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: <3bad6983-b412-4386-931c-4eca3ed54da3@kernel.org>
Date: Mon, 20 Oct 2025 16:18:26 +0200
From: Danilo Krummrich <dakr@...nel.org>
To: Alice Ryhl <aliceryhl@...gle.com>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
 Yury Norov <yury.norov@...il.com>, Arve Hjønnevåg
 <arve@...roid.com>, Todd Kjos <tkjos@...roid.com>,
 Martijn Coenen <maco@...roid.com>, Joel Fernandes <joelagnelf@...dia.com>,
 Christian Brauner <brauner@...nel.org>, Carlos Llamas <cmllamas@...gle.com>,
 Suren Baghdasaryan <surenb@...gle.com>, Burak Emir <bqe@...gle.com>,
 Miguel Ojeda <ojeda@...nel.org>, 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>, Trevor Gross <tmgross@...ch.edu>,
 rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/2] rust: bitmap: add MAX_LEN and NO_ALLOC_MAX_LEN
 constants

On 10/20/25 3:33 PM, Alice Ryhl wrote:
> To avoid hard-coding these values in drivers, define constants for them
> that drivers can reference.
> 
> Signed-off-by: Alice Ryhl <aliceryhl@...gle.com>

Yes, please! :)

Acked-by: Danilo Krummrich <dakr@...nel.org>

> @@ -238,11 +244,11 @@ pub fn new(nbits: usize, flags: Flags) -> Result<Self, AllocError> {
>                  nbits,
>              });
>          }
> -        if nbits > i32::MAX.try_into().unwrap() {
> +        if nbits > Self::MAX_LEN {
>              return Err(AllocError);
>          }
>          let nbits_u32 = u32::try_from(nbits).unwrap();

Can we also get rid of this please? :)

> -        // SAFETY: `BITS_PER_LONG < nbits` and `nbits <= i32::MAX`.
> +        // SAFETY: `BITS_PER_LONG < nbits` and `nbits <= MAX_LEN`.
>          let ptr = unsafe { bindings::bitmap_zalloc(nbits_u32, flags.as_raw()) };
>          let ptr = NonNull::new(ptr).ok_or(AllocError)?;
>          // INVARIANT: `ptr` returned by C `bitmap_zalloc` and `nbits` checked.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ