From: Georgios Androutsopoulos <georgeandrout13@gmail.com>
To: mcgrof@kernel.org, dakr@kernel.org
Cc: ojeda@kernel.org, boqun@kernel.org, gary@garyguo.net,
bjorn3_gh@protonmail.com, lossin@kernel.org,
a.hindborg@kernel.org, aliceryhl@google.com, tmgross@umich.edu,
daniel.almeida@collabora.com, tamird@kernel.org,
acourbot@nvidia.com, work@onurozkan.dev,
driver-core@lists.linux.dev, rust-for-linux@vger.kernel.org,
linux-kernel@vger.kernel.org,
Georgios Androutsopoulos <georgeandrout13@gmail.com>
Subject: [RFC PATCH] rust: firmware: diagnose insufficient modinfo buffer capacity
Date: Sun, 22 Nov 2026 11:56:09 -0500 [thread overview]
Message-ID: <20261122165609.1914670-1-georgeandrout13@gmail.com> (raw)
`ModInfoBuilder::push_internal()` tracks the required length even when
the buffer is too small, but `push_module_name()` can still index past
its end. During const evaluation, this reports an out-of-bounds index
rather than the capacity constraint.
Check the capacity explicitly with `build_error!` so the failure
reports the violated constraint.
Link: https://github.com/Rust-for-Linux/linux/issues/1271
Signed-off-by: Georgios Androutsopoulos <georgeandrout13@gmail.com>
---
rust/kernel/firmware.rs | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/rust/kernel/firmware.rs b/rust/kernel/firmware.rs
index a18f8b84f3e3..54c6a13714c5 100644
--- a/rust/kernel/firmware.rs
+++ b/rust/kernel/firmware.rs
@@ -339,6 +339,10 @@ const fn push_module_name(self) -> Self {
this = this.push_internal(module_name.to_bytes_with_nul());
if N != 0 {
+ if this.n > N {
+ crate::build_error!("Modinfo buffer too small for module name.");
+ }
+
// Re-use the space taken by the NULL terminator and swap it with the '.' separator.
this.buf[this.n - 1] = b'.';
}
base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
--
2.47.3
reply other threads:[~2026-11-22 16:56 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261122165609.1914670-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=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=driver-core@lists.linux.dev \
--cc=gary@garyguo.net \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=mcgrof@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 \
/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
all inboxes | Powered by JetHome®