311 lines · plain
1# SPDX-License-Identifier: GPL-2.0-only2config PAGE_EXTENSION3 bool "Extend memmap on extra space for more information on page"4 help5 Extend memmap on extra space for more information on page. This6 could be used for debugging features that need to insert extra7 field for every page. This extension enables us to save memory8 by not allocating this extra memory according to boottime9 configuration.10 11config DEBUG_PAGEALLOC12 bool "Debug page memory allocations"13 depends on DEBUG_KERNEL14 depends on !HIBERNATION || ARCH_SUPPORTS_DEBUG_PAGEALLOC && !PPC && !SPARC15 select PAGE_POISONING if !ARCH_SUPPORTS_DEBUG_PAGEALLOC16 help17 Unmap pages from the kernel linear mapping after free_pages().18 Depending on runtime enablement, this results in a small or large19 slowdown, but helps to find certain types of memory corruption.20 21 Also, the state of page tracking structures is checked more often as22 pages are being allocated and freed, as unexpected state changes23 often happen for same reasons as memory corruption (e.g. double free,24 use-after-free). The error reports for these checks can be augmented25 with stack traces of last allocation and freeing of the page, when26 PAGE_OWNER is also selected and enabled on boot.27 28 For architectures which don't enable ARCH_SUPPORTS_DEBUG_PAGEALLOC,29 fill the pages with poison patterns after free_pages() and verify30 the patterns before alloc_pages(). Additionally, this option cannot31 be enabled in combination with hibernation as that would result in32 incorrect warnings of memory corruption after a resume because free33 pages are not saved to the suspend image.34 35 By default this option will have a small overhead, e.g. by not36 allowing the kernel mapping to be backed by large pages on some37 architectures. Even bigger overhead comes when the debugging is38 enabled by DEBUG_PAGEALLOC_ENABLE_DEFAULT or the debug_pagealloc39 command line parameter.40 41config DEBUG_PAGEALLOC_ENABLE_DEFAULT42 bool "Enable debug page memory allocations by default?"43 depends on DEBUG_PAGEALLOC44 help45 Enable debug page memory allocations by default? This value46 can be overridden by debug_pagealloc=off|on.47 48config SLUB_DEBUG49 default y50 bool "Enable SLUB debugging support" if EXPERT51 depends on SYSFS && !SLUB_TINY52 select STACKDEPOT if STACKTRACE_SUPPORT53 help54 SLUB has extensive debug support features. Disabling these can55 result in significant savings in code size. While /sys/kernel/slab56 will still exist (with SYSFS enabled), it will not provide e.g. cache57 validation.58 59config SLUB_DEBUG_ON60 bool "SLUB debugging on by default"61 depends on SLUB_DEBUG62 select STACKDEPOT_ALWAYS_INIT if STACKTRACE_SUPPORT63 default n64 help65 Boot with debugging on by default. SLUB boots by default with66 the runtime debug capabilities switched off. Enabling this is67 equivalent to specifying the "slab_debug" parameter on boot.68 There is no support for more fine grained debug control like69 possible with slab_debug=xxx. SLUB debugging may be switched70 off in a kernel built with CONFIG_SLUB_DEBUG_ON by specifying71 "slab_debug=-".72 73config SLUB_RCU_DEBUG74 bool "Enable UAF detection in TYPESAFE_BY_RCU caches (for KASAN)"75 depends on SLUB_DEBUG76 # SLUB_RCU_DEBUG should build fine without KASAN, but is currently useless77 # without KASAN, so mark it as a dependency of KASAN for now.78 depends on KASAN79 default KASAN_GENERIC || KASAN_SW_TAGS80 help81 Make SLAB_TYPESAFE_BY_RCU caches behave approximately as if the cache82 was not marked as SLAB_TYPESAFE_BY_RCU and every caller used83 kfree_rcu() instead.84 85 This is intended for use in combination with KASAN, to enable KASAN to86 detect use-after-free accesses in such caches.87 (KFENCE is able to do that independent of this flag.)88 89 This might degrade performance.90 Unfortunately this also prevents a very specific bug pattern from91 triggering (insufficient checks against an object being recycled92 within the RCU grace period); so this option can be turned off even on93 KASAN builds, in case you want to test for such a bug.94 95 If you're using this for testing bugs / fuzzing and care about96 catching all the bugs WAY more than performance, you might want to97 also turn on CONFIG_RCU_STRICT_GRACE_PERIOD.98 99 WARNING:100 This is designed as a debugging feature, not a security feature.101 Objects are sometimes recycled without RCU delay under memory pressure.102 103 If unsure, say N.104 105config PAGE_OWNER106 bool "Track page owner"107 depends on DEBUG_KERNEL && STACKTRACE_SUPPORT108 select DEBUG_FS109 select STACKTRACE110 select STACKDEPOT111 select PAGE_EXTENSION112 help113 This keeps track of what call chain is the owner of a page, may114 help to find bare alloc_page(s) leaks. Even if you include this115 feature on your build, it is disabled in default. You should pass116 "page_owner=on" to boot parameter in order to enable it. Eats117 a fair amount of memory if enabled. See tools/mm/page_owner_sort.c118 for user-space helper.119 120 If unsure, say N.121 122config PAGE_TABLE_CHECK123 bool "Check for invalid mappings in user page tables"124 depends on ARCH_SUPPORTS_PAGE_TABLE_CHECK125 depends on EXCLUSIVE_SYSTEM_RAM126 select PAGE_EXTENSION127 help128 Check that anonymous page is not being mapped twice with read write129 permissions. Check that anonymous and file pages are not being130 erroneously shared. Since the checking is performed at the time131 entries are added and removed to user page tables, leaking, corruption132 and double mapping problems are detected synchronously.133 134 If unsure say "n".135 136config PAGE_TABLE_CHECK_ENFORCED137 bool "Enforce the page table checking by default"138 depends on PAGE_TABLE_CHECK139 help140 Always enable page table checking. By default the page table checking141 is disabled, and can be optionally enabled via page_table_check=on142 kernel parameter. This config enforces that page table check is always143 enabled.144 145 If unsure say "n".146 147config PAGE_POISONING148 bool "Poison pages after freeing"149 help150 Fill the pages with poison patterns after free_pages() and verify151 the patterns before alloc_pages. The filling of the memory helps152 reduce the risk of information leaks from freed data. This does153 have a potential performance impact if enabled with the154 "page_poison=1" kernel boot option.155 156 Note that "poison" here is not the same thing as the "HWPoison"157 for CONFIG_MEMORY_FAILURE. This is software poisoning only.158 159 If you are only interested in sanitization of freed pages without160 checking the poison pattern on alloc, you can boot the kernel with161 "init_on_free=1" instead of enabling this.162 163 If unsure, say N164 165config DEBUG_PAGE_REF166 bool "Enable tracepoint to track down page reference manipulation"167 depends on DEBUG_KERNEL168 depends on TRACEPOINTS169 help170 This is a feature to add tracepoint for tracking down page reference171 manipulation. This tracking is useful to diagnose functional failure172 due to migration failures caused by page reference mismatches. Be173 careful when enabling this feature because it adds about 30 KB to the174 kernel code. However the runtime performance overhead is virtually175 nil until the tracepoints are actually enabled.176 177config DEBUG_RODATA_TEST178 bool "Testcase for the marking rodata read-only"179 depends on STRICT_KERNEL_RWX180 help181 This option enables a testcase for the setting rodata read-only.182 183config ARCH_HAS_DEBUG_WX184 bool185 186config DEBUG_WX187 bool "Warn on W+X mappings at boot"188 depends on ARCH_HAS_DEBUG_WX189 depends on MMU190 select PTDUMP_CORE191 help192 Generate a warning if any W+X mappings are found at boot.193 194 This is useful for discovering cases where the kernel is leaving W+X195 mappings after applying NX, as such mappings are a security risk.196 197 Look for a message in dmesg output like this:198 199 <arch>/mm: Checked W+X mappings: passed, no W+X pages found.200 201 or like this, if the check failed:202 203 <arch>/mm: Checked W+X mappings: failed, <N> W+X pages found.204 205 Note that even if the check fails, your kernel is possibly206 still fine, as W+X mappings are not a security hole in207 themselves, what they do is that they make the exploitation208 of other unfixed kernel bugs easier.209 210 There is no runtime or memory usage effect of this option211 once the kernel has booted up - it's a one time check.212 213 If in doubt, say "Y".214 215config GENERIC_PTDUMP216 bool217 218config PTDUMP_CORE219 bool220 221config PTDUMP_DEBUGFS222 bool "Export kernel pagetable layout to userspace via debugfs"223 depends on DEBUG_KERNEL224 depends on DEBUG_FS225 depends on GENERIC_PTDUMP226 select PTDUMP_CORE227 help228 Say Y here if you want to show the kernel pagetable layout in a229 debugfs file. This information is only useful for kernel developers230 who are working in architecture specific areas of the kernel.231 It is probably not a good idea to enable this feature in a production232 kernel.233 234 If in doubt, say N.235 236config HAVE_DEBUG_KMEMLEAK237 bool238 239config DEBUG_KMEMLEAK240 bool "Kernel memory leak detector"241 depends on DEBUG_KERNEL && HAVE_DEBUG_KMEMLEAK242 select DEBUG_FS243 select STACKTRACE if STACKTRACE_SUPPORT244 select KALLSYMS245 select CRC32246 select STACKDEPOT247 select STACKDEPOT_ALWAYS_INIT if !DEBUG_KMEMLEAK_DEFAULT_OFF248 help249 Say Y here if you want to enable the memory leak250 detector. The memory allocation/freeing is traced in a way251 similar to the Boehm's conservative garbage collector, the252 difference being that the orphan objects are not freed but253 only shown in /sys/kernel/debug/kmemleak. Enabling this254 feature will introduce an overhead to memory255 allocations. See Documentation/dev-tools/kmemleak.rst for more256 details.257 258 Enabling SLUB_DEBUG may increase the chances of finding leaks259 due to the slab objects poisoning.260 261 In order to access the kmemleak file, debugfs needs to be262 mounted (usually at /sys/kernel/debug).263 264config DEBUG_KMEMLEAK_MEM_POOL_SIZE265 int "Kmemleak memory pool size"266 depends on DEBUG_KMEMLEAK267 range 200 1000000268 default 16000269 help270 Kmemleak must track all the memory allocations to avoid271 reporting false positives. Since memory may be allocated or272 freed before kmemleak is fully initialised, use a static pool273 of metadata objects to track such callbacks. After kmemleak is274 fully initialised, this memory pool acts as an emergency one275 if slab allocations fail.276 277config DEBUG_KMEMLEAK_DEFAULT_OFF278 bool "Default kmemleak to off"279 depends on DEBUG_KMEMLEAK280 help281 Say Y here to disable kmemleak by default. It can then be enabled282 on the command line via kmemleak=on.283 284config DEBUG_KMEMLEAK_AUTO_SCAN285 bool "Enable kmemleak auto scan thread on boot up"286 default y287 depends on DEBUG_KMEMLEAK288 help289 Depending on the cpu, kmemleak scan may be cpu intensive and can290 stall user tasks at times. This option enables/disables automatic291 kmemleak scan at boot up.292 293 Say N here to disable kmemleak auto scan thread to stop automatic294 scanning. Disabling this option disables automatic reporting of295 memory leaks.296 297 If unsure, say Y.298 299config PER_VMA_LOCK_STATS300 bool "Statistics for per-vma locks"301 depends on PER_VMA_LOCK302 help303 Say Y here to enable success, retry and failure counters of page304 faults handled under protection of per-vma locks. When enabled, the305 counters are exposed in /proc/vmstat. This information is useful for306 kernel developers to evaluate effectiveness of per-vma locks and to307 identify pathological cases. Counting these events introduces a small308 overhead in the page fault path.309 310 If in doubt, say N.311