Kconfig.debug 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  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 SLUB_DEBUG
  43. default y
  44. bool "Enable SLUB debugging support" if EXPERT
  45. depends on SYSFS && !SLUB_TINY
  46. select STACKDEPOT if STACKTRACE_SUPPORT
  47. help
  48. SLUB has extensive debug support features. Disabling these can
  49. result in significant savings in code size. While /sys/kernel/slab
  50. will still exist (with SYSFS enabled), it will not provide e.g. cache
  51. validation.
  52. config SLUB_DEBUG_ON
  53. bool "SLUB debugging on by default"
  54. depends on SLUB_DEBUG
  55. select STACKDEPOT_ALWAYS_INIT if STACKTRACE_SUPPORT
  56. default n
  57. help
  58. Boot with debugging on by default. SLUB boots by default with
  59. the runtime debug capabilities switched off. Enabling this is
  60. equivalent to specifying the "slab_debug" parameter on boot.
  61. There is no support for more fine grained debug control like
  62. possible with slab_debug=xxx. SLUB debugging may be switched
  63. off in a kernel built with CONFIG_SLUB_DEBUG_ON by specifying
  64. "slab_debug=-".
  65. config SLUB_RCU_DEBUG
  66. bool "Enable UAF detection in TYPESAFE_BY_RCU caches (for KASAN)"
  67. depends on SLUB_DEBUG
  68. # SLUB_RCU_DEBUG should build fine without KASAN, but is currently useless
  69. # without KASAN, so mark it as a dependency of KASAN for now.
  70. depends on KASAN
  71. default KASAN_GENERIC || KASAN_SW_TAGS
  72. help
  73. Make SLAB_TYPESAFE_BY_RCU caches behave approximately as if the cache
  74. was not marked as SLAB_TYPESAFE_BY_RCU and every caller used
  75. kfree_rcu() instead.
  76. This is intended for use in combination with KASAN, to enable KASAN to
  77. detect use-after-free accesses in such caches.
  78. (KFENCE is able to do that independent of this flag.)
  79. This might degrade performance.
  80. Unfortunately this also prevents a very specific bug pattern from
  81. triggering (insufficient checks against an object being recycled
  82. within the RCU grace period); so this option can be turned off even on
  83. KASAN builds, in case you want to test for such a bug.
  84. If you're using this for testing bugs / fuzzing and care about
  85. catching all the bugs WAY more than performance, you might want to
  86. also turn on CONFIG_RCU_STRICT_GRACE_PERIOD.
  87. WARNING:
  88. This is designed as a debugging feature, not a security feature.
  89. Objects are sometimes recycled without RCU delay under memory pressure.
  90. If unsure, say N.
  91. config PAGE_OWNER
  92. bool "Track page owner"
  93. depends on DEBUG_KERNEL && STACKTRACE_SUPPORT
  94. select DEBUG_FS
  95. select STACKTRACE
  96. select STACKDEPOT
  97. select PAGE_EXTENSION
  98. help
  99. This keeps track of what call chain is the owner of a page, may
  100. help to find bare alloc_page(s) leaks. Even if you include this
  101. feature on your build, it is disabled in default. You should pass
  102. "page_owner=on" to boot parameter in order to enable it. Eats
  103. a fair amount of memory if enabled. See tools/mm/page_owner_sort.c
  104. for user-space helper.
  105. If unsure, say N.
  106. config PAGE_TABLE_CHECK
  107. bool "Check for invalid mappings in user page tables"
  108. depends on ARCH_SUPPORTS_PAGE_TABLE_CHECK
  109. depends on EXCLUSIVE_SYSTEM_RAM
  110. select PAGE_EXTENSION
  111. help
  112. Check that anonymous page is not being mapped twice with read write
  113. permissions. Check that anonymous and file pages are not being
  114. erroneously shared. Since the checking is performed at the time
  115. entries are added and removed to user page tables, leaking, corruption
  116. and double mapping problems are detected synchronously.
  117. If unsure say "n".
  118. config PAGE_TABLE_CHECK_ENFORCED
  119. bool "Enforce the page table checking by default"
  120. depends on PAGE_TABLE_CHECK
  121. help
  122. Always enable page table checking. By default the page table checking
  123. is disabled, and can be optionally enabled via page_table_check=on
  124. kernel parameter. This config enforces that page table check is always
  125. enabled.
  126. If unsure say "n".
  127. config PAGE_POISONING
  128. bool "Poison pages after freeing"
  129. help
  130. Fill the pages with poison patterns after free_pages() and verify
  131. the patterns before alloc_pages. The filling of the memory helps
  132. reduce the risk of information leaks from freed data. This does
  133. have a potential performance impact if enabled with the
  134. "page_poison=1" kernel boot option.
  135. Note that "poison" here is not the same thing as the "HWPoison"
  136. for CONFIG_MEMORY_FAILURE. This is software poisoning only.
  137. If you are only interested in sanitization of freed pages without
  138. checking the poison pattern on alloc, you can boot the kernel with
  139. "init_on_free=1" instead of enabling this.
  140. If unsure, say N
  141. config DEBUG_PAGE_REF
  142. bool "Enable tracepoint to track down page reference manipulation"
  143. depends on DEBUG_KERNEL
  144. depends on TRACEPOINTS
  145. help
  146. This is a feature to add tracepoint for tracking down page reference
  147. manipulation. This tracking is useful to diagnose functional failure
  148. due to migration failures caused by page reference mismatches. Be
  149. careful when enabling this feature because it adds about 30 KB to the
  150. kernel code. However the runtime performance overhead is virtually
  151. nil until the tracepoints are actually enabled.
  152. config DEBUG_RODATA_TEST
  153. bool "Testcase for the marking rodata read-only"
  154. depends on STRICT_KERNEL_RWX
  155. help
  156. This option enables a testcase for the setting rodata read-only.
  157. config ARCH_HAS_DEBUG_WX
  158. bool
  159. config DEBUG_WX
  160. bool "Warn on W+X mappings at boot"
  161. depends on ARCH_HAS_DEBUG_WX
  162. depends on MMU
  163. select PTDUMP_CORE
  164. help
  165. Generate a warning if any W+X mappings are found at boot.
  166. This is useful for discovering cases where the kernel is leaving W+X
  167. mappings after applying NX, as such mappings are a security risk.
  168. Look for a message in dmesg output like this:
  169. <arch>/mm: Checked W+X mappings: passed, no W+X pages found.
  170. or like this, if the check failed:
  171. <arch>/mm: Checked W+X mappings: failed, <N> W+X pages found.
  172. Note that even if the check fails, your kernel is possibly
  173. still fine, as W+X mappings are not a security hole in
  174. themselves, what they do is that they make the exploitation
  175. of other unfixed kernel bugs easier.
  176. There is no runtime or memory usage effect of this option
  177. once the kernel has booted up - it's a one time check.
  178. If in doubt, say "Y".
  179. config GENERIC_PTDUMP
  180. bool
  181. config PTDUMP_CORE
  182. bool
  183. config PTDUMP_DEBUGFS
  184. bool "Export kernel pagetable layout to userspace via debugfs"
  185. depends on DEBUG_KERNEL
  186. depends on DEBUG_FS
  187. depends on GENERIC_PTDUMP
  188. select PTDUMP_CORE
  189. help
  190. Say Y here if you want to show the kernel pagetable layout in a
  191. debugfs file. This information is only useful for kernel developers
  192. who are working in architecture specific areas of the kernel.
  193. It is probably not a good idea to enable this feature in a production
  194. kernel.
  195. If in doubt, say N.
  196. config HAVE_DEBUG_KMEMLEAK
  197. bool
  198. config DEBUG_KMEMLEAK
  199. bool "Kernel memory leak detector"
  200. depends on DEBUG_KERNEL && HAVE_DEBUG_KMEMLEAK
  201. select DEBUG_FS
  202. select STACKTRACE if STACKTRACE_SUPPORT
  203. select KALLSYMS
  204. select CRC32
  205. select STACKDEPOT
  206. select STACKDEPOT_ALWAYS_INIT if !DEBUG_KMEMLEAK_DEFAULT_OFF
  207. help
  208. Say Y here if you want to enable the memory leak
  209. detector. The memory allocation/freeing is traced in a way
  210. similar to the Boehm's conservative garbage collector, the
  211. difference being that the orphan objects are not freed but
  212. only shown in /sys/kernel/debug/kmemleak. Enabling this
  213. feature will introduce an overhead to memory
  214. allocations. See Documentation/dev-tools/kmemleak.rst for more
  215. details.
  216. Enabling SLUB_DEBUG may increase the chances of finding leaks
  217. due to the slab objects poisoning.
  218. In order to access the kmemleak file, debugfs needs to be
  219. mounted (usually at /sys/kernel/debug).
  220. config DEBUG_KMEMLEAK_MEM_POOL_SIZE
  221. int "Kmemleak memory pool size"
  222. depends on DEBUG_KMEMLEAK
  223. range 200 1000000
  224. default 16000
  225. help
  226. Kmemleak must track all the memory allocations to avoid
  227. reporting false positives. Since memory may be allocated or
  228. freed before kmemleak is fully initialised, use a static pool
  229. of metadata objects to track such callbacks. After kmemleak is
  230. fully initialised, this memory pool acts as an emergency one
  231. if slab allocations fail.
  232. config DEBUG_KMEMLEAK_DEFAULT_OFF
  233. bool "Default kmemleak to off"
  234. depends on DEBUG_KMEMLEAK
  235. help
  236. Say Y here to disable kmemleak by default. It can then be enabled
  237. on the command line via kmemleak=on.
  238. config DEBUG_KMEMLEAK_AUTO_SCAN
  239. bool "Enable kmemleak auto scan thread on boot up"
  240. default y
  241. depends on DEBUG_KMEMLEAK
  242. help
  243. Depending on the cpu, kmemleak scan may be cpu intensive and can
  244. stall user tasks at times. This option enables/disables automatic
  245. kmemleak scan at boot up.
  246. Say N here to disable kmemleak auto scan thread to stop automatic
  247. scanning. Disabling this option disables automatic reporting of
  248. memory leaks.
  249. If unsure, say Y.
  250. config PER_VMA_LOCK_STATS
  251. bool "Statistics for per-vma locks"
  252. depends on PER_VMA_LOCK
  253. help
  254. Say Y here to enable success, retry and failure counters of page
  255. faults handled under protection of per-vma locks. When enabled, the
  256. counters are exposed in /proc/vmstat. This information is useful for
  257. kernel developers to evaluate effectiveness of per-vma locks and to
  258. identify pathological cases. Counting these events introduces a small
  259. overhead in the page fault path.
  260. If in doubt, say N.