Linux kernel -stable discussions
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] rust: bug: pass TAINT_WARN to warn_slowpath_fmt() on UML" failed to apply to 6.18-stable tree
@ 2026-11-04 14:12 gregkh
  2026-11-04 20:18 ` [PATCH 6.18.y] rust: bug: pass TAINT_WARN to warn_slowpath_fmt() on UML Sasha Levin
  2026-11-08  4:33 ` [PATCH 6.18.y 1/2] " Miguel Ojeda
  0 siblings, 2 replies; 5+ messages in thread
From: gregkh @ 2026-11-04 14:12 UTC (permalink / raw)
  To: fujita.tomonori, ojeda; +Cc: stable


The 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 <stable@vger.kernel.org>.

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 '<stable@vger.kernel.org>' --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 <fujita.tomonori@gmail.com>
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.

Cc: stable@vger.kernel.org
Fixes: dff64b072708 ("rust: Add warn_on macro")
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Link: https://patch.msgid.link/20261001123103.2198104-1-tomo@flapping.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

diff --git a/rust/kernel/bug.rs b/rust/kernel/bug.rs
index 3566f0234ca4..af8eba4563de 100644
--- a/rust/kernel/bug.rs
+++ b/rust/kernel/bug.rs
@@ -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,
-                $flags as $crate::ffi::c_uint,
+                $crate::bindings::TAINT_WARN,
                 ::core::ptr::null(),
             );
         }


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

* [PATCH 6.18.y] rust: bug: pass TAINT_WARN to warn_slowpath_fmt() on UML
  2026-11-04 14:12 FAILED: patch "[PATCH] rust: bug: pass TAINT_WARN to warn_slowpath_fmt() on UML" failed to apply to 6.18-stable tree gregkh
@ 2026-11-04 20:18 ` Sasha Levin
  2026-11-06  8:23   ` Miguel Ojeda
  2026-11-08  4:33 ` [PATCH 6.18.y 1/2] " Miguel Ojeda
  1 sibling, 1 reply; 5+ messages in thread
From: Sasha Levin @ 2026-11-04 20:18 UTC (permalink / raw)
  To: stable; +Cc: FUJITA Tomonori, Miguel Ojeda, Sasha Levin

From: FUJITA Tomonori <fujita.tomonori@gmail.com>

[ 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.

Cc: stable@vger.kernel.org
Fixes: dff64b072708 ("rust: Add warn_on macro")
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Link: https://patch.msgid.link/20261001123103.2198104-1-tomo@flapping.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
[ sashal: adapted warning handling to the single-argument warn_flags! macro and existing CStr API ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 rust/kernel/bug.rs | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/rust/kernel/bug.rs b/rust/kernel/bug.rs
index 15a84e553fd4d..7e540954d67a0 100644
--- a/rust/kernel/bug.rs
+++ b/rust/kernel/bug.rs
@@ -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,
-                $flags as $crate::ffi::c_uint,
+                $crate::bindings::TAINT_WARN,
                 ::core::ptr::null(),
             );
         }
-- 
2.53.0


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

* Re: [PATCH 6.18.y] rust: bug: pass TAINT_WARN to warn_slowpath_fmt() on UML
  2026-11-04 20:18 ` [PATCH 6.18.y] rust: bug: pass TAINT_WARN to warn_slowpath_fmt() on UML Sasha Levin
@ 2026-11-06  8:23   ` Miguel Ojeda
  0 siblings, 0 replies; 5+ messages in thread
From: Miguel Ojeda @ 2026-11-06  8:23 UTC (permalink / raw)
  To: Sasha Levin; +Cc: stable, FUJITA Tomonori, Miguel Ojeda

On Wed, Nov 4, 2026 at 9:18 PM Sasha Levin <sashal@kernel.org> wrote:
>
> [ sashal: adapted warning handling to the single-argument warn_flags! macro and existing CStr API ]

> -                $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/20261106070543.89122-1-ojeda@kernel.org/

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

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

* [PATCH 6.18.y 1/2] rust: bug: pass TAINT_WARN to warn_slowpath_fmt() on UML
  2026-11-04 14:12 FAILED: patch "[PATCH] rust: bug: pass TAINT_WARN to warn_slowpath_fmt() on UML" failed to apply to 6.18-stable tree gregkh
  2026-11-04 20:18 ` [PATCH 6.18.y] rust: bug: pass TAINT_WARN to warn_slowpath_fmt() on UML Sasha Levin
@ 2026-11-08  4:33 ` Miguel Ojeda
  2026-11-08  4:33   ` [PATCH 6.18.y 2/2] rust: bug: update the SAFETY comment for " Miguel Ojeda
  1 sibling, 1 reply; 5+ messages in thread
From: Miguel Ojeda @ 2026-11-08  4:33 UTC (permalink / raw)
  To: stable, sashal; +Cc: ojeda, FUJITA Tomonori

From: FUJITA Tomonori <fujita.tomonori@gmail.com>

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.

Cc: stable@vger.kernel.org
Fixes: dff64b072708 ("rust: Add warn_on macro")
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Link: https://patch.msgid.link/20261001123103.2198104-1-tomo@flapping.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
[ Adapted to the single-argument `warn_flags!` macro. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
---
 rust/kernel/bug.rs | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/rust/kernel/bug.rs b/rust/kernel/bug.rs
index 53dbdaec3560..364d90c6404c 100644
--- a/rust/kernel/bug.rs
+++ b/rust/kernel/bug.rs
@@ -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,
-                $flags as $crate::ffi::c_uint,
+                $crate::bindings::TAINT_WARN,
                 ::core::ptr::null(),
             );
         }
-- 
2.56.0


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

* [PATCH 6.18.y 2/2] rust: bug: update the SAFETY comment for warn_slowpath_fmt() on UML
  2026-11-08  4:33 ` [PATCH 6.18.y 1/2] " Miguel Ojeda
@ 2026-11-08  4:33   ` Miguel Ojeda
  0 siblings, 0 replies; 5+ messages in thread
From: Miguel Ojeda @ 2026-11-08  4:33 UTC (permalink / raw)
  To: stable, sashal; +Cc: ojeda, FUJITA Tomonori

From: FUJITA Tomonori <fujita.tomonori@gmail.com>

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`.

Suggested-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Link: https://patch.msgid.link/20261002104550.2877930-1-tomo@flapping.org
Cc: stable@vger.kernel.org
Fixes: dff64b072708 ("rust: Add warn_on macro")
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
---
 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 364d90c6404c..95bfd195c986 100644
--- a/rust/kernel/bug.rs
+++ b/rust/kernel/bug.rs
@@ -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(),
-- 
2.56.0


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

end of thread, other threads:[~2026-11-08  4:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-04 14:12 FAILED: patch "[PATCH] rust: bug: pass TAINT_WARN to warn_slowpath_fmt() on UML" failed to apply to 6.18-stable tree gregkh
2026-11-04 20:18 ` [PATCH 6.18.y] rust: bug: pass TAINT_WARN to warn_slowpath_fmt() on UML Sasha Levin
2026-11-06  8:23   ` Miguel Ojeda
2026-11-08  4:33 ` [PATCH 6.18.y 1/2] " Miguel Ojeda
2026-11-08  4:33   ` [PATCH 6.18.y 2/2] rust: bug: update the SAFETY comment for " Miguel Ojeda

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