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: <672f991f-96af-9389-278d-77bde2ee2db8@ryhl.io>
Date:   Thu, 30 Mar 2023 17:07:26 +0200
From:   Alice Ryhl <alice@...l.io>
To:     Gary Guo <gary@...yguo.net>, y86-dev@...tonmail.com
Cc:     Miguel Ojeda <ojeda@...nel.org>,
        Alex Gaynor <alex.gaynor@...il.com>,
        Wedson Almeida Filho <wedsonaf@...il.com>,
        Boqun Feng <boqun.feng@...il.com>,
        Björn Roy Baron <bjorn3_gh@...tonmail.com>,
        rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org,
        patches@...ts.linux.dev
Subject: Re: [PATCH v3 08/13] rust: init: add `stack_pin_init!` macro

On 3/30/23 13:06, Gary Guo wrote:
>> +impl<T> StackInit<T> {
>> +    /// Creates a new [`StackInit<T>`] that is uninitialized. Use [`stack_pin_init`] instead of this
>> +    /// primitive.
>> +    ///
>> +    /// [`stack_pin_init`]: kernel::stack_pin_init
>> +    #[inline]
>> +    pub fn uninit() -> Self {
>> +        Self(MaybeUninit::uninit(), false)
>> +    }
>> +
>> +    /// Initializes the contents and returns the result.
>> +    ///
>> +    /// # Safety
>> +    ///
>> +    /// The caller ensures that `self` is on the stack and not accessible in any other way, if this
>> +    /// function returns `Ok`.
>> +    #[inline]
>> +    pub unsafe fn init<E>(&mut self, init: impl PinInit<T, E>) -> Result<Pin<&mut T>, E> {
> 
> Could this be made safe if the signature takes `self: Pin<&mut Self>`
> instead?
> 
> The std `pin!` macro is stable in
> 1.68 so we can just `core::pin::pin!(StackInit::uninit())` and then
> call `init` on it.
> 
> Best,
> Gary

Yeah, I think that would work. If it's marked safe, then it will be 
possible to call `init` several times, but this is fine if `init` 
transitions the `StackInit` back into its uninitialized state before 
attempting to initialize it again.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ