diff --git a/mm/Kconfig b/mm/Kconfig index 356daa21969..2966d9f3008 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -318,124 +318,7 @@ config FS_PROCFS_EXCLUDE_MEMPOOL default DEFAULT_SMALL depends on FS_PROCFS && MM_HEAP_MEMPOOL_THRESHOLD > 0 -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. - -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" - ---help--- - KASan generic mode that does not require hardware support at all - -config MM_KASAN_SW_TAGS - bool "KAsan SW tags" - select ARM64_TBI - depends on ARCH_ARM64 - ---help--- - KAsan based on software tags - -endchoice - -config MM_KASAN_ALL - bool "Enable KASan for the entire image" - 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_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_MODLIB - ---help--- - This option disables checking for zero tags. - -config MM_KASAN_GLOBAL - bool "Enable global data check" - depends on MM_KASAN_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 +source "mm/kasan/Kconfig" config MM_UBSAN bool "Undefined Behavior Sanitizer" diff --git a/mm/kasan/Kconfig b/mm/kasan/Kconfig new file mode 100644 index 00000000000..4a6c9764a8f --- /dev/null +++ b/mm/kasan/Kconfig @@ -0,0 +1,123 @@ +# +# 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. + +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" + ---help--- + KASan generic mode that does not require hardware support at all + +config MM_KASAN_SW_TAGS + bool "KAsan SW tags" + select ARM64_TBI + depends on ARCH_ARM64 + ---help--- + KAsan based on software tags + +endchoice + +config MM_KASAN_ALL + bool "Enable KASan for the entire image" + 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_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_MODLIB + ---help--- + This option disables checking for zero tags. + +config MM_KASAN_GLOBAL + bool "Enable global data check" + depends on MM_KASAN_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