lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <D9YO9OZ5X83E.2DOL82V16Z8QK@kernel.org>
Date: Sat, 17 May 2025 21:11:20 +0200
From: "Benno Lossin" <lossin@...nel.org>
To: "Christian Schrefl" <chrisi.schrefl@...il.com>, "Miguel Ojeda"
 <ojeda@...nel.org>, "Sky" <sky@...9.dev>, "Alex Gaynor"
 <alex.gaynor@...il.com>, "Boqun Feng" <boqun.feng@...il.com>, "Gary Guo"
 <gary@...yguo.net>, Björn Roy Baron
 <bjorn3_gh@...tonmail.com>, "Benno Lossin" <benno.lossin@...ton.me>,
 "Andreas Hindborg" <a.hindborg@...nel.org>, "Alice Ryhl"
 <aliceryhl@...gle.com>, "Trevor Gross" <tmgross@...ch.edu>, "Danilo
 Krummrich" <dakr@...nel.org>, Gerald Wisböck
 <gerald.wisboeck@...ther.ink>, "Nathan Chancellor" <nathan@...nel.org>,
 "Nick Desaulniers" <nick.desaulniers+lkml@...il.com>, "Bill Wendling"
 <morbo@...gle.com>, "Justin Stitt" <justinstitt@...gle.com>
Cc: <linux-kernel@...r.kernel.org>, <rust-for-linux@...r.kernel.org>,
 <llvm@...ts.linux.dev>
Subject: Re: [PATCH v4 1/3] rust: add UnsafePinned type

On Sat May 17, 2025 at 1:36 PM CEST, Christian Schrefl wrote:
> Hi Benno,
>
> On 13.05.25 10:51 PM, Benno Lossin wrote:
>> On Sun May 11, 2025 at 8:21 PM CEST, Christian Schrefl wrote:
>>> `UnsafePinned<T>` is useful for cases where a value might be shared with
>>> C code but not directly used by it. In particular this is added for
>>> storing additional data in the `MiscDeviceRegistration` which will be
>>> shared between `fops->open` and the containing struct.
>>>
>>> Similar to `Opaque` but guarantees that the value is always initialized
>>> and that the inner value is dropped when `UnsafePinned` is dropped.
>>>
>>> This was originally proposed for the IRQ abstractions [0] and is also
>>> useful for other where the inner data may be aliased, but is always
>>> valid and automatic `Drop` is desired.
>>>
>>> Since then the `UnsafePinned` type was added to upstream Rust [1] by Sky
>>> as a unstable feature, therefore this patch implements the subset of the
>>> upstream API for the `UnsafePinned` type required for additional data in
>>> `MiscDeviceRegistration` and in the implementation of the `Opaque` type.
>>>
>>> Some differences to the upstream type definition are required in the
>>> kernel implementation, because upstream type uses some compiler changes
>>> to opt out of certain optimizations, this is documented in the
>>> documentation and a comment on the `UnsafePinned` type.
>>>
>>> The documentation on is based on the upstream rust documentation with
>>> minor modifications for the kernel implementation.
>>>
>>> Link: https://lore.kernel.org/rust-for-linux/CAH5fLgiOASgjoYKFz6kWwzLaH07DqP2ph+3YyCDh2+gYqGpABA@mail.gmail.com [0]
>>> Link: https://github.com/rust-lang/rust/pull/137043 [1]
>>> Suggested-by: Alice Ryhl <aliceryhl@...gle.com>
>>> Reviewed-by: Gerald Wisböck <gerald.wisboeck@...ther.ink>
>>> Reviewed-by: Alice Ryhl <aliceryhl@...gle.com>
>>> Co-developed-by: Sky <sky@...9.dev>
>>> Signed-off-by: Sky <sky@...9.dev>
>>> Signed-off-by: Christian Schrefl <chrisi.schrefl@...il.com>
>> 
>> One nit below, with that fixed:
>> 
>> Reviewed-by: Benno Lossin <lossin@...nel.org>
>> 
>>> ---
>>>  rust/kernel/types.rs               |   6 ++
>>>  rust/kernel/types/unsafe_pinned.rs | 111 +++++++++++++++++++++++++++++++++++++
>>>  2 files changed, 117 insertions(+)
>>>
>>> diff --git a/rust/kernel/types.rs b/rust/kernel/types.rs
>>> index 9d0471afc9648f2973235488b441eb109069adb1..705f420fdfbc4a576de1c4546578f2f04cdf615e 100644
>>> --- a/rust/kernel/types.rs
>>> +++ b/rust/kernel/types.rs
>>> @@ -578,3 +581,6 @@ pub enum Either<L, R> {
>>>  /// [`NotThreadSafe`]: type@...ThreadSafe
>>>  #[allow(non_upper_case_globals)]
>>>  pub const NotThreadSafe: NotThreadSafe = PhantomData;
>>> +
>>> +mod unsafe_pinned;
>>> +pub use unsafe_pinned::UnsafePinned;
>> 
>> I would put `mod` to the top of the 
>
> Your sentence was cut off, I assume you mean:
>
>> I would put `mod` to the top of the file.

Oh yeah sorry about that.

> I can do that, let me know if I should send a
> new version or if this will be fixed when applying.

I think Miguel can do this when picking the patch :)

---
Cheers,
Benno

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ