FAILED: patch "[PATCH] rust: bug: pass TAINT_WARN to warn_slowpath_fmt() on UML" failed to apply to 6.18-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 6.18-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.18.y
git checkout FETCH_HEAD
git cherry-pick -x 951d09ca450ca76a695016ea76c3fa653bd20439
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026110447-anything-wildcard-f4e0@gregkh' --subject-prefix 'PATCH 6.18.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 951d09ca450ca76a695016ea76c3fa653bd20439 Mon Sep 17 00:00:00 2001
From: FUJITA Tomonori <[email protected]>
Date: Thu, 1 Oct 2026 21:31:03 +0900
Subject: [PATCH] rust: bug: pass TAINT_WARN to warn_slowpath_fmt() on UML
On UML, warn_flags! calls warn_slowpath_fmt() directly. Its third argument is a taint number, but warn_on! passes its bug flags there.
As a result, add_taint() gets 2304 instead of 9 (TAINT_WARN). The warning is not recorded: /proc/sys/kernel/tainted stays 0 after warn_on! fires, where it should be 512. It also causes an out-of-bounds write in add_taint().
Pass TAINT_WARN directly, as C does on UML.
rust/kernel/bug.rs +2 -1
@@ -85,6 +85,7 @@ macro_rules! warn_flags { ($file:expr, $flags:expr) => {if false { _ = $file; + _ = $flags; }// SAFETY: It is always safe to call `warn_slowpath_fmt()`
@@ -93,7 +94,7 @@ macro_rules! warn_flags { $crate::bindings::warn_slowpath_fmt ( $crate::str::CStrExt ::as_char_ptr ($crate::c_str!(::core::file!())),line! ()as $crate::ffi::c_int , - $flagsas $crate::ffi::c_uint , + $crate::bindings::TAINT_WARN , ::core::ptr::null (), ); }
Sasha Levin
maintainerPATCH 1/1 rust: bug: pass TAINT_WARN to warn_slowpath_fmt() on UML
From: FUJITA Tomonori <[email protected]>
[ Upstream commit 951d09ca450ca76a695016ea76c3fa653bd20439 ]
On UML, warn_flags! calls warn_slowpath_fmt() directly. Its third argument is a taint number, but warn_on! passes its bug flags there.
As a result, add_taint() gets 2304 instead of 9 (TAINT_WARN). The warning is not recorded: /proc/sys/kernel/tainted stays 0 after warn_on! fires, where it should be 512. It also causes an out-of-bounds write in add_taint().
Pass TAINT_WARN directly, as C does on UML.
--- rust/kernel/bug.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
rust/kernel/bug.rs +6 -2
@@ -79,13 +79,17 @@ macro_rules! warn_flags {#[cfg(all( CONFIG_BUG , CONFIG_UML ))] macro_rules! warn_flags { ($flags:expr) => { +if false { + _ = $flags; + } +// SAFETY: It is always safe to call `warn_slowpath_fmt()` // with a valid null-terminated string. unsafe { $crate::bindings::warn_slowpath_fmt ( - $crate::str ::CStrExt ::as_char_ptr ($crate::c_str!(::core::file!())), + $crate::str ::CStr ::as_char_ptr ($crate::c_str!(::core::file!())),line! ()as $crate::ffi::c_int , - $flagsas $crate::ffi::c_uint , + $crate::bindings::TAINT_WARN , ::core::ptr::null (), ); }
Signature · 1 line
2.53.0
Re: [PATCH 6.18.y] rust: bug: pass TAINT_WARN to warn_slowpath_fmt() on UML
rust/kernel/bug.rs macro_rules! warn_flags { · line 90
Quoted 5 lines · Sasha Levin
[ sashal: adapted warning handling to the single-argument
warn_flags! macro and existing CStr API ]rust/kernel/bug.rs +1
-1- $crate::str::CStrExt::as_char_ptr($crate::c_str!(::core::file!())), + $crate::str::CStr::as_char_ptr($crate::c_str!(::core::file!())),
So this one looks OK to solve:
https://lore.kernel.org/stable/[email protected]/
In the queue I see the commit with CStrExt I mentioned was already dropped due to an earlier report of mine about CStrExt in older kernels (and I guess you decided to send this one fixing both because of that (?)), but I don't see it picked for -rc2 yet, right?
If this is picked in -rc2, then I think it should be fine -- I checked it solves the build error indeed.
Thanks!
Cheers,
Miguel
Miguel Ojeda
maintainerPATCH 1/2 rust: bug: pass TAINT_WARN to warn_slowpath_fmt() on UML
In reply to [email protected]From: FUJITA Tomonori <[email protected]>
commit 951d09ca450ca76a695016ea76c3fa653bd20439 upstream.
On UML, warn_flags! calls warn_slowpath_fmt() directly. Its third argument is a taint number, but warn_on! passes its bug flags there.
As a result, add_taint() gets 2304 instead of 9 (TAINT_WARN). The warning is not recorded: /proc/sys/kernel/tainted stays 0 after warn_on! fires, where it should be 512. It also causes an out-of-bounds write in add_taint().
Pass TAINT_WARN directly, as C does on UML.
--- rust/kernel/bug.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
rust/kernel/bug.rs +5 -1
@@ -79,13 +79,17 @@ macro_rules! warn_flags {#[cfg(all( CONFIG_BUG , CONFIG_UML ))] macro_rules! warn_flags { ($flags:expr) => { +if false { + _ = $flags; + } +// SAFETY: It is always safe to call `warn_slowpath_fmt()` // with a valid null-terminated string. unsafe { $crate::bindings::warn_slowpath_fmt ( $crate::c_str!(::core::file!()).as_char_ptr (),line! ()as $crate::ffi::c_int , - $flagsas $crate::ffi::c_uint , + $crate::bindings::TAINT_WARN , ::core::ptr::null (), ); }
Signature · 1 line
2.56.0
Miguel Ojeda
maintainerPATCH 2/2 rust: bug: update the SAFETY comment for warn_slowpath_fmt() on UML
From: FUJITA Tomonori <[email protected]>
commit 5c94956f2bfb87025c1eaded6c51d5841d38d333 upstream.
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.
--- rust/kernel/bug.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
rust/kernel/bug.rs +4 -2
@@ -83,8 +83,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::c_str!(::core::file!()).as_char_ptr(),
Signature · 1 line
2.56.0