Skip to content

Commit 9b4cd4e

Browse files
W-M-Rxiaoxiang781216
authored andcommitted
kasan: Extract kasan's kconfig separately
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
1 parent 299136b commit 9b4cd4e

File tree

2 files changed

+124
-118
lines changed

2 files changed

+124
-118
lines changed

mm/Kconfig

Lines changed: 1 addition & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -318,124 +318,7 @@ config FS_PROCFS_EXCLUDE_MEMPOOL
318318
default DEFAULT_SMALL
319319
depends on FS_PROCFS && MM_HEAP_MEMPOOL_THRESHOLD > 0
320320

321-
config MM_KASAN
322-
bool "Kernel Address Sanitizer"
323-
default n
324-
---help---
325-
KASan is a fast compiler-based tool for detecting memory
326-
bugs in native code. After turn on this option, Please
327-
add -fsanitize=kernel-address to CFLAGS/CXXFLAGS too.
328-
329-
if MM_KASAN
330-
331-
choice
332-
prompt "KAsan Mode"
333-
default MM_KASAN_GENERIC
334-
335-
config MM_KASAN_NONE
336-
bool "KAsan disable"
337-
---help---
338-
Disable KASan check
339-
340-
config MM_KASAN_GENERIC
341-
bool "KAsan generic mode"
342-
---help---
343-
KASan generic mode that does not require hardware support at all
344-
345-
config MM_KASAN_SW_TAGS
346-
bool "KAsan SW tags"
347-
select ARM64_TBI
348-
depends on ARCH_ARM64
349-
---help---
350-
KAsan based on software tags
351-
352-
endchoice
353-
354-
config MM_KASAN_ALL
355-
bool "Enable KASan for the entire image"
356-
default y
357-
---help---
358-
This option activates address sanitizer for the entire image.
359-
If you don't enable this option, you have to explicitly specify
360-
"-fsanitize=kernel-address" for the files/directories you want
361-
to check. Enabling this option will get image size increased
362-
and performance decreased significantly.
363-
364-
config MM_KASAN_REGIONS
365-
int "Kasan region count"
366-
default 8
367-
368-
config MM_KASAN_WATCHPOINT
369-
int "Kasan watchpoint maximum number"
370-
default 0
371-
---help---
372-
The maximum number of watchpoints that can be set by KASan.
373-
374-
config MM_KASAN_DISABLE_NULL_POINTER_CHECK
375-
bool "Disable null pointer access check"
376-
default n
377-
---help---
378-
This option enables KASan check null pointer access.
379-
380-
config MM_KASAN_DISABLE_READS_CHECK
381-
bool "Disable reads check"
382-
default n
383-
---help---
384-
This option disables kasan reads check. It speeds up performance
385-
compared with default read/write check. Only disable it when you are
386-
sure there's no need to do so. Or performance is too bad and only focus
387-
on writes check.
388-
389-
config MM_KASAN_DISABLE_WRITES_CHECK
390-
bool "Disable writes check"
391-
default n
392-
---help---
393-
This option disables kasan writes check.
394-
395-
config MM_KASAN_DISABLE_READ_PANIC
396-
bool "Disable panic on kasan read error"
397-
default n
398-
---help---
399-
This option disables panic on kasan read error. It will print error info
400-
and continue to run.
401-
402-
config MM_KASAN_DISABLE_WRITE_PANIC
403-
bool "Disable panic on kasan write error"
404-
default n
405-
---help---
406-
This option disables panic on kasan write error. It will print error info
407-
and continue to run.
408-
409-
config MM_KASAN_SKIP_ZERO_TAGS
410-
bool "Enable skip check zero tags"
411-
default LIBC_MODLIB
412-
---help---
413-
This option disables checking for zero tags.
414-
415-
config MM_KASAN_GLOBAL
416-
bool "Enable global data check"
417-
depends on MM_KASAN_ALL
418-
default n
419-
---help---
420-
This option enables KASan global data check.
421-
It's used to extract segments in the linker script.
422-
Two new segments need to be created, one being
423-
".kasan.unused: { *(.data..LASANLOC*) }",
424-
used to eliminate excess data generated.
425-
One is ".kasan.global:{
426-
KEEP ( *(. data.. LASAN0))
427-
KEEP ( *(. data. rel. local.. LASAN0))
428-
}", used to extract data generated by the compiler
429-
430-
config MM_KASAN_GLOBAL_ALIGN
431-
int "KASan global alignment"
432-
default 1
433-
depends on MM_KASAN_GLOBAL
434-
---help---
435-
It is recommended to use 1, 2, 4, 8, 16, 32.
436-
The maximum value is 32.
437-
438-
endif # MM_KASAN
321+
source "mm/kasan/Kconfig"
439322

440323
config MM_UBSAN
441324
bool "Undefined Behavior Sanitizer"

mm/kasan/Kconfig

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
#
2+
# For a description of the syntax of this configuration file,
3+
# see the file kconfig-language.txt in the NuttX tools repository.
4+
#
5+
6+
config MM_KASAN
7+
bool "Kernel Address Sanitizer"
8+
default n
9+
---help---
10+
KASan is a fast compiler-based tool for detecting memory
11+
bugs in native code. After turn on this option, Please
12+
add -fsanitize=kernel-address to CFLAGS/CXXFLAGS too.
13+
14+
if MM_KASAN
15+
16+
choice
17+
prompt "KAsan Mode"
18+
default MM_KASAN_GENERIC
19+
20+
config MM_KASAN_NONE
21+
bool "KAsan disable"
22+
---help---
23+
Disable KASan check
24+
25+
config MM_KASAN_GENERIC
26+
bool "KAsan generic mode"
27+
---help---
28+
KASan generic mode that does not require hardware support at all
29+
30+
config MM_KASAN_SW_TAGS
31+
bool "KAsan SW tags"
32+
select ARM64_TBI
33+
depends on ARCH_ARM64
34+
---help---
35+
KAsan based on software tags
36+
37+
endchoice
38+
39+
config MM_KASAN_ALL
40+
bool "Enable KASan for the entire image"
41+
default y
42+
---help---
43+
This option activates address sanitizer for the entire image.
44+
If you don't enable this option, you have to explicitly specify
45+
"-fsanitize=kernel-address" for the files/directories you want
46+
to check. Enabling this option will get image size increased
47+
and performance decreased significantly.
48+
49+
config MM_KASAN_REGIONS
50+
int "Kasan region count"
51+
default 8
52+
53+
config MM_KASAN_WATCHPOINT
54+
int "Kasan watchpoint maximum number"
55+
default 0
56+
---help---
57+
The maximum number of watchpoints that can be set by KASan.
58+
59+
config MM_KASAN_DISABLE_NULL_POINTER_CHECK
60+
bool "Disable null pointer access check"
61+
default n
62+
---help---
63+
This option enables KASan check null pointer access.
64+
65+
config MM_KASAN_DISABLE_READS_CHECK
66+
bool "Disable reads check"
67+
default n
68+
---help---
69+
This option disables kasan reads check. It speeds up performance
70+
compared with default read/write check. Only disable it when you are
71+
sure there's no need to do so. Or performance is too bad and only focus
72+
on writes check.
73+
74+
config MM_KASAN_DISABLE_WRITES_CHECK
75+
bool "Disable writes check"
76+
default n
77+
---help---
78+
This option disables kasan writes check.
79+
80+
config MM_KASAN_DISABLE_READ_PANIC
81+
bool "Disable panic on kasan read error"
82+
default n
83+
---help---
84+
This option disables panic on kasan read error. It will print error info
85+
and continue to run.
86+
87+
config MM_KASAN_DISABLE_WRITE_PANIC
88+
bool "Disable panic on kasan write error"
89+
default n
90+
---help---
91+
This option disables panic on kasan write error. It will print error info
92+
and continue to run.
93+
94+
config MM_KASAN_SKIP_ZERO_TAGS
95+
bool "Enable skip check zero tags"
96+
default LIBC_MODLIB
97+
---help---
98+
This option disables checking for zero tags.
99+
100+
config MM_KASAN_GLOBAL
101+
bool "Enable global data check"
102+
depends on MM_KASAN_ALL
103+
default n
104+
---help---
105+
This option enables KASan global data check.
106+
It's used to extract segments in the linker script.
107+
Two new segments need to be created, one being
108+
".kasan.unused: { *(.data..LASANLOC*) }",
109+
used to eliminate excess data generated.
110+
One is ".kasan.global:{
111+
KEEP ( *(. data.. LASAN0))
112+
KEEP ( *(. data. rel. local.. LASAN0))
113+
}", used to extract data generated by the compiler
114+
115+
config MM_KASAN_GLOBAL_ALIGN
116+
int "KASan global alignment"
117+
default 1
118+
depends on MM_KASAN_GLOBAL
119+
---help---
120+
It is recommended to use 1, 2, 4, 8, 16, 32.
121+
The maximum value is 32.
122+
123+
endif # MM_KASAN

0 commit comments

Comments
 (0)