Skip to content

Commit f2435d7

Browse files
Darksonnisaacmanjarres
authored andcommitted
FROMLIST: rust: kasan: add support for Software Tag-Based KASAN
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. Link: rust-lang/rust#153049 [1] Reviewed-by: Danilo Krummrich <dakr@kernel.org> Link: https://lore.kernel.org/r/20260331-kasan-rust-sw-tags-v2-1-f6765e3e1a2f@google.com Bug: 493254381 Change-Id: Icbe302adf0b8358668760a621570eeba76e10019 Signed-off-by: Alice Ryhl <aliceryhl@google.com>
1 parent e2fdf65 commit f2435d7

2 files changed

Lines changed: 1 addition & 3 deletions

File tree

init/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2024,7 +2024,7 @@ config RUST
20242024
depends on !CFI_CLANG || HAVE_CFI_ICALL_NORMALIZE_INTEGERS_RUSTC
20252025
select CFI_ICALL_NORMALIZE_INTEGERS if CFI_CLANG
20262026
depends on !CALL_PADDING || RUSTC_VERSION >= 108100
2027-
depends on !KASAN_SW_TAGS
2027+
depends on !KASAN_SW_TAGS || RUSTC_VERSION >= 109600
20282028
# ANDROID: This version number has been changed due to backports in Android's compiler.
20292029
depends on !(MITIGATION_RETHUNK && KASAN) || RUSTC_VERSION >= 108200
20302030
help

scripts/Makefile.kasan

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ ifdef CONFIG_KASAN_SW_TAGS
7171

7272
CFLAGS_KASAN := -fsanitize=kernel-hwaddress
7373

74-
# This sets flags that will enable SW_TAGS KASAN once enabled in Rust. These
75-
# will not work today, and is guarded against in dependencies for CONFIG_RUST.
7674
RUSTFLAGS_KASAN := -Zsanitizer=kernel-hwaddress \
7775
-Zsanitizer-recover=kernel-hwaddress
7876

0 commit comments

Comments
 (0)