* [PATCH v2] rust: id_pool: document panics in `find_unused_id` and `release_id`
@ 2026-09-08 20:31 Georgios Androutsopoulos
2026-10-06 15:07 ` Georgios Androutsopoulos
2026-10-06 16:16 ` Yury Norov
0 siblings, 2 replies; 3+ messages in thread
From: Georgios Androutsopoulos @ 2026-09-08 20:31 UTC (permalink / raw)
To: Alice Ryhl, Burak Emir, Miguel Ojeda, Yury Norov
Cc: Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Trevor Gross, Danilo Krummrich, Daniel Almeida,
Tamir Duberstein, Alexandre Courbot, Onur Özkan,
Eliot Courtney, rust-for-linux, linux-kernel,
Georgios Androutsopoulos
`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`.
Fixes: 2cdae413cd3e ("rust: add dynamic ID pool abstraction for bitmap")
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Georgios Androutsopoulos <georgeandrout13@gmail.com>
---
Changes in v2:
- Use "within bounds" instead of "in bounds", following feedback from
Alexandre Courbot.
- Add Fixes:, treating the documentation hole as a bug [1].
- Link to v1: https://lore.kernel.org/rust-for-linux/20260829153442.20799-1-georgeandrout13@gmail.com/
[1] https://lore.kernel.org/rust-for-linux/CANiq72mgZg-QBy4gwzHmD4gJm4wScktfpdDtyZt3Zijk83h2CA@mail.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 384753fe0e44..ae6960d7f638 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
+ /// within 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 within 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] rust: id_pool: document panics in `find_unused_id` and `release_id`
2026-09-08 20:31 [PATCH v2] rust: id_pool: document panics in `find_unused_id` and `release_id` Georgios Androutsopoulos
@ 2026-10-06 15:07 ` Georgios Androutsopoulos
2026-10-06 16:16 ` Yury Norov
1 sibling, 0 replies; 3+ messages in thread
From: Georgios Androutsopoulos @ 2026-10-06 15:07 UTC (permalink / raw)
To: Alice Ryhl, Burak Emir, Miguel Ojeda, Yury Norov
Cc: Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Trevor Gross, Danilo Krummrich, Daniel Almeida,
Tamir Duberstein, Alexandre Courbot, Onur Özkan,
Eliot Courtney, rust-for-linux, linux-kernel
On Tue, Sep 8, 2026 at 4:32 PM Georgios Androutsopoulos
<georgeandrout13@gmail.com> wrote:
>
> `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`.
>
> Fixes: 2cdae413cd3e ("rust: add dynamic ID pool abstraction for bitmap")
> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
> Signed-off-by: Georgios Androutsopoulos <georgeandrout13@gmail.com>
> ---
> Changes in v2:
> - Use "within bounds" instead of "in bounds", following feedback from
> Alexandre Courbot.
> - Add Fixes:, treating the documentation hole as a bug [1].
> - Link to v1: https://lore.kernel.org/rust-for-linux/20260829153442.20799-1-georgeandrout13@gmail.com/
>
> [1] https://lore.kernel.org/rust-for-linux/CANiq72mgZg-QBy4gwzHmD4gJm4wScktfpdDtyZt3Zijk83h2CA@mail.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 384753fe0e44..ae6960d7f638 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
> + /// within 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 within 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
>
Hi,
Just checking if there are any remaining concerns with this patch, or if
it can be picked up.
Thanks,
Georgios
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] rust: id_pool: document panics in `find_unused_id` and `release_id`
2026-09-08 20:31 [PATCH v2] rust: id_pool: document panics in `find_unused_id` and `release_id` Georgios Androutsopoulos
2026-10-06 15:07 ` Georgios Androutsopoulos
@ 2026-10-06 16:16 ` Yury Norov
1 sibling, 0 replies; 3+ messages in thread
From: Yury Norov @ 2026-10-06 16:16 UTC (permalink / raw)
To: Georgios Androutsopoulos
Cc: Alice Ryhl, Burak Emir, Miguel Ojeda, Yury Norov, Boqun Feng,
Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Trevor Gross, Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
Alexandre Courbot, Onur Özkan, Eliot Courtney,
rust-for-linux, linux-kernel
On Tue, Sep 08, 2026 at 04:31:57PM -0400, Georgios Androutsopoulos wrote:
> `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`.
>
> Fixes: 2cdae413cd3e ("rust: add dynamic ID pool abstraction for bitmap")
> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
> Signed-off-by: Georgios Androutsopoulos <georgeandrout13@gmail.com>
Applied both in bitmap-for-next. Thanks!
> ---
> Changes in v2:
> - Use "within bounds" instead of "in bounds", following feedback from
> Alexandre Courbot.
> - Add Fixes:, treating the documentation hole as a bug [1].
> - Link to v1: https://lore.kernel.org/rust-for-linux/20260829153442.20799-1-georgeandrout13@gmail.com/
>
> [1] https://lore.kernel.org/rust-for-linux/CANiq72mgZg-QBy4gwzHmD4gJm4wScktfpdDtyZt3Zijk83h2CA@mail.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 384753fe0e44..ae6960d7f638 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
> + /// within 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 within 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-06 16:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-08 20:31 [PATCH v2] rust: id_pool: document panics in `find_unused_id` and `release_id` Georgios Androutsopoulos
2026-10-06 15:07 ` Georgios Androutsopoulos
2026-10-06 16:16 ` Yury Norov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®