From: sashiko-bot@kernel.org
To: "Eliot Courtney" <ecourtney@nvidia.com>
Cc: ojeda@kernel.org, "Danilo Krummrich" <dakr@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v8 11/12] rust: id_pool: do not round capacity up to BitmapVec::MAX_INLINE_LEN
Date: Thu, 27 Aug 2026 07:41:47 +0000 [thread overview]
Message-ID: <20260827074147.EED811F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260827-chid-v8-11-bc74c77d0214@nvidia.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Calling `find_unused_id(0)` or `reserve_ids(0, ...)` on an `IdPool` initialized with a capacity of 0 triggers a kernel panic when `CONFIG_RUST_BITMAP_HARDENED` is enabled.
--
commit c0cd93bbf9f36768f04bc377021b9e32ae0dce05
Author: Eliot Courtney <ecourtney@nvidia.com>
rust: id_pool: do not round capacity up to BitmapVec::MAX_INLINE_LEN
This commit modifies IdPool::with_capacity to stop rounding the capacity up
to BitmapVec::MAX_INLINE_LEN. This allows explicitly creating pools with 0
capacity, and adjusts grow_request and shrink_request to handle the new floor.
> diff --git a/rust/kernel/id_pool.rs b/rust/kernel/id_pool.rs
> index 06a4c71c4c6c9..4f329249df9d0 100644
> --- a/rust/kernel/id_pool.rs
> +++ b/rust/kernel/id_pool.rs
> @@ -112,13 +112,8 @@ pub fn new() -> Self {
> }
>
> /// Constructs a new [`IdPool`] with space for a specific number of bits.
> - ///
> - /// A capacity below [`MAX_INLINE_LEN`] is adjusted to [`MAX_INLINE_LEN`].
> - ///
> - /// [`MAX_INLINE_LEN`]: BitmapVec::MAX_INLINE_LEN
> #[inline]
> pub fn with_capacity(num_ids: usize, flags: Flags) -> Result<Self, AllocError> {
> - let num_ids = usize::max(num_ids, BitmapVec::MAX_INLINE_LEN);
> let map = BitmapVec::new(num_ids, flags)?;
> Ok(Self { map })
> }
[Severity: High]
Does allowing a capacity of 0 here introduce a kernel panic during standard
allocations if CONFIG_RUST_BITMAP_HARDENED is enabled?
If a caller attempts to allocate an ID on a 0-capacity pool using patterns like
pool.find_unused_id(0) or pool.reserve_ids(0, ...), the call delegates directly
to the underlying bitmap without its own bounds check:
IdPool::find_unused_id() {
Some(UnusedId {
id: self.map.next_zero_bit(offset)?,
pool: self,
})
}
This passes offset=0 to Bitmap::next_zero_bit(), which contains an assertion
that start < self.len(). Since 0 < 0 is false on a 0-capacity pool, it panics
immediately instead of gracefully returning None to prompt a grow_request().
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260827-chid-v8-0-bc74c77d0214@nvidia.com?part=11
next prev parent reply other threads:[~2026-08-27 7:41 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-27 7:28 [PATCH v8 00/12] rust: Add support for reserving of ranges of IDs Eliot Courtney
2026-08-27 7:28 ` [PATCH v8 01/12] rust: bitmap: use function-level cfg on kunit test Eliot Courtney
2026-08-27 7:28 ` [PATCH v8 02/12] rust: bitmap: restrict bitmap length to at most i32::MAX Eliot Courtney
2026-08-27 7:40 ` sashiko-bot
2026-08-27 7:28 ` [PATCH v8 03/12] rust: num: add cv! macro to create values from constant expressions Eliot Courtney
2026-08-27 9:32 ` Alice Ryhl
2026-08-27 10:42 ` Alexandre Courbot
2026-08-27 11:12 ` Alexandre Courbot
2026-08-27 13:48 ` Eliot Courtney
2026-08-27 13:59 ` Gary Guo
2026-08-27 14:29 ` Alexandre Courbot
2026-08-27 14:37 ` Gary Guo
2026-08-27 14:55 ` Alice Ryhl
2026-08-28 0:08 ` Eliot Courtney
2026-08-28 3:40 ` Alexandre Courbot
2026-08-28 4:53 ` Eliot Courtney
2026-08-28 14:01 ` Gary Guo
2026-08-27 7:28 ` [PATCH v8 04/12] rust: prelude: add `num::cv` Eliot Courtney
2026-08-27 7:28 ` [PATCH v8 05/12] rust: use cv! to build Bounded values from constants Eliot Courtney
2026-08-27 7:28 ` [PATCH v8 06/12] rust: sizes: add sub-1K size constants Eliot Courtney
2026-08-28 5:11 ` Alexandre Courbot
2026-08-27 7:28 ` [PATCH v8 07/12] rust: sizes: implement SizeConstants for Alignment Eliot Courtney
2026-08-28 5:13 ` Alexandre Courbot
2026-08-28 5:23 ` Eliot Courtney
2026-08-28 5:36 ` Alexandre Courbot
2026-08-28 6:27 ` Miguel Ojeda
2026-08-27 7:28 ` [PATCH v8 08/12] rust: use Alignment size constants Eliot Courtney
2026-08-27 7:28 ` [PATCH v8 09/12] rust: bitmap: add contiguous area operations Eliot Courtney
2026-08-27 7:43 ` sashiko-bot
2026-08-27 7:28 ` [PATCH v8 10/12] rust: id_pool: add contiguous ID reservation Eliot Courtney
2026-08-27 7:28 ` [PATCH v8 11/12] rust: id_pool: do not round capacity up to BitmapVec::MAX_INLINE_LEN Eliot Courtney
2026-08-27 7:41 ` sashiko-bot [this message]
2026-08-27 7:28 ` [PATCH v8 12/12] gpu: nova-core: add ChannelIdPool Eliot Courtney
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=20260827074147.EED811F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=acourbot@nvidia.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=ecourtney@nvidia.com \
--cc=ojeda@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox