Kconfig.debug 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. # SPDX-License-Identifier: GPL-2.0-only
  2. config PAGE_EXTENSION
  3. bool "Extend memmap on extra space for more information on page"
  4. help
  5. Extend memmap on extra space for more information on page. This
  6. could be used for debugging features that need to insert extra
  7. field for every page. This extension enables us to save memory
  8. by not allocating this extra memory according to boottime
  9. configuration.
  10. config DEBUG_PAGEALLOC
  11. bool "Debug page memory allocations"
  12. depends on DEBUG_KERNEL
  13. depends on !HIBERNATION || ARCH_SUPPORTS_DEBUG_PAGEALLOC && !PPC && !SPARC
  14. select PAGE_POISONING if !ARCH_SUPPORTS_DEBUG_PAGEALLOC
  15. help
  16. Unmap pages from the kernel linear mapping after free_pages().
  17. Depending on runtime enablement, this results in a small or large
  18. slowdown, but helps to find certain types of memory corruption.
  19. Also, the state of page tracking structures is checked more often as
  20. pages are being allocated and freed, as unexpected state changes
  21. often happen for same reasons as memory corruption (e.g. double free,
  22. use-after-free). The error reports for these checks can be augmented
  23. with stack traces of last allocation and freeing of the page, when
  24. PAGE_OWNER is also selected and enabled on boot.
  25. For architectures which don't enable ARCH_SUPPORTS_DEBUG_PAGEALLOC,
  26. fill the pages with poison patterns after free_pages() and verify
  27. the patterns before alloc_pages(). Additionally, this option cannot
  28. be enabled in combination with hibernation as that would result in
  29. incorrect warnings of memory corruption after a resume because free
  30. pages are not saved to the suspend image.
  31. By default this option will have a small overhead, e.g. by not
  32. allowing the kernel mapping to be backed by large pages on some
  33. architectures. Even bigger overhead comes when the debugging is
  34. enabled by DEBUG_PAGEALLOC_ENABLE_DEFAULT or the debug_pagealloc
  35. command line parameter.
  36. config DEBUG_PAGEALLOC_ENABLE_DEFAULT
  37. bool "Enable debug page memory allocations by default?"
  38. depends on DEBUG_PAGEALLOC
  39. help
  40. Enable debug page memory allocations by default? This value
  41. can be overridden by debug_pagealloc=off|on.
  42. config DEBUG_SLAB
  43. bool "Debug slab memory allocations"
  44. depends on DEBUG_KERNEL && SLAB
  45. help
  46. Say Y here to have the kernel do limited verification on memory
  47. allocation as well as poisoning memory on free to catch use of freed
  48. memory. This can make kmalloc/kfree-intensive workloads much slower.
  49. config SLUB_DEBUG
  50. default y
  51. bool "Enable SLUB debugging support" if EXPERT
  52. depends on SLUB && SYSFS
  53. select STACKDEPOT if STACKTRACE_SUPPORT
  54. help
  55. SLUB has extensive debug support features. Disabling these can
  56. result in significant savings in code size. This also disables
  57. SLUB sysfs support. /sys/slab will not exist and there will be
  58. no support for cache validation etc.
  59. config SLUB_DEBUG_ON
  60. bool "SLUB debugging on by default"
  61. depends on SLUB && SLUB_DEBUG
  62. select STACKDEPOT_ALWAYS_INIT if STACKTRACE_SUPPORT
  63. default n
  64. help
  65. Boot with debugging on by default. SLUB boots by default with
  66. the runtime debug capabilities switched off. Enabling this is
  67. equivalent to specifying the "slub_debug" parameter on boot.
  68. There is no support for more fine grained debug control like
  69. possible with slub_debug=xxx. SLUB debugging may be switched
  70. off in a kernel built with CONFIG_SLUB_DEBUG_ON by specifying
  71. "slub_debug=-".
  72. config PAGE_OWNER
  73. bool "Track page owner"
  74. depends on DEBUG_KERNEL && STACKTRACE_SUPPORT
  75. select DEBUG_FS
  76. select STACKTRACE
  77. select STACKDEPOT
  78. select PAGE_EXTENSION
  79. help
  80. This keeps track of what call chain is the owner of a page, may
  81. help to find bare alloc_page(s) leaks. Even if you include this
  82. feature on your build, it is disabled in default. You should pass
  83. "page_owner=on" to boot parameter in order to enable it. Eats
  84. a fair amount of memory if enabled. See tools/vm/page_owner_sort.c
  85. for user-space helper.
  86. If unsure, say N.
  87. config PAGE_TABLE_CHECK
  88. bool "Check for invalid mappings in user page tables"
  89. depends on ARCH_SUPPORTS_PAGE_TABLE_CHECK
  90. depends on EXCLUSIVE_SYSTEM_RAM
  91. select PAGE_EXTENSION
  92. help
  93. Check that anonymous page is not being mapped twice with read write
  94. permissions. Check that anonymous and file pages are not being
  95. erroneously shared. Since the checking is performed at the time
  96. entries are added and removed to user page tables, leaking, corruption
  97. and double mapping problems are detected synchronously.
  98. If unsure say "n".
  99. config PAGE_TABLE_CHECK_ENFORCED
  100. bool "Enforce the page table checking by default"
  101. depends on PAGE_TABLE_CHECK
  102. help
  103. Always enable page table checking. By default the page table checking
  104. is disabled, and can be optionally enabled via page_table_check=on
  105. kernel parameter. This config enforces that page table check is always
  106. enabled.
  107. If unsure say "n".
  108. config PAGE_PINNER
  109. bool "Track page pinner"
  110. depends on DEBUG_KERNEL && STACKTRACE_SUPPORT
  111. select DEBUG_FS
  112. select STACKTRACE
  113. select STACKDEPOT
  114. select PAGE_EXTENSION
  115. help
  116. This keeps track of what call chain is the pinner of a page, may
  117. help to find page migration failures. Even if you include this
  118. feature in your build, it is disabled by default. You should pass
  119. "page_pinner=on" to boot parameter in order to enable it. Eats
  120. a fair amount of memory if enabled.
  121. If unsure, say N.
  122. config PAGE_POISONING
  123. bool "Poison pages after freeing"
  124. help
  125. Fill the pages with poison patterns after free_pages() and verify
  126. the patterns before alloc_pages. The filling of the memory helps
  127. reduce the risk of information leaks from freed data. This does
  128. have a potential performance impact if enabled with the
  129. "page_poison=1" kernel boot option.
  130. Note that "poison" here is not the same thing as the "HWPoison"
  131. for CONFIG_MEMORY_FAILURE. This is software poisoning only.
  132. If you are only interested in sanitization of freed pages without
  133. checking the poison pattern on alloc, you can boot the kernel with
  134. "init_on_free=1" instead of enabling this.
  135. If unsure, say N
  136. config DEBUG_PAGE_REF
  137. bool "Enable tracepoint to track down page reference manipulation"
  138. depends on DEBUG_KERNEL
  139. depends on TRACEPOINTS
  140. help
  141. This is a feature to add tracepoint for tracking down page reference
  142. manipulation. This tracking is useful to diagnose functional failure
  143. due to migration failures caused by page reference mismatches. Be
  144. careful when enabling this feature because it adds about 30 KB to the
  145. kernel code. However the runtime performance overhead is virtually
  146. nil until the tracepoints are actually enabled.
  147. config DEBUG_RODATA_TEST
  148. bool "Testcase for the marking rodata read-only"
  149. depends on STRICT_KERNEL_RWX
  150. help
  151. This option enables a testcase for the setting rodata read-only.
  152. config ARCH_HAS_DEBUG_WX
  153. bool
  154. config DEBUG_WX
  155. bool "Warn on W+X mappings at boot"
  156. depends on ARCH_HAS_DEBUG_WX
  157. depends on MMU
  158. select PTDUMP_CORE
  159. help
  160. Generate a warning if any W+X mappings are found at boot.
  161. This is useful for discovering cases where the kernel is leaving W+X
  162. mappings after applying NX, as such mappings are a security risk.
  163. Look for a message in dmesg output like this:
  164. <arch>/mm: Checked W+X mappings: passed, no W+X pages found.
  165. or like this, if the check failed:
  166. <arch>/mm: Checked W+X mappings: failed, <N> W+X pages found.
  167. Note that even if the check fails, your kernel is possibly
  168. still fine, as W+X mappings are not a security hole in
  169. themselves, what they do is that they make the exploitation
  170. of other unfixed kernel bugs easier.
  171. There is no runtime or memory usage effect of this option
  172. once the kernel has booted up - it's a one time check.
  173. If in doubt, say "Y".
  174. config GENERIC_PTDUMP
  175. bool
  176. config PTDUMP_CORE
  177. bool
  178. config PTDUMP_DEBUGFS
  179. bool "Export kernel pagetable layout to userspace via debugfs"
  180. depends on DEBUG_KERNEL
  181. depends on DEBUG_FS
  182. depends on GENERIC_PTDUMP
  183. select PTDUMP_CORE
  184. help
  185. Say Y here if you want to show the kernel pagetable layout in a
  186. debugfs file. This information is only useful for kernel developers
  187. who are working in architecture specific areas of the kernel.
  188. It is probably not a good idea to enable this feature in a production
  189. kernel.
  190. If in doubt, say N.
  191. config PER_VMA_LOCK_STATS
  192. bool "Statistics for per-vma locks"
  193. depends on PER_VMA_LOCK
  194. help
  195. Say Y here to enable success, retry and failure counters of page
  196. faults handled under protection of per-vma locks. When enabled, the
  197. counters are exposed in /proc/vmstat. This information is useful for
  198. kernel developers to evaluate effectiveness of per-vma locks and to
  199. identify pathological cases. Counting these events introduces a small
  200. overhead in the page fault path.
  201. If in doubt, say N.