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: <CAJ-ks9mhc3CqDnZz3BMXFDxNPW0KgYZrXHvKwTGYKhSF_rDDMA@mail.gmail.com>
Date: Sun, 29 Jun 2025 15:01:14 -0400
From: Tamir Duberstein <tamird@...il.com>
To: Antonio Hickey <contact@...oniohickey.com>
Cc: 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 <lossin@...nel.org>, Andreas Hindborg <a.hindborg@...nel.org>, 
	Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>, 
	Danilo Krummrich <dakr@...nel.org>, Daniel Cote <danielstonecote@...il.com>, 
	rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 2/2] rust: uaccess: refactor to use `overflow_assert!`

On Sat, Jun 28, 2025 at 10:44 PM Antonio Hickey
<contact@...oniohickey.com> wrote:
>
> Using the `overflow_assert!` macro here adds documentation to
> the intent of the assertion, and avoids local `#ifdefs`s by
> encapsulating the conditional behavior to the macro itself.
>
> Co-developed-by: Daniel Cote <danielstonecote@...il.com>
> Signed-off-by: Daniel Cote <danielstonecote@...il.com>
> Signed-off-by: Antonio Hickey <contact@...oniohickey.com>
> Link: https://github.com/Rust-for-Linux/linux/issues/1159
> Suggested-by: Miguel Ojeda <ojeda@...nel.org>
> ---

Reviewed-by: Tamir Duberstein <tamird@...il.com>

>  rust/kernel/uaccess.rs | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/rust/kernel/uaccess.rs b/rust/kernel/uaccess.rs
> index 635a03e0989f..452a5e0d76d2 100644
> --- a/rust/kernel/uaccess.rs
> +++ b/rust/kernel/uaccess.rs
> @@ -9,6 +9,7 @@
>      bindings,
>      error::Result,
>      ffi::{c_char, c_void},
> +    overflow_assert,
>      prelude::*,
>      transmute::{AsBytes, FromBytes},
>  };
> @@ -394,8 +395,7 @@ fn raw_strncpy_from_user(dst: &mut [MaybeUninit<u8>], src: UserPtr) -> Result<us
>          return Err(Error::from_errno(res as i32));
>      }
>
> -    #[cfg(CONFIG_RUST_OVERFLOW_CHECKS)]
> -    assert!(res <= len);
> +    overflow_assert!(res <= len);
>
>      // GUARANTEES: `strncpy_from_user` was successful, so `dst` has contents in accordance with the
>      // guarantees of this function.
> --
> 2.50.0
>
>
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ