kasan: add option to disable read/write checks

Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
This commit is contained in:
Xu Xingliang 2023-08-31 18:11:39 +08:00 committed by Xiang Xiao
parent cb105192c7
commit a2df576ecf
5 changed files with 49 additions and 0 deletions

View File

@ -78,6 +78,14 @@ ifeq ($(CONFIG_MM_KASAN_ALL),y)
ARCHOPTIMIZATION += -fsanitize=kernel-address ARCHOPTIMIZATION += -fsanitize=kernel-address
endif endif
ifeq ($(CONFIG_MM_KASAN_DISABLE_READS_CHECK),y)
ARCHOPTIMIZATION += --param asan-instrument-reads=0
endif
ifeq ($(CONFIG_MM_KASAN_DISABLE_WRITES_CHECK),y)
ARCHOPTIMIZATION += --param asan-instrument-writes=0
endif
ifeq ($(CONFIG_UNWINDER_ARM),y) ifeq ($(CONFIG_UNWINDER_ARM),y)
ARCHOPTIMIZATION += -funwind-tables -fasynchronous-unwind-tables ARCHOPTIMIZATION += -funwind-tables -fasynchronous-unwind-tables
endif endif

View File

@ -230,6 +230,14 @@ ifeq ($(CONFIG_MM_KASAN_ALL),y)
ARCHOPTIMIZATION += -fsanitize=kernel-address ARCHOPTIMIZATION += -fsanitize=kernel-address
endif endif
ifeq ($(CONFIG_MM_KASAN_DISABLE_READS_CHECK),y)
ARCHOPTIMIZATION += --param asan-instrument-reads=0
endif
ifeq ($(CONFIG_MM_KASAN_DISABLE_WRITES_CHECK),y)
ARCHOPTIMIZATION += --param asan-instrument-writes=0
endif
ifeq ($(CONFIG_MM_UBSAN_ALL),y) ifeq ($(CONFIG_MM_UBSAN_ALL),y)
ARCHOPTIMIZATION += $(CONFIG_MM_UBSAN_OPTION) ARCHOPTIMIZATION += $(CONFIG_MM_UBSAN_OPTION)
endif endif

View File

@ -47,6 +47,14 @@ ifeq ($(CONFIG_MM_KASAN_ALL),y)
ARCHOPTIMIZATION += -fsanitize=kernel-address ARCHOPTIMIZATION += -fsanitize=kernel-address
endif endif
ifeq ($(CONFIG_MM_KASAN_DISABLE_READS_CHECK),y)
ARCHOPTIMIZATION += --param asan-instrument-reads=0
endif
ifeq ($(CONFIG_MM_KASAN_DISABLE_WRITES_CHECK),y)
ARCHOPTIMIZATION += --param asan-instrument-writes=0
endif
ifeq ($(CONFIG_MM_UBSAN_ALL),y) ifeq ($(CONFIG_MM_UBSAN_ALL),y)
ARCHOPTIMIZATION += $(CONFIG_MM_UBSAN_OPTION) ARCHOPTIMIZATION += $(CONFIG_MM_UBSAN_OPTION)
endif endif

View File

@ -47,6 +47,14 @@ ifeq ($(CONFIG_MM_KASAN_ALL),y)
ARCHOPTIMIZATION += -fsanitize=kernel-address ARCHOPTIMIZATION += -fsanitize=kernel-address
endif endif
ifeq ($(CONFIG_MM_KASAN_DISABLE_READS_CHECK),y)
ARCHOPTIMIZATION += --param asan-instrument-reads=0
endif
ifeq ($(CONFIG_MM_KASAN_DISABLE_WRITES_CHECK),y)
ARCHOPTIMIZATION += --param asan-instrument-writes=0
endif
ifeq ($(CONFIG_MM_UBSAN_ALL),y) ifeq ($(CONFIG_MM_UBSAN_ALL),y)
ARCHOPTIMIZATION += $(CONFIG_MM_UBSAN_OPTION) ARCHOPTIMIZATION += $(CONFIG_MM_UBSAN_OPTION)
endif endif

View File

@ -265,6 +265,23 @@ config MM_KASAN_ALL
to check. Enabling this option will get image size increased to check. Enabling this option will get image size increased
and performance decreased significantly. and performance decreased significantly.
config MM_KASAN_DISABLE_READS_CHECK
bool "Disable reads check"
depends on MM_KASAN
default n
---help---
This option disable kasan reads check. It speeds up performance
compared with default read/write check. Only disable it when you are
sure there's no need to do so. Or performance is too bad and only focus
on writes check.
config MM_KASAN_DISABLE_WRITES_CHECK
bool "Disable writes check"
depends on MM_KASAN
default n
---help---
This option disable kasan writes check.
config MM_UBSAN config MM_UBSAN
bool "Undefined Behavior Sanitizer" bool "Undefined Behavior Sanitizer"
default n default n