rust: firmware: diagnose insufficient modinfo buffer capacity
Subsystems (3)
RFC PATCH 1/1 rust: firmware: diagnose insufficient modinfo buffer capacity
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.
Signed-off-by Georgios Androutsopoulos <[email protected]>
--- rust/kernel/firmware.rs | 4 ++++ 1 file changed, 4 insertions(+)
rust/kernel/firmware.rs +4 -0
@@ -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
Signature · 1 line
2.47.3