1ec8f24b7SThomas Gleixner# SPDX-License-Identifier: GPL-2.0-only 2eefa864bSJoonsoo Kimconfig PAGE_EXTENSION 3eefa864bSJoonsoo Kim bool "Extend memmap on extra space for more information on page" 4a7f7f624SMasahiro Yamada help 5eefa864bSJoonsoo Kim Extend memmap on extra space for more information on page. This 6eefa864bSJoonsoo Kim could be used for debugging features that need to insert extra 7eefa864bSJoonsoo Kim field for every page. This extension enables us to save memory 8eefa864bSJoonsoo Kim by not allocating this extra memory according to boottime 9eefa864bSJoonsoo Kim configuration. 10eefa864bSJoonsoo Kim 11ee3b4290SAkinobu Mitaconfig DEBUG_PAGEALLOC 12ee3b4290SAkinobu Mita bool "Debug page memory allocations" 137bc32f6fSAkinobu Mita depends on DEBUG_KERNEL 147bc32f6fSAkinobu Mita depends on !HIBERNATION || ARCH_SUPPORTS_DEBUG_PAGEALLOC && !PPC && !SPARC 157bc32f6fSAkinobu Mita select PAGE_POISONING if !ARCH_SUPPORTS_DEBUG_PAGEALLOC 16a7f7f624SMasahiro Yamada help 17ee3b4290SAkinobu Mita Unmap pages from the kernel linear mapping after free_pages(). 18ea6eabb0SChristian Borntraeger Depending on runtime enablement, this results in a small or large 19ea6eabb0SChristian Borntraeger slowdown, but helps to find certain types of memory corruption. 20ee3b4290SAkinobu Mita 214462b32cSVlastimil Babka Also, the state of page tracking structures is checked more often as 224462b32cSVlastimil Babka pages are being allocated and freed, as unexpected state changes 234462b32cSVlastimil Babka often happen for same reasons as memory corruption (e.g. double free, 248974558fSVlastimil Babka use-after-free). The error reports for these checks can be augmented 258974558fSVlastimil Babka with stack traces of last allocation and freeing of the page, when 268974558fSVlastimil Babka PAGE_OWNER is also selected and enabled on boot. 274462b32cSVlastimil Babka 287bc32f6fSAkinobu Mita For architectures which don't enable ARCH_SUPPORTS_DEBUG_PAGEALLOC, 297bc32f6fSAkinobu Mita fill the pages with poison patterns after free_pages() and verify 304462b32cSVlastimil Babka the patterns before alloc_pages(). Additionally, this option cannot 314462b32cSVlastimil Babka be enabled in combination with hibernation as that would result in 324462b32cSVlastimil Babka incorrect warnings of memory corruption after a resume because free 334462b32cSVlastimil Babka pages are not saved to the suspend image. 347bc32f6fSAkinobu Mita 35ea6eabb0SChristian Borntraeger By default this option will have a small overhead, e.g. by not 36ea6eabb0SChristian Borntraeger allowing the kernel mapping to be backed by large pages on some 37ea6eabb0SChristian Borntraeger architectures. Even bigger overhead comes when the debugging is 38ea6eabb0SChristian Borntraeger enabled by DEBUG_PAGEALLOC_ENABLE_DEFAULT or the debug_pagealloc 39ea6eabb0SChristian Borntraeger command line parameter. 40ea6eabb0SChristian Borntraeger 41ea6eabb0SChristian Borntraegerconfig DEBUG_PAGEALLOC_ENABLE_DEFAULT 42ea6eabb0SChristian Borntraeger bool "Enable debug page memory allocations by default?" 43ea6eabb0SChristian Borntraeger depends on DEBUG_PAGEALLOC 44a7f7f624SMasahiro Yamada help 45ea6eabb0SChristian Borntraeger Enable debug page memory allocations by default? This value 46ea6eabb0SChristian Borntraeger can be overridden by debug_pagealloc=off|on. 47ea6eabb0SChristian Borntraeger 480710d012SVlastimil Babkaconfig DEBUG_SLAB 490710d012SVlastimil Babka bool "Debug slab memory allocations" 500710d012SVlastimil Babka depends on DEBUG_KERNEL && SLAB 510710d012SVlastimil Babka help 520710d012SVlastimil Babka Say Y here to have the kernel do limited verification on memory 530710d012SVlastimil Babka allocation as well as poisoning memory on free to catch use of freed 540710d012SVlastimil Babka memory. This can make kmalloc/kfree-intensive workloads much slower. 550710d012SVlastimil Babka 560710d012SVlastimil Babkaconfig SLUB_DEBUG 570710d012SVlastimil Babka default y 580710d012SVlastimil Babka bool "Enable SLUB debugging support" if EXPERT 59e240e53aSVlastimil Babka depends on SLUB && SYSFS && !SLUB_TINY 608291eaafSLinus Torvalds select STACKDEPOT if STACKTRACE_SUPPORT 610710d012SVlastimil Babka help 620710d012SVlastimil Babka SLUB has extensive debug support features. Disabling these can 63220a20adSVernon Yang result in significant savings in code size. While /sys/kernel/slab 64220a20adSVernon Yang will still exist (with SYSFS enabled), it will not provide e.g. cache 65220a20adSVernon Yang validation. 660710d012SVlastimil Babka 670710d012SVlastimil Babkaconfig SLUB_DEBUG_ON 680710d012SVlastimil Babka bool "SLUB debugging on by default" 690710d012SVlastimil Babka depends on SLUB && SLUB_DEBUG 708291eaafSLinus Torvalds select STACKDEPOT_ALWAYS_INIT if STACKTRACE_SUPPORT 710710d012SVlastimil Babka default n 720710d012SVlastimil Babka help 730710d012SVlastimil Babka Boot with debugging on by default. SLUB boots by default with 740710d012SVlastimil Babka the runtime debug capabilities switched off. Enabling this is 750710d012SVlastimil Babka equivalent to specifying the "slub_debug" parameter on boot. 760710d012SVlastimil Babka There is no support for more fine grained debug control like 770710d012SVlastimil Babka possible with slub_debug=xxx. SLUB debugging may be switched 780710d012SVlastimil Babka off in a kernel built with CONFIG_SLUB_DEBUG_ON by specifying 790710d012SVlastimil Babka "slub_debug=-". 800710d012SVlastimil Babka 818aa49762SChangbin Duconfig PAGE_OWNER 828aa49762SChangbin Du bool "Track page owner" 838aa49762SChangbin Du depends on DEBUG_KERNEL && STACKTRACE_SUPPORT 848aa49762SChangbin Du select DEBUG_FS 858aa49762SChangbin Du select STACKTRACE 868aa49762SChangbin Du select STACKDEPOT 878aa49762SChangbin Du select PAGE_EXTENSION 888aa49762SChangbin Du help 898aa49762SChangbin Du This keeps track of what call chain is the owner of a page, may 908aa49762SChangbin Du help to find bare alloc_page(s) leaks. Even if you include this 918aa49762SChangbin Du feature on your build, it is disabled in default. You should pass 928aa49762SChangbin Du "page_owner=on" to boot parameter in order to enable it. Eats 93799fb82aSSeongJae Park a fair amount of memory if enabled. See tools/mm/page_owner_sort.c 948aa49762SChangbin Du for user-space helper. 958aa49762SChangbin Du 968aa49762SChangbin Du If unsure, say N. 978aa49762SChangbin Du 98df4e817bSPasha Tatashinconfig PAGE_TABLE_CHECK 99df4e817bSPasha Tatashin bool "Check for invalid mappings in user page tables" 100df4e817bSPasha Tatashin depends on ARCH_SUPPORTS_PAGE_TABLE_CHECK 101*81a31a86SRuihan Li depends on EXCLUSIVE_SYSTEM_RAM 102df4e817bSPasha Tatashin select PAGE_EXTENSION 103df4e817bSPasha Tatashin help 104df4e817bSPasha Tatashin Check that anonymous page is not being mapped twice with read write 105df4e817bSPasha Tatashin permissions. Check that anonymous and file pages are not being 106df4e817bSPasha Tatashin erroneously shared. Since the checking is performed at the time 107df4e817bSPasha Tatashin entries are added and removed to user page tables, leaking, corruption 108df4e817bSPasha Tatashin and double mapping problems are detected synchronously. 109df4e817bSPasha Tatashin 110df4e817bSPasha Tatashin If unsure say "n". 111df4e817bSPasha Tatashin 112df4e817bSPasha Tatashinconfig PAGE_TABLE_CHECK_ENFORCED 113df4e817bSPasha Tatashin bool "Enforce the page table checking by default" 114df4e817bSPasha Tatashin depends on PAGE_TABLE_CHECK 115df4e817bSPasha Tatashin help 116df4e817bSPasha Tatashin Always enable page table checking. By default the page table checking 117df4e817bSPasha Tatashin is disabled, and can be optionally enabled via page_table_check=on 118df4e817bSPasha Tatashin kernel parameter. This config enforces that page table check is always 119df4e817bSPasha Tatashin enabled. 120df4e817bSPasha Tatashin 121df4e817bSPasha Tatashin If unsure say "n". 122df4e817bSPasha Tatashin 1236a11f75bSAkinobu Mitaconfig PAGE_POISONING 1248823b1dbSLaura Abbott bool "Poison pages after freeing" 125a7f7f624SMasahiro Yamada help 1268823b1dbSLaura Abbott Fill the pages with poison patterns after free_pages() and verify 1278823b1dbSLaura Abbott the patterns before alloc_pages. The filling of the memory helps 1288823b1dbSLaura Abbott reduce the risk of information leaks from freed data. This does 1298c9a134cSKees Cook have a potential performance impact if enabled with the 1308c9a134cSKees Cook "page_poison=1" kernel boot option. 1318823b1dbSLaura Abbott 1328823b1dbSLaura Abbott Note that "poison" here is not the same thing as the "HWPoison" 1338823b1dbSLaura Abbott for CONFIG_MEMORY_FAILURE. This is software poisoning only. 1348823b1dbSLaura Abbott 1358f424750SVlastimil Babka If you are only interested in sanitization of freed pages without 1368f424750SVlastimil Babka checking the poison pattern on alloc, you can boot the kernel with 1378f424750SVlastimil Babka "init_on_free=1" instead of enabling this. 1388f424750SVlastimil Babka 1398823b1dbSLaura Abbott If unsure, say N 1408823b1dbSLaura Abbott 14195813b8fSJoonsoo Kimconfig DEBUG_PAGE_REF 14295813b8fSJoonsoo Kim bool "Enable tracepoint to track down page reference manipulation" 14395813b8fSJoonsoo Kim depends on DEBUG_KERNEL 14495813b8fSJoonsoo Kim depends on TRACEPOINTS 145a7f7f624SMasahiro Yamada help 14695813b8fSJoonsoo Kim This is a feature to add tracepoint for tracking down page reference 14795813b8fSJoonsoo Kim manipulation. This tracking is useful to diagnose functional failure 14895813b8fSJoonsoo Kim due to migration failures caused by page reference mismatches. Be 14995813b8fSJoonsoo Kim careful when enabling this feature because it adds about 30 KB to the 15095813b8fSJoonsoo Kim kernel code. However the runtime performance overhead is virtually 15195813b8fSJoonsoo Kim nil until the tracepoints are actually enabled. 1522959a5f7SJinbum Park 1532959a5f7SJinbum Parkconfig DEBUG_RODATA_TEST 1542959a5f7SJinbum Park bool "Testcase for the marking rodata read-only" 1552959a5f7SJinbum Park depends on STRICT_KERNEL_RWX 156a7f7f624SMasahiro Yamada help 1572959a5f7SJinbum Park This option enables a testcase for the setting rodata read-only. 15830d621f6SSteven Price 159375d315cSZong Liconfig ARCH_HAS_DEBUG_WX 160375d315cSZong Li bool 161375d315cSZong Li 162375d315cSZong Liconfig DEBUG_WX 163375d315cSZong Li bool "Warn on W+X mappings at boot" 164375d315cSZong Li depends on ARCH_HAS_DEBUG_WX 165375d315cSZong Li depends on MMU 166375d315cSZong Li select PTDUMP_CORE 167375d315cSZong Li help 168375d315cSZong Li Generate a warning if any W+X mappings are found at boot. 169375d315cSZong Li 170375d315cSZong Li This is useful for discovering cases where the kernel is leaving W+X 171375d315cSZong Li mappings after applying NX, as such mappings are a security risk. 172375d315cSZong Li 173375d315cSZong Li Look for a message in dmesg output like this: 174375d315cSZong Li 175375d315cSZong Li <arch>/mm: Checked W+X mappings: passed, no W+X pages found. 176375d315cSZong Li 177375d315cSZong Li or like this, if the check failed: 178375d315cSZong Li 179375d315cSZong Li <arch>/mm: Checked W+X mappings: failed, <N> W+X pages found. 180375d315cSZong Li 181375d315cSZong Li Note that even if the check fails, your kernel is possibly 182375d315cSZong Li still fine, as W+X mappings are not a security hole in 183375d315cSZong Li themselves, what they do is that they make the exploitation 184375d315cSZong Li of other unfixed kernel bugs easier. 185375d315cSZong Li 186375d315cSZong Li There is no runtime or memory usage effect of this option 187375d315cSZong Li once the kernel has booted up - it's a one time check. 188375d315cSZong Li 189375d315cSZong Li If in doubt, say "Y". 190375d315cSZong Li 19130d621f6SSteven Priceconfig GENERIC_PTDUMP 19230d621f6SSteven Price bool 19330d621f6SSteven Price 19430d621f6SSteven Priceconfig PTDUMP_CORE 19530d621f6SSteven Price bool 19630d621f6SSteven Price 19730d621f6SSteven Priceconfig PTDUMP_DEBUGFS 19830d621f6SSteven Price bool "Export kernel pagetable layout to userspace via debugfs" 19930d621f6SSteven Price depends on DEBUG_KERNEL 20030d621f6SSteven Price depends on DEBUG_FS 20130d621f6SSteven Price depends on GENERIC_PTDUMP 20230d621f6SSteven Price select PTDUMP_CORE 20330d621f6SSteven Price help 20430d621f6SSteven Price Say Y here if you want to show the kernel pagetable layout in a 20530d621f6SSteven Price debugfs file. This information is only useful for kernel developers 20630d621f6SSteven Price who are working in architecture specific areas of the kernel. 20730d621f6SSteven Price It is probably not a good idea to enable this feature in a production 20830d621f6SSteven Price kernel. 20930d621f6SSteven Price 21030d621f6SSteven Price If in doubt, say N. 211b2db9ef2SZhaoyang Huang 212b2db9ef2SZhaoyang Huangconfig HAVE_DEBUG_KMEMLEAK 213b2db9ef2SZhaoyang Huang bool 214b2db9ef2SZhaoyang Huang 215b2db9ef2SZhaoyang Huangconfig DEBUG_KMEMLEAK 216b2db9ef2SZhaoyang Huang bool "Kernel memory leak detector" 217b2db9ef2SZhaoyang Huang depends on DEBUG_KERNEL && HAVE_DEBUG_KMEMLEAK 218b2db9ef2SZhaoyang Huang select DEBUG_FS 219b2db9ef2SZhaoyang Huang select STACKTRACE if STACKTRACE_SUPPORT 220b2db9ef2SZhaoyang Huang select KALLSYMS 221b2db9ef2SZhaoyang Huang select CRC32 222b2db9ef2SZhaoyang Huang select STACKDEPOT 223b2db9ef2SZhaoyang Huang select STACKDEPOT_ALWAYS_INIT if !DEBUG_KMEMLEAK_DEFAULT_OFF 224b2db9ef2SZhaoyang Huang help 225b2db9ef2SZhaoyang Huang Say Y here if you want to enable the memory leak 226b2db9ef2SZhaoyang Huang detector. The memory allocation/freeing is traced in a way 227b2db9ef2SZhaoyang Huang similar to the Boehm's conservative garbage collector, the 228b2db9ef2SZhaoyang Huang difference being that the orphan objects are not freed but 229b2db9ef2SZhaoyang Huang only shown in /sys/kernel/debug/kmemleak. Enabling this 230b2db9ef2SZhaoyang Huang feature will introduce an overhead to memory 231b2db9ef2SZhaoyang Huang allocations. See Documentation/dev-tools/kmemleak.rst for more 232b2db9ef2SZhaoyang Huang details. 233b2db9ef2SZhaoyang Huang 234b2db9ef2SZhaoyang Huang Enabling DEBUG_SLAB or SLUB_DEBUG may increase the chances 235b2db9ef2SZhaoyang Huang of finding leaks due to the slab objects poisoning. 236b2db9ef2SZhaoyang Huang 237b2db9ef2SZhaoyang Huang In order to access the kmemleak file, debugfs needs to be 238b2db9ef2SZhaoyang Huang mounted (usually at /sys/kernel/debug). 239b2db9ef2SZhaoyang Huang 240b2db9ef2SZhaoyang Huangconfig DEBUG_KMEMLEAK_MEM_POOL_SIZE 241b2db9ef2SZhaoyang Huang int "Kmemleak memory pool size" 242b2db9ef2SZhaoyang Huang depends on DEBUG_KMEMLEAK 243b2db9ef2SZhaoyang Huang range 200 1000000 244b2db9ef2SZhaoyang Huang default 16000 245b2db9ef2SZhaoyang Huang help 246b2db9ef2SZhaoyang Huang Kmemleak must track all the memory allocations to avoid 247b2db9ef2SZhaoyang Huang reporting false positives. Since memory may be allocated or 248b2db9ef2SZhaoyang Huang freed before kmemleak is fully initialised, use a static pool 249b2db9ef2SZhaoyang Huang of metadata objects to track such callbacks. After kmemleak is 250b2db9ef2SZhaoyang Huang fully initialised, this memory pool acts as an emergency one 251b2db9ef2SZhaoyang Huang if slab allocations fail. 252b2db9ef2SZhaoyang Huang 253b2db9ef2SZhaoyang Huangconfig DEBUG_KMEMLEAK_DEFAULT_OFF 254b2db9ef2SZhaoyang Huang bool "Default kmemleak to off" 255b2db9ef2SZhaoyang Huang depends on DEBUG_KMEMLEAK 256b2db9ef2SZhaoyang Huang help 257b2db9ef2SZhaoyang Huang Say Y here to disable kmemleak by default. It can then be enabled 258b2db9ef2SZhaoyang Huang on the command line via kmemleak=on. 259b2db9ef2SZhaoyang Huang 260b2db9ef2SZhaoyang Huangconfig DEBUG_KMEMLEAK_AUTO_SCAN 261b2db9ef2SZhaoyang Huang bool "Enable kmemleak auto scan thread on boot up" 262b2db9ef2SZhaoyang Huang default y 263b2db9ef2SZhaoyang Huang depends on DEBUG_KMEMLEAK 264b2db9ef2SZhaoyang Huang help 265b2db9ef2SZhaoyang Huang Depending on the cpu, kmemleak scan may be cpu intensive and can 266b2db9ef2SZhaoyang Huang stall user tasks at times. This option enables/disables automatic 267b2db9ef2SZhaoyang Huang kmemleak scan at boot up. 268b2db9ef2SZhaoyang Huang 269b2db9ef2SZhaoyang Huang Say N here to disable kmemleak auto scan thread to stop automatic 270b2db9ef2SZhaoyang Huang scanning. Disabling this option disables automatic reporting of 271b2db9ef2SZhaoyang Huang memory leaks. 272b2db9ef2SZhaoyang Huang 273b2db9ef2SZhaoyang Huang If unsure, say Y. 274b2db9ef2SZhaoyang Huang 27552f23865SSuren Baghdasaryanconfig PER_VMA_LOCK_STATS 27652f23865SSuren Baghdasaryan bool "Statistics for per-vma locks" 27752f23865SSuren Baghdasaryan depends on PER_VMA_LOCK 27852f23865SSuren Baghdasaryan help 2796152e53dSSuren Baghdasaryan Say Y here to enable success, retry and failure counters of page 2806152e53dSSuren Baghdasaryan faults handled under protection of per-vma locks. When enabled, the 2816152e53dSSuren Baghdasaryan counters are exposed in /proc/vmstat. This information is useful for 2826152e53dSSuren Baghdasaryan kernel developers to evaluate effectiveness of per-vma locks and to 2836152e53dSSuren Baghdasaryan identify pathological cases. Counting these events introduces a small 2846152e53dSSuren Baghdasaryan overhead in the page fault path. 2856152e53dSSuren Baghdasaryan 2866152e53dSSuren Baghdasaryan If in doubt, say N. 287