From: Georgios Androutsopoulos <georgeandrout13@gmail.com>
To: Alice Ryhl <aliceryhl@google.com>,
Burak Emir <burak.emir@gmail.com>,
Miguel Ojeda <ojeda@kernel.org>,
Yury Norov <yury.norov@gmail.com>
Cc: "Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Tamir Duberstein" <tamird@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Onur Özkan" <work@onurozkan.dev>,
"Eliot Courtney" <ecourtney@nvidia.com>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
"Georgios Androutsopoulos" <georgeandrout13@gmail.com>
Subject: [PATCH] rust: id_pool: document panics in `find_unused_id` and `release_id`
Date: Sat, 29 Aug 2026 11:34:42 -0400 [thread overview]
Message-ID: <20260829153442.20799-1-georgeandrout13@gmail.com> (raw)
`find_unused_id()` calls `Bitmap::next_zero_bit()` and `release_id()`
calls `Bitmap::clear_bit()`, both of which panic when
`CONFIG_RUST_BITMAP_HARDENED` is enabled and the index is out of
bounds. Neither `IdPool` method documents this.
Add the missing `# Panics` sections and state the bounds requirement
on `offset` and `id`.
Signed-off-by: Georgios Androutsopoulos <georgeandrout13@gmail.com>
---
rust/kernel/id_pool.rs | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/rust/kernel/id_pool.rs b/rust/kernel/id_pool.rs
index 384753fe0..ae6960d7f 100644
--- a/rust/kernel/id_pool.rs
+++ b/rust/kernel/id_pool.rs
@@ -224,7 +224,13 @@ pub fn grow(&mut self, mut resizer: PoolResizer) {
/// Finds an unused ID in the bitmap.
///
/// Upon success, returns its index. Otherwise, returns [`None`]
- /// to indicate that a [`Self::grow_request`] is needed.
+ /// to indicate that a [`Self::grow_request`] is needed. `offset` must be
+ /// in bounds.
+ ///
+ /// # Panics
+ ///
+ /// Panics if `CONFIG_RUST_BITMAP_HARDENED` is enabled and `offset` is out
+ /// of bounds.
#[inline]
#[must_use]
pub fn find_unused_id(&mut self, offset: usize) -> Option<UnusedId<'_>> {
@@ -236,6 +242,13 @@ pub fn find_unused_id(&mut self, offset: usize) -> Option<UnusedId<'_>> {
}
/// Releases an ID.
+ ///
+ /// The `id` must be in bounds.
+ ///
+ /// # Panics
+ ///
+ /// Panics if `CONFIG_RUST_BITMAP_HARDENED` is enabled and `id` is out of
+ /// bounds.
#[inline]
pub fn release_id(&mut self, id: usize) {
self.map.clear_bit(id);
base-commit: 73e3f0710014fe6d4ed98cfc02292f6121db7558
--
2.47.3
next reply other threads:[~2026-08-29 15:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-29 15:34 Georgios Androutsopoulos [this message]
2026-08-31 1:08 ` [PATCH] rust: id_pool: document panics in `find_unused_id` and `release_id` Alexandre Courbot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260829153442.20799-1-georgeandrout13@gmail.com \
--to=georgeandrout13@gmail.com \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=burak.emir@gmail.com \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=ecourtney@nvidia.com \
--cc=gary@garyguo.net \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=work@onurozkan.dev \
--cc=yury.norov@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.