From: Alice Ryhl <aliceryhl@google.com>
To: Benno Lossin <benno.lossin@proton.me>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Andreas Hindborg" <a.hindborg@samsung.com>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] rust: sync: require `Send` and `Sync` for `Backend::State`
Date: Tue, 3 Sep 2024 11:30:14 +0200 [thread overview]
Message-ID: <CAH5fLgihM6OeuVrAhSXAqb9RDKBa8p7+EOsFuuqkGu-OzoapZw@mail.gmail.com> (raw)
In-Reply-To: <20240903091700.172734-1-benno.lossin@proton.me>
On Tue, Sep 3, 2024 at 11:17 AM Benno Lossin <benno.lossin@proton.me> wrote:
>
> `Lock<T, B>` implements `Send` and `Sync` when `T` is `Send` or `Sync`
> respectively. Since this does not depend on `B`, creating a `Lock` that
> is `Send` and `Sync`, but with a `!Sync` or `!Send` state is possible.
> This is a soundness issue, thus add the bounds to the respective impls.
>
> Signed-off-by: Benno Lossin <benno.lossin@proton.me>
Currently, B::State is set directly to `bindings::spinlock_t` or
`bindings::mutex` and these types are pretty unlikely to be Send/Sync
on all kernel configurations. If you're going to make this change, you
will need to change these types.
Considering that B::State is already stored in Opaque meaning that we
don't run its destructor either, it's not really treated as a normal
field right now. Perhaps it would be better to change the safety
requirements of the `Backend` trait to impose restrictions on the
thread safety of B::State?
Alice
next prev parent reply other threads:[~2024-09-03 9:30 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-03 9:17 [PATCH 1/2] rust: sync: require `Send` and `Sync` for `Backend::State` Benno Lossin
2024-09-03 9:17 ` [PATCH 2/2] rust: sync: require `Sync` for `Backend::GuardState` Benno Lossin
2024-09-03 9:32 ` Alice Ryhl
2024-09-03 10:06 ` Benno Lossin
2024-09-03 11:34 ` Alice Ryhl
2024-09-03 9:30 ` Alice Ryhl [this message]
2024-09-03 9:57 ` [PATCH 1/2] rust: sync: require `Send` and `Sync` for `Backend::State` Benno Lossin
2024-09-03 11:31 ` Alice Ryhl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAH5fLgihM6OeuVrAhSXAqb9RDKBa8p7+EOsFuuqkGu-OzoapZw@mail.gmail.com \
--to=aliceryhl@google.com \
--cc=a.hindborg@samsung.com \
--cc=alex.gaynor@gmail.com \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=gary@garyguo.net \
--cc=linux-kernel@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).