* [RFC PATCH] rust: firmware: diagnose insufficient modinfo buffer capacity
@ 2026-11-22 16:56 Georgios Androutsopoulos
0 siblings, 0 replies; only message in thread
From: Georgios Androutsopoulos @ 2026-11-22 16:56 UTC (permalink / raw)
To: mcgrof, dakr
Cc: ojeda, boqun, gary, bjorn3_gh, lossin, a.hindborg, aliceryhl,
tmgross, daniel.almeida, tamird, acourbot, work, driver-core,
rust-for-linux, linux-kernel, Georgios Androutsopoulos
`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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-22 16:56 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-22 16:56 [RFC PATCH] rust: firmware: diagnose insufficient modinfo buffer capacity Georgios Androutsopoulos
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®