Skip to content

Commit dd03762

Browse files
Kefeng Wangctmarinas
authored andcommitted
arm64: Enable KCSAN
This patch enables KCSAN for arm64, with updates to build rules to not use KCSAN for several incompatible compilation units. Recent GCC version(at least GCC10) made outline-atomics as the default option(unlike Clang), which will cause linker errors for kernel/kcsan/core.o. Disables the out-of-line atomics by no-outline-atomics to fix the linker errors. Meanwhile, as Mark said[1], some latent issues are needed to be fixed which isn't just a KCSAN problem, we make the KCSAN depends on EXPERT for now. Tested selftest and kcsan_test(built with GCC11 and Clang 13), and all passed. [1] https://lkml.kernel.org/r/YadiUPpJ0gADbiHQ@FVFF77S0Q05N Acked-by: Marco Elver <[email protected]> # kernel/kcsan Tested-by: Joey Gouly <[email protected]> Signed-off-by: Kefeng Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] [[email protected]: added comment to justify EXPERT] Signed-off-by: Catalin Marinas <[email protected]>
1 parent d58071a commit dd03762

File tree

4 files changed

+5
-0
lines changed

4 files changed

+5
-0
lines changed

arch/arm64/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ config ARM64
150150
select HAVE_ARCH_KASAN_VMALLOC if HAVE_ARCH_KASAN
151151
select HAVE_ARCH_KASAN_SW_TAGS if HAVE_ARCH_KASAN
152152
select HAVE_ARCH_KASAN_HW_TAGS if (HAVE_ARCH_KASAN && ARM64_MTE)
153+
# Some instrumentation may be unsound, hence EXPERT
154+
select HAVE_ARCH_KCSAN if EXPERT
153155
select HAVE_ARCH_KFENCE
154156
select HAVE_ARCH_KGDB
155157
select HAVE_ARCH_MMAP_RND_BITS

arch/arm64/kernel/vdso/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ ccflags-y += -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO
3232
CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) -Os $(CC_FLAGS_SCS) $(GCC_PLUGINS_CFLAGS) \
3333
$(CC_FLAGS_LTO)
3434
KASAN_SANITIZE := n
35+
KCSAN_SANITIZE := n
3536
UBSAN_SANITIZE := n
3637
OBJECT_FILES_NON_STANDARD := y
3738
KCOV_INSTRUMENT := n

arch/arm64/kvm/hyp/nvhe/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS) $(CC_FLAGS_CFI)
8989
# cause crashes. Just disable it.
9090
GCOV_PROFILE := n
9191
KASAN_SANITIZE := n
92+
KCSAN_SANITIZE := n
9293
UBSAN_SANITIZE := n
9394
KCOV_INSTRUMENT := n
9495

kernel/kcsan/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ CFLAGS_REMOVE_debugfs.o = $(CC_FLAGS_FTRACE)
88
CFLAGS_REMOVE_report.o = $(CC_FLAGS_FTRACE)
99

1010
CFLAGS_core.o := $(call cc-option,-fno-conserve-stack) \
11+
$(call cc-option,-mno-outline-atomics) \
1112
-fno-stack-protector -DDISABLE_BRANCH_PROFILING
1213

1314
obj-y := core.o debugfs.o report.o

0 commit comments

Comments
 (0)