[PATCH v1] rust: bug: pass TAINT_WARN to warn_slowpath_fmt() on UML

David Gow david at davidgow.net
Sat Oct 3 05:19:51 PDT 2026


Le 01/10/2026 à 20:31, FUJITA Tomonori a écrit :
> From: FUJITA Tomonori <fujita.tomonori at gmail.com>
> 
> 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 at vger.kernel.org
> Fixes: dff64b072708 ("rust: Add warn_on macro")
> Signed-off-by: FUJITA Tomonori <fujita.tomonori at gmail.com>
> ---

Nice catch!

Reviewed-by: David Gow <david at davidgow.net>

Cheers,
-- David

>   rust/kernel/bug.rs | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> 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(),
>               );
>           }
> 
> base-commit: 551c722f40809618230001baccf219193e22fc5a




More information about the linux-um mailing list