[PATCH v1] rust: bug: update the SAFETY comment for warn_slowpath_fmt() on UML
FUJITA Tomonori
tomo at flapping.org
Fri Oct 2 03:45:50 PDT 2026
From: FUJITA Tomonori <fujita.tomonori at gmail.com>
The SAFETY comment says that it is always safe to call
`warn_slowpath_fmt()` with a valid null-terminated string. This is not
true. The taint argument must also be a valid taint number.
Commit 951d09ca450c ("rust: bug: pass TAINT_WARN to warn_slowpath_fmt()
on UML") fixed a bug where it was not.
List each condition that the call meets: the file name, the taint
number, and the null `fmt`.
Suggested-by: Miguel Ojeda <ojeda at kernel.org>
Signed-off-by: FUJITA Tomonori <fujita.tomonori at gmail.com>
---
rust/kernel/bug.rs | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/rust/kernel/bug.rs b/rust/kernel/bug.rs
index 6abed2c055b1..3b40b0bd37b5 100644
--- a/rust/kernel/bug.rs
+++ b/rust/kernel/bug.rs
@@ -88,8 +88,10 @@ macro_rules! warn_flags {
_ = $flags;
}
- // SAFETY: It is always safe to call `warn_slowpath_fmt()`
- // with a valid null-terminated string.
+ // SAFETY:
+ // - The file name is a null-terminated string with `'static` lifetime.
+ // - `TAINT_WARN` is a valid taint number.
+ // - `fmt` can be NULL, and NULL is passed.
unsafe {
$crate::bindings::warn_slowpath_fmt(
$crate::str::CStrExt::as_char_ptr($crate::c_str!(::core::file!())),
base-commit: 948440b3f429f84680db58b4bf529b1ed2a20e15
--
2.43.0
More information about the linux-um
mailing list