History

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

Alice Ryhl committed 7 months ago

Commit 72d33b81 parent 5b271542 files · +1 −3Browse files

Unified · Split

2 files
  1. init/Kconfig +1 −1
  2. scripts/Makefile.kasan +0 −2
init/Kconfig+1−1
@@ -2199,7 +2199,7 @@ config RUST · 2198 unmodified lines
2199 depends on !CFI || HAVE_CFI_ICALL_NORMALIZE_INTEGERS_RUSTC2199 depends on !CFI || HAVE_CFI_ICALL_NORMALIZE_INTEGERS_RUSTC
2200 select CFI_ICALL_NORMALIZE_INTEGERS if CFI2200 select CFI_ICALL_NORMALIZE_INTEGERS if CFI
2201 depends on !KASAN || CC_IS_CLANG2201 depends on !KASAN || CC_IS_CLANG
2202 depends on !KASAN_SW_TAGS2202 depends on !KASAN_SW_TAGS || RUSTC_VERSION >= 109600
2203 help2203 help
2204 Enables Rust support in the kernel.2204 Enables Rust support in the kernel.
2205 2205
scripts/Makefile.kasan+0−2
@@ -71,8 +71,6 @@ ifdef CONFIG_KASAN_SW_TAGS · 70 unmodified lines
71 71
72CFLAGS_KASAN := -fsanitize=kernel-hwaddress72CFLAGS_KASAN := -fsanitize=kernel-hwaddress
73 73
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.
76RUSTFLAGS_KASAN := -Zsanitizer=kernel-hwaddress \74RUSTFLAGS_KASAN := -Zsanitizer=kernel-hwaddress \
77 -Zsanitizer-recover=kernel-hwaddress75 -Zsanitizer-recover=kernel-hwaddress
78 76

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t