Alice Ryhl
unread,Apr 8, 2026, 4:32:31 AM (2 days ago) Apr 8Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Andrey Ryabinin, Alexander Potapenko, Andrey Konovalov, Dmitry Vyukov, Vincenzo Frascino, Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt, Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg, Trevor Gross, Danilo Krummrich, linux-...@vger.kernel.org, kasa...@googlegroups.com, rust-fo...@vger.kernel.org, ll...@lists.linux.dev, Alice Ryhl
This adds support for Software Tag-Based KASAN (KASAN_SW_TAGS) when
CONFIG_RUST is enabled. This requires that rustc includes support for
the kernel-hwaddress sanitizer, which is available since 1.96.0 [1].
Unlike with clang, we need to pass -Zsanitizer-recover in addition to
-Zsanitizer because the option is not implied automatically.
The kasan makefile uses different names for the flags depending on
whether CC is clang or gcc, but as we require that CC is clang when
using KASAN, we do not need to try to handle mixed gcc/llvm builds when
Rust is enabled.
Link:
https://github.com/rust-lang/rust/pull/153049 [1]
Reviewed-by: Danilo Krummrich <
da...@kernel.org>
init/Kconfig | 2 +-
scripts/Makefile.kasan | 2 --
2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/init/Kconfig b/init/Kconfig
index 1d41c7c5e986..d2edb1dbd2f2 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -2180,7 +2180,7 @@ config RUST
select CFI_ICALL_NORMALIZE_INTEGERS if CFI
depends on !CALL_PADDING || RUSTC_VERSION >= 108100
depends on !KASAN || CC_IS_CLANG
- depends on !KASAN_SW_TAGS
+ depends on !KASAN_SW_TAGS || RUSTC_VERSION >= 109600
depends on !(MITIGATION_RETHUNK && KASAN) || RUSTC_VERSION >= 108300
help
Enables Rust support in the kernel.
diff --git a/scripts/Makefile.kasan b/scripts/Makefile.kasan
index 0ba2aac3b8dc..91504e81247a 100644
--- a/scripts/Makefile.kasan
+++ b/scripts/Makefile.kasan
@@ -71,8 +71,6 @@ ifdef CONFIG_KASAN_SW_TAGS
CFLAGS_KASAN := -fsanitize=kernel-hwaddress
-# This sets flags that will enable SW_TAGS KASAN once enabled in Rust. These
-# will not work today, and is guarded against in dependencies for CONFIG_RUST.
RUSTFLAGS_KASAN := -Zsanitizer=kernel-hwaddress \
-Zsanitizer-recover=kernel-hwaddress
--
2.53.0.1213.gd9a14994de-goog