This can avoid crashes caused by uninitialized accesses to initialized variables in non-chip memory. Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
144 lines
3.7 KiB
Text
144 lines
3.7 KiB
Text
#
|
|
# For a description of the syntax of this configuration file,
|
|
# see the file kconfig-language.txt in the NuttX tools repository.
|
|
#
|
|
|
|
config MM_KASAN
|
|
bool "Kernel Address Sanitizer"
|
|
default n
|
|
---help---
|
|
KASan is a fast compiler-based tool for detecting memory
|
|
bugs in native code. After turn on this option, Please
|
|
add -fsanitize=kernel-address to CFLAGS/CXXFLAGS too.
|
|
|
|
config MM_KASAN_INSTRUMENT
|
|
bool
|
|
|
|
if MM_KASAN
|
|
|
|
choice
|
|
prompt "KAsan Mode"
|
|
default MM_KASAN_GENERIC
|
|
|
|
config MM_KASAN_NONE
|
|
bool "KAsan disable"
|
|
---help---
|
|
Disable KASan check
|
|
|
|
config MM_KASAN_GENERIC
|
|
bool "KAsan generic mode"
|
|
select MM_KASAN_INSTRUMENT
|
|
---help---
|
|
KASan generic mode that does not require hardware support at all
|
|
|
|
config MM_KASAN_SW_TAGS
|
|
bool "KAsan softtags tags"
|
|
select ARM64_TBI if ARCH_ARM64
|
|
select MM_KASAN_INSTRUMENT
|
|
---help---
|
|
KAsan based on software tags
|
|
|
|
config MM_KASAN_HW_TAGS
|
|
bool "KAsan hardware tags"
|
|
select ARM64_MTE if ARCH_ARM64
|
|
---help---
|
|
KAsan based on hardware tags
|
|
|
|
endchoice
|
|
|
|
config MM_KASAN_INSTRUMENT_ALL
|
|
bool "Enable KASan for the entire image"
|
|
depends on MM_KASAN_INSTRUMENT
|
|
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_KASAN_MARK_LOCATION
|
|
string "Kasan's mark storage location"
|
|
---help---
|
|
The section where KASan mark is located. It can prevent
|
|
variables located in non-chip memory, and crashes
|
|
caused by instrumentation access
|
|
|
|
if MM_KASAN_INSTRUMENT
|
|
|
|
config MM_KASAN_REGIONS
|
|
int "Kasan region count"
|
|
default 8
|
|
|
|
config MM_KASAN_WATCHPOINT
|
|
int "Kasan watchpoint maximum number"
|
|
default 0
|
|
---help---
|
|
The maximum number of watchpoints that can be set by KASan.
|
|
|
|
config MM_KASAN_DISABLE_NULL_POINTER_CHECK
|
|
bool "Disable null pointer access check"
|
|
default n
|
|
---help---
|
|
This option enables KASan check null pointer access.
|
|
|
|
config MM_KASAN_DISABLE_READS_CHECK
|
|
bool "Disable reads check"
|
|
default n
|
|
---help---
|
|
This option disables 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"
|
|
default n
|
|
---help---
|
|
This option disables kasan writes check.
|
|
|
|
config MM_KASAN_DISABLE_READ_PANIC
|
|
bool "Disable panic on kasan read error"
|
|
default n
|
|
---help---
|
|
This option disables panic on kasan read error. It will print error info
|
|
and continue to run.
|
|
|
|
config MM_KASAN_DISABLE_WRITE_PANIC
|
|
bool "Disable panic on kasan write error"
|
|
default n
|
|
---help---
|
|
This option disables panic on kasan write error. It will print error info
|
|
and continue to run.
|
|
|
|
config MM_KASAN_SKIP_ZERO_TAGS
|
|
bool "Enable skip check zero tags"
|
|
default LIBC_ELF
|
|
---help---
|
|
This option disables checking for zero tags.
|
|
|
|
config MM_KASAN_GLOBAL
|
|
bool "Enable global data check"
|
|
depends on MM_KASAN_INSTRUMENT_ALL
|
|
default n
|
|
---help---
|
|
This option enables KASan global data check.
|
|
It's used to extract segments in the linker script.
|
|
Two new segments need to be created, one being
|
|
".kasan.unused: { *(.data..LASANLOC*) }",
|
|
used to eliminate excess data generated.
|
|
One is ".kasan.global:{
|
|
KEEP ( *(. data.. LASAN0))
|
|
KEEP ( *(. data. rel. local.. LASAN0))
|
|
}", used to extract data generated by the compiler
|
|
|
|
config MM_KASAN_GLOBAL_ALIGN
|
|
int "KASan global alignment"
|
|
default 1
|
|
depends on MM_KASAN_GLOBAL
|
|
---help---
|
|
It is recommended to use 1, 2, 4, 8, 16, 32.
|
|
The maximum value is 32.
|
|
|
|
endif # MM_KASAN_INSTRUMENT
|
|
endif # MM_KASAN
|