Rust for Linux List
 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
  0 siblings, 1 reply; 3+ 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] 3+ messages in thread

* Re: [PATCH v1] rust: bug: update the SAFETY comment for warn_slowpath_fmt() on UML
  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
  0 siblings, 1 reply; 3+ messages in thread
From: Miguel Ojeda @ 2026-10-02 10:54 UTC (permalink / raw)
  To: FUJITA Tomonori
  Cc: ojeda, 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

On Fri, Oct 2, 2026 at 12:46 PM FUJITA Tomonori <tomo@flapping.org> wrote:
>
> 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>

Thanks Tomo!

(By the way, you have been authoring all the work in this file -- we
could have an entry for the file in `MAINTAINERS` if you want it)

Cheers,
Miguel

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

* Re: [PATCH v1] rust: bug: update the SAFETY comment for warn_slowpath_fmt() on UML
  2026-10-02 10:54 ` Miguel Ojeda
@ 2026-10-03 13:33   ` FUJITA Tomonori
  0 siblings, 0 replies; 3+ messages in thread
From: FUJITA Tomonori @ 2026-10-03 13:33 UTC (permalink / raw)
  To: miguel.ojeda.sandonis
  Cc: tomo, ojeda, 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

On Fri, 2 Oct 2026 12:54:47 +0200
Miguel Ojeda <miguel.ojeda.sandonis@gmail.com> wrote:

> (By the way, you have been authoring all the work in this file -- we
> could have an entry for the file in `MAINTAINERS` if you want it)

Thanks, let's add one. It would make sure that I am Cc'd on changes to
the file. I'll send a patch to update MAINTAINERS.

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

end of thread, other threads:[~2026-10-03 13:33 UTC | newest]

Thread overview: 3+ 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

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