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: <CANiq72m9_DUG67keD+Sa660X08_Sm1MSm9NB2K2iEUme5DpozQ@mail.gmail.com>
Date: Wed, 9 Oct 2024 14:32:11 +0200
From: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
To: Christian dos Santos de Lima <christiansantoslima21@...il.com>
Cc: rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org, 
	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>, 
	Benno Lossin <benno.lossin@...ton.me>, Andreas Hindborg <a.hindborg@...nel.org>, 
	Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>
Subject: Re: [PATCH] rust: transmute: Add implementation for FromBytes trait

On Wed, Oct 9, 2024 at 3:48 AM Christian dos Santos de Lima
<christiansantoslima21@...il.com> wrote:
>
> +pub unsafe trait FromBytes {
> +    ///Converts a slice of Bytes into a Reference to Self
> +    ///
> +    /// # Examples
> +    /// ```
> +    ///    pub unsafe trait FromBytes {

Apart from what Alice mentions (which is critical, since we are
looking to get into stable Rust as soon as feasible -- please see
https://rust-for-linux.com/unstable-features#usage-in-the-kernel),
please also format the code, documentation and examples appropriately
(please see other files to see how it is usually done, we mostly
follow Rust's standard library conventions).

> +        unsafe {
> +            let slice_ptr = slice_of_bytes.as_ptr() as *const Self;
> +            &*slice_ptr
> +        }

Please note that we require `// SAFETY` comments too. Missing those is
already a warning/error (depending on the kernel configuration) in
rust-next.

Thanks for the patch!

Cheers,
Miguel

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ