Skip to content

Commit 7aed6a2

Browse files
committed
kasan: Disable Software Tag-Based KASAN with GCC
Syzbot reports a KASAN failure early during boot on arm64 when building with GCC 12.2.0 and using the Software Tag-Based KASAN mode: | BUG: KASAN: invalid-access in smp_build_mpidr_hash arch/arm64/kernel/setup.c:133 [inline] | BUG: KASAN: invalid-access in setup_arch+0x984/0xd60 arch/arm64/kernel/setup.c:356 | Write of size 4 at addr 03ff800086867e00 by task swapper/0 | Pointer tag: [03], memory tag: [fe] Initial triage indicates that the report is a false positive and a thorough investigation of the crash by Mark Rutland revealed the root cause to be a bug in GCC: > When GCC is passed `-fsanitize=hwaddress` or > `-fsanitize=kernel-hwaddress` it ignores > `__attribute__((no_sanitize_address))`, and instruments functions > we require are not instrumented. > > [...] > > All versions [of GCC] I tried were broken, from 11.3.0 to 14.2.0 > inclusive. > > I think we have to disable KASAN_SW_TAGS with GCC until this is > fixed Disable Software Tag-Based KASAN when building with GCC by making CC_HAS_KASAN_SW_TAGS depend on !CC_IS_GCC. Cc: Andrey Konovalov <andreyknvl@gmail.com> Suggested-by: Mark Rutland <mark.rutland@arm.com> Reported-by: syzbot+908886656a02769af987@syzkaller.appspotmail.com Link: https://lore.kernel.org/r/000000000000f362e80620e27859@google.com Link: https://lore.kernel.org/r/ZvFGwKfoC4yVjN_X@J2N7QTR9R3 Link: https://bugzilla.kernel.org/show_bug.cgi?id=218854 Reviewed-by: Andrey Konovalov <andreyknvl@gmail.com> Acked-by: Mark Rutland <mark.rutland@arm.com> Link: https://lore.kernel.org/r/20241014161100.18034-1-will@kernel.org Signed-off-by: Will Deacon <will@kernel.org>
1 parent f56d8d2 commit 7aed6a2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/Kconfig.kasan

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ config ARCH_DISABLE_KASAN_INLINE
2222
config CC_HAS_KASAN_GENERIC
2323
def_bool $(cc-option, -fsanitize=kernel-address)
2424

25+
# GCC appears to ignore no_sanitize_address when -fsanitize=kernel-hwaddress
26+
# is passed. See https://bugzilla.kernel.org/show_bug.cgi?id=218854 (and
27+
# the linked LKML thread) for more details.
2528
config CC_HAS_KASAN_SW_TAGS
26-
def_bool $(cc-option, -fsanitize=kernel-hwaddress)
29+
def_bool !CC_IS_GCC && $(cc-option, -fsanitize=kernel-hwaddress)
2730

2831
# This option is only required for software KASAN modes.
2932
# Old GCC versions do not have proper support for no_sanitize_address.
@@ -98,7 +101,7 @@ config KASAN_SW_TAGS
98101
help
99102
Enables Software Tag-Based KASAN.
100103

101-
Requires GCC 11+ or Clang.
104+
Requires Clang.
102105

103106
Supported only on arm64 CPUs and relies on Top Byte Ignore.
104107

0 commit comments

Comments
 (0)