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] [day] [month] [year] [list]
Message-ID: <a27d97ff-7d40-4595-9c0d-51415d958ebe@gmail.com>
Date: Tue, 22 Apr 2025 16:17:33 +0200
From: Christian Schrefl <chrisi.schrefl@...il.com>
To: Benno Lossin <benno.lossin@...ton.me>, Miguel Ojeda <ojeda@...nel.org>,
 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>, Andreas Hindborg <a.hindborg@...nel.org>,
 Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>,
 Danilo Krummrich <dakr@...nel.org>, Fiona Behrens <me@...enk.dev>
Cc: rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/8] rust: pin-init: Implement `Wrapper` for
 `UnsafePinned` behind feature flag.

On 22.04.25 1:21 PM, Benno Lossin wrote:
> On Tue Apr 22, 2025 at 11:42 AM CEST, Christian Schrefl wrote:
>> On 22.04.25 12:18 AM, Benno Lossin wrote:
>>> @@ -1557,3 +1561,11 @@ fn pin_init<E>(value_init: impl PinInit<T, E>) -> impl PinInit<Self, E> {
>>>          unsafe { cast_pin_init(value_init) }
>>>      }
>>>  }
>>> +
>>> +#[cfg(all(feature = "unsafe-pinned", CONFIG_RUSTC_HAS_UNSAFE_PINNED))]
>>> +impl<T> Wrapper<T> for core::pin::UnsafePinned<T> {
>>> +    fn pin_init<E>(init: impl PinInit<T, E>) -> impl PinInit<Self, E> {
>>> +        // SAFETY: `UnsafePinned<T>` has a compatible layout to `T`.
>>> +        unsafe { cast_pin_init(init) }
>>> +    }
>>> +}
>>
>> I've realized that for us to use `UnsafePinned` in `Opaque` internally 
>> we need to have a `T: ?Sized` for this implementation. `cast_pin_init`
>> won't work for that since we can't cast pointers between different DSTs.
>> We could add something similar that uses a closure to convert a
>> `*mut T` to `*mut U`.
> 
> I don't follow, which types do you need to wrap in `Opaque` that are not
> sized?
> 
> Since `Opaque` uses `MaybeUninit` under the hood, it cannot support
> `!Sized` types anyways, so I'm a bit confused.

Sorry I got an `?Sized` error and convinced myself that `Opaque` had
a `T: ?Sized` bound. After looking at it again there is no problem.

I'll work on V2 of my `UnsafePinned` patch with a second commit
for using it in `Opaque`.

Cheers
Chrisitan

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ