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: <KGzE8bKBnwN0hJkKd2Cdes4IN7iuBDbKsa9OpVt7Q_pZZRithsnP3ygISozTyGn5UmfrOcd-11ZQ-vElMwrma6sozkXF3t8Jl7DKhdc2TGA=@proton.me>
Date:   Sat, 15 Jul 2023 09:58:48 +0000
From:   Benno Lossin <benno.lossin@...ton.me>
To:     Asahi Lina <lina@...hilina.net>
Cc:     Miguel Ojeda <ojeda@...nel.org>,
        Alex Gaynor <alex.gaynor@...il.com>,
        Wedson Almeida Filho <wedsonaf@...il.com>,
        Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
        Björn Roy Baron <bjorn3_gh@...tonmail.com>,
        rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] rust: init: Implement Zeroable::zeroed()

> By analogy to Default::default(), this just returns the zeroed
> representation of the type directly. init::zeroed() is the version that
> returns an initializer.
> 
> Signed-off-by: Asahi Lina <lina@...hilina.net>
> ---
>  rust/kernel/init.rs | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/rust/kernel/init.rs b/rust/kernel/init.rs
> index b4332a4ec1f4..c300ce39ac10 100644
> --- a/rust/kernel/init.rs
> +++ b/rust/kernel/init.rs
> @@ -1354,7 +1354,14 @@ pub unsafe trait PinnedDrop: __internal::HasPinData {
>  /// ```rust,ignore
>  /// let val: Self = unsafe { core::mem::zeroed() };
>  /// ```
> -pub unsafe trait Zeroable {}
> +pub unsafe trait Zeroable: core::marker::Sized {

Note that `Sized` is in the prelude so you do not need the full path
`core::marker::`. Also same concern as Alice.

> +    /// Create a new zeroed T.
> +    ///
> +    /// Directly returns a zeroed T, analogous to Default::default().

Please add a link to `init::zeroed()` and explain that that is the
initializer version of this function.

> +    fn zeroed() -> Self {
> +        unsafe { core::mem::zeroed() }

Missing `SAFETY` comment.

--
Cheers,
Benno

> +    }
> +}
> 
>  /// Create a new zeroed T.
>  ///
> 
> ---
> base-commit: 06c2afb862f9da8dc5efa4b6076a0e48c3fbaaa5
> change-id: 20230714-zeroed-dd05bc737f85
> 
> Thank you,
> ~~ Lina
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ