mm/kasan: Add MM_KASAN_ALL option

so the user could disable the full image instrumentation,
but enable the instrumentation by files or directories.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2022-08-20 06:28:39 +08:00 committed by Petro Karashchenko
parent f3f1dde39b
commit f1355680ca
12 changed files with 22 additions and 11 deletions

View File

@ -79,7 +79,7 @@ ifeq ($(CONFIG_ARCH_COVERAGE),y)
ARCHOPTIMIZATION += -fprofile-generate -ftest-coverage ARCHOPTIMIZATION += -fprofile-generate -ftest-coverage
endif endif
ifeq ($(CONFIG_MM_KASAN),y) ifeq ($(CONFIG_MM_KASAN_ALL),y)
ARCHOPTIMIZATION += -fsanitize=kernel-address ARCHOPTIMIZATION += -fsanitize=kernel-address
endif endif

View File

@ -165,7 +165,7 @@ endif
# Architecture flags # Architecture flags
ifeq ($(CONFIG_MM_KASAN),y) ifeq ($(CONFIG_MM_KASAN_ALL),y)
ARCHOPTIMIZATION += -fsanitize=kernel-address ARCHOPTIMIZATION += -fsanitize=kernel-address
endif endif

View File

@ -96,7 +96,7 @@ else
ARCHCPUFLAGS += -mfloat-abi=soft ARCHCPUFLAGS += -mfloat-abi=soft
endif endif
ifeq ($(CONFIG_MM_KASAN),y) ifeq ($(CONFIG_MM_KASAN_ALL),y)
ARCHOPTIMIZATION += -fsanitize=kernel-address ARCHOPTIMIZATION += -fsanitize=kernel-address
endif endif

View File

@ -179,7 +179,7 @@ else
endif endif
endif endif
ifeq ($(CONFIG_MM_KASAN),y) ifeq ($(CONFIG_MM_KASAN_ALL),y)
ARCHOPTIMIZATION += -fsanitize=kernel-address ARCHOPTIMIZATION += -fsanitize=kernel-address
endif endif

View File

@ -96,7 +96,7 @@ ifeq ($(CONFIG_ENDIAN_BIG),y)
ARCHCPUFLAGS += -mbig-endian ARCHCPUFLAGS += -mbig-endian
endif endif
ifeq ($(CONFIG_MM_KASAN),y) ifeq ($(CONFIG_MM_KASAN_ALL),y)
ARCHOPTIMIZATION += -fsanitize=kernel-address ARCHOPTIMIZATION += -fsanitize=kernel-address
endif endif

View File

@ -188,7 +188,7 @@ else
endif endif
endif endif
ifeq ($(CONFIG_MM_KASAN),y) ifeq ($(CONFIG_MM_KASAN_ALL),y)
ARCHOPTIMIZATION += -fsanitize=kernel-address ARCHOPTIMIZATION += -fsanitize=kernel-address
endif endif

View File

@ -140,7 +140,7 @@ endif
# Architecture flags # Architecture flags
ifeq ($(CONFIG_MM_KASAN),y) ifeq ($(CONFIG_MM_KASAN_ALL),y)
ARCHOPTIMIZATION += -fsanitize=kernel-address ARCHOPTIMIZATION += -fsanitize=kernel-address
endif endif

View File

@ -162,7 +162,7 @@ ifeq ($(CONFIG_RISCV_TOOLCHAIN),GNU_RVG)
endif endif
ifeq ($(CONFIG_MM_KASAN),y) ifeq ($(CONFIG_MM_KASAN_ALL),y)
ARCHOPTIMIZATION += -fsanitize=kernel-address ARCHOPTIMIZATION += -fsanitize=kernel-address
endif endif

View File

@ -43,7 +43,7 @@ endif
ARCHCPUFLAGS = -mlongcalls ARCHCPUFLAGS = -mlongcalls
ifeq ($(CONFIG_MM_KASAN),y) ifeq ($(CONFIG_MM_KASAN_ALL),y)
ARCHOPTIMIZATION += -fsanitize=kernel-address ARCHOPTIMIZATION += -fsanitize=kernel-address
endif endif

View File

@ -43,7 +43,7 @@ endif
ARCHCPUFLAGS = -mlongcalls ARCHCPUFLAGS = -mlongcalls
ifeq ($(CONFIG_MM_KASAN),y) ifeq ($(CONFIG_MM_KASAN_ALL),y)
ARCHOPTIMIZATION += -fsanitize=kernel-address ARCHOPTIMIZATION += -fsanitize=kernel-address
endif endif

View File

@ -73,7 +73,7 @@ endif
ifeq ($(CONFIG_SIM_ASAN),y) ifeq ($(CONFIG_SIM_ASAN),y)
ARCHOPTIMIZATION += -fsanitize=address ARCHOPTIMIZATION += -fsanitize=address
else ifeq ($(CONFIG_MM_KASAN),y) else ifeq ($(CONFIG_MM_KASAN_ALL),y)
ARCHOPTIMIZATION += -fsanitize=kernel-address ARCHOPTIMIZATION += -fsanitize=kernel-address
endif endif

View File

@ -191,6 +191,17 @@ config MM_KASAN
bugs in native code. After turn on this option, Please bugs in native code. After turn on this option, Please
add -fsanitize=kernel-address to CFLAGS/CXXFLAGS too. add -fsanitize=kernel-address to CFLAGS/CXXFLAGS too.
config MM_KASAN_ALL
bool "Enable KASan for the entire image"
depends on MM_KASAN
default y
---help---
This option activates address sanitizer for the entire image.
If you don't enable this option, you have to explicitly specify
"-fsanitize=kernel-address" for the files/directories you want
to check. Enabling this option will get image size increased
and performance decreased significantly.
config MM_UBSAN config MM_UBSAN
bool "Undefined Behavior Sanitizer" bool "Undefined Behavior Sanitizer"
default n default n