Andrey Ryabinin | 0b24bec | 2015-02-13 14:39:17 -0800 | [diff] [blame] | 1 | config HAVE_ARCH_KASAN |
| 2 | bool |
| 3 | |
| 4 | if HAVE_ARCH_KASAN |
| 5 | |
| 6 | config KASAN |
| 7 | bool "KASan: runtime memory debugger" |
Arnd Bergmann | 03758db | 2018-07-26 16:37:12 -0700 | [diff] [blame] | 8 | depends on (SLUB && SYSFS) || (SLAB && !DEBUG_SLAB) |
Jason A. Donenfeld | dd275ca | 2018-06-27 23:26:20 -0700 | [diff] [blame] | 9 | select SLUB_DEBUG if SLUB |
Andrey Ryabinin | bebf56a | 2015-02-13 14:40:17 -0800 | [diff] [blame] | 10 | select CONSTRUCTORS |
Alexander Potapenko | 80a9201 | 2016-07-28 15:49:07 -0700 | [diff] [blame] | 11 | select STACKDEPOT |
Andrey Ryabinin | 0b24bec | 2015-02-13 14:39:17 -0800 | [diff] [blame] | 12 | help |
| 13 | Enables kernel address sanitizer - runtime memory debugger, |
| 14 | designed to find out-of-bounds accesses and use-after-free bugs. |
Joe Perches | 01e7690 | 2015-05-05 16:23:38 -0700 | [diff] [blame] | 15 | This is strictly a debugging feature and it requires a gcc version |
| 16 | of 4.9.2 or later. Detection of out of bounds accesses to stack or |
| 17 | global variables requires gcc 5.0 or later. |
| 18 | This feature consumes about 1/8 of available memory and brings about |
| 19 | ~x3 performance slowdown. |
Andrey Ryabinin | 89d3c87 | 2015-11-05 18:51:23 -0800 | [diff] [blame] | 20 | For better error detection enable CONFIG_STACKTRACE. |
Alexander Potapenko | 7ed2f9e | 2016-03-25 14:21:59 -0700 | [diff] [blame] | 21 | Currently CONFIG_KASAN doesn't work with CONFIG_DEBUG_SLAB |
| 22 | (the resulting kernel does not boot). |
Andrey Ryabinin | 0b24bec | 2015-02-13 14:39:17 -0800 | [diff] [blame] | 23 | |
Arnd Bergmann | e7c52b8 | 2018-02-06 15:41:41 -0800 | [diff] [blame] | 24 | config KASAN_EXTRA |
| 25 | bool "KAsan: extra checks" |
| 26 | depends on KASAN && DEBUG_KERNEL && !COMPILE_TEST |
| 27 | help |
| 28 | This enables further checks in the kernel address sanitizer, for now |
| 29 | it only includes the address-use-after-scope check that can lead |
| 30 | to excessive kernel stack usage, frame size warnings and longer |
| 31 | compile time. |
| 32 | https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81715 has more |
| 33 | |
| 34 | |
Andrey Ryabinin | 0b24bec | 2015-02-13 14:39:17 -0800 | [diff] [blame] | 35 | choice |
| 36 | prompt "Instrumentation type" |
| 37 | depends on KASAN |
| 38 | default KASAN_OUTLINE |
| 39 | |
| 40 | config KASAN_OUTLINE |
| 41 | bool "Outline instrumentation" |
| 42 | help |
| 43 | Before every memory access compiler insert function call |
| 44 | __asan_load*/__asan_store*. These functions performs check |
| 45 | of shadow memory. This is slower than inline instrumentation, |
| 46 | however it doesn't bloat size of kernel's .text section so |
| 47 | much as inline does. |
| 48 | |
| 49 | config KASAN_INLINE |
| 50 | bool "Inline instrumentation" |
| 51 | help |
| 52 | Compiler directly inserts code checking shadow memory before |
| 53 | memory accesses. This is faster than outline (in some workloads |
| 54 | it gives about x2 boost over outline instrumentation), but |
| 55 | make kernel's .text size much bigger. |
Joe Perches | 01e7690 | 2015-05-05 16:23:38 -0700 | [diff] [blame] | 56 | This requires a gcc version of 5.0 or later. |
Andrey Ryabinin | 0b24bec | 2015-02-13 14:39:17 -0800 | [diff] [blame] | 57 | |
| 58 | endchoice |
| 59 | |
Vasily Gorbik | 5dff038 | 2017-11-19 11:54:14 +0100 | [diff] [blame] | 60 | config KASAN_S390_4_LEVEL_PAGING |
| 61 | bool "KASan: use 4-level paging" |
| 62 | depends on KASAN && S390 |
| 63 | help |
| 64 | Compiling the kernel with KASan disables automatic 3-level vs |
| 65 | 4-level paging selection. 3-level paging is used by default (up |
| 66 | to 3TB of RAM with KASan enabled). This options allows to force |
| 67 | 4-level paging instead. |
| 68 | |
Andrey Ryabinin | 3f15801 | 2015-02-13 14:39:53 -0800 | [diff] [blame] | 69 | config TEST_KASAN |
| 70 | tristate "Module for testing kasan for bug detection" |
| 71 | depends on m && KASAN |
| 72 | help |
| 73 | This is a test module doing various nasty things like |
| 74 | out of bounds accesses, use after free. It is useful for testing |
| 75 | kernel debugging features like kernel address sanitizer. |
| 76 | |
Andrey Ryabinin | 0b24bec | 2015-02-13 14:39:17 -0800 | [diff] [blame] | 77 | endif |