From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: FUJITA Tomonori <fujita.tomonori@gmail.com>,
Miguel Ojeda <ojeda@kernel.org>, Sasha Levin <sashal@kernel.org>
Subject: [PATCH 6.18.y] rust: bug: pass TAINT_WARN to warn_slowpath_fmt() on UML
Date: Wed, 4 Nov 2026 15:18:01 -0500 [thread overview]
Message-ID: <20261104201749.344995-1-sashal@kernel.org> (raw)
In-Reply-To: <2026110447-anything-wildcard-f4e0@gregkh>
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
next prev parent reply other threads:[~2026-11-04 20:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2026-11-06 8:23 ` [PATCH 6.18.y] rust: bug: pass TAINT_WARN to warn_slowpath_fmt() on UML 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261104201749.344995-1-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=fujita.tomonori@gmail.com \
--cc=ojeda@kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox