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.
Showing the changes to scripts (1 of 2 files). Show all
Unified · Split
| @@ -71,8 +71,6 @@ ifdef CONFIG_KASAN_SW_TAGS · 70 unmodified lines | |||
| 71 | 71 | ||
| 72 | CFLAGS_KASAN := -fsanitize=kernel-hwaddress | 72 | CFLAGS_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. | ||
| 76 | RUSTFLAGS_KASAN := -Zsanitizer=kernel-hwaddress \ | 74 | RUSTFLAGS_KASAN := -Zsanitizer=kernel-hwaddress \ |
| 77 | -Zsanitizer-recover=kernel-hwaddress | 75 | -Zsanitizer-recover=kernel-hwaddress |
| 78 | 76 | ||