linux-um archives
 help / color / mirror / Atom feed
* [PATCH v1] rust: bug: update the SAFETY comment for warn_slowpath_fmt() on UML
@ 2026-10-02 10:45 FUJITA Tomonori
  2026-10-02 10:54 ` Miguel Ojeda
  2026-10-12 15:35 ` Miguel Ojeda
  0 siblings, 2 replies; 4+ messages in thread
From: FUJITA Tomonori @ 2026-10-02 10:45 UTC (permalink / raw)
  To: ojeda
  Cc: a.hindborg, acourbot, aliceryhl, anton.ivanov, bjorn3_gh, boqun,
	dakr, daniel.almeida, david, gary, johannes, linux-um, lossin,
	richard, tamird, tmgross, work, rust-for-linux, FUJITA Tomonori

From: FUJITA Tomonori <fujita.tomonori@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@kernel.org>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@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



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-10-12 15:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-02 10:45 [PATCH v1] rust: bug: update the SAFETY comment for warn_slowpath_fmt() on UML FUJITA Tomonori
2026-10-02 10:54 ` Miguel Ojeda
2026-10-03 13:33   ` FUJITA Tomonori
2026-10-12 15:35 ` Miguel Ojeda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox