Kconfig.debug 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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 PAGE_OWNER
  43. bool "Track page owner"
  44. depends on DEBUG_KERNEL && STACKTRACE_SUPPORT
  45. select DEBUG_FS
  46. select STACKTRACE
  47. select STACKDEPOT
  48. select PAGE_EXTENSION
  49. help
  50. This keeps track of what call chain is the owner of a page, may
  51. help to find bare alloc_page(s) leaks. Even if you include this
  52. feature on your build, it is disabled in default. You should pass
  53. "page_owner=on" to boot parameter in order to enable it. Eats
  54. a fair amount of memory if enabled. See tools/vm/page_owner_sort.c
  55. for user-space helper.
  56. If unsure, say N.
  57. config PAGE_PINNER
  58. bool "Track page pinner"
  59. depends on DEBUG_KERNEL && STACKTRACE_SUPPORT
  60. select DEBUG_FS
  61. select STACKTRACE
  62. select STACKDEPOT
  63. select PAGE_EXTENSION
  64. help
  65. This keeps track of what call chain is the pinner of a page, may
  66. help to find page migration failures. Even if you include this
  67. feature in your build, it is disabled by default. You should pass
  68. "page_pinner=on" to boot parameter in order to enable it. Eats
  69. a fair amount of memory if enabled.
  70. If unsure, say N.
  71. config PAGE_POISONING
  72. bool "Poison pages after freeing"
  73. help
  74. Fill the pages with poison patterns after free_pages() and verify
  75. the patterns before alloc_pages. The filling of the memory helps
  76. reduce the risk of information leaks from freed data. This does
  77. have a potential performance impact if enabled with the
  78. "page_poison=1" kernel boot option.
  79. Note that "poison" here is not the same thing as the "HWPoison"
  80. for CONFIG_MEMORY_FAILURE. This is software poisoning only.
  81. If you are only interested in sanitization of freed pages without
  82. checking the poison pattern on alloc, you can boot the kernel with
  83. "init_on_free=1" instead of enabling this.
  84. If unsure, say N
  85. config DEBUG_PAGE_REF
  86. bool "Enable tracepoint to track down page reference manipulation"
  87. depends on DEBUG_KERNEL
  88. depends on TRACEPOINTS
  89. help
  90. This is a feature to add tracepoint for tracking down page reference
  91. manipulation. This tracking is useful to diagnose functional failure
  92. due to migration failures caused by page reference mismatches. Be
  93. careful when enabling this feature because it adds about 30 KB to the
  94. kernel code. However the runtime performance overhead is virtually
  95. nil until the tracepoints are actually enabled.
  96. config DEBUG_RODATA_TEST
  97. bool "Testcase for the marking rodata read-only"
  98. depends on STRICT_KERNEL_RWX
  99. help
  100. This option enables a testcase for the setting rodata read-only.
  101. config ARCH_HAS_DEBUG_WX
  102. bool
  103. config DEBUG_WX
  104. bool "Warn on W+X mappings at boot"
  105. depends on ARCH_HAS_DEBUG_WX
  106. depends on MMU
  107. select PTDUMP_CORE
  108. help
  109. Generate a warning if any W+X mappings are found at boot.
  110. This is useful for discovering cases where the kernel is leaving W+X
  111. mappings after applying NX, as such mappings are a security risk.
  112. Look for a message in dmesg output like this:
  113. <arch>/mm: Checked W+X mappings: passed, no W+X pages found.
  114. or like this, if the check failed:
  115. <arch>/mm: Checked W+X mappings: failed, <N> W+X pages found.
  116. Note that even if the check fails, your kernel is possibly
  117. still fine, as W+X mappings are not a security hole in
  118. themselves, what they do is that they make the exploitation
  119. of other unfixed kernel bugs easier.
  120. There is no runtime or memory usage effect of this option
  121. once the kernel has booted up - it's a one time check.
  122. If in doubt, say "Y".
  123. config GENERIC_PTDUMP
  124. bool
  125. config PTDUMP_CORE
  126. bool
  127. config PTDUMP_DEBUGFS
  128. bool "Export kernel pagetable layout to userspace via debugfs"
  129. depends on DEBUG_KERNEL
  130. depends on DEBUG_FS
  131. depends on GENERIC_PTDUMP
  132. select PTDUMP_CORE
  133. help
  134. Say Y here if you want to show the kernel pagetable layout in a
  135. debugfs file. This information is only useful for kernel developers
  136. who are working in architecture specific areas of the kernel.
  137. It is probably not a good idea to enable this feature in a production
  138. kernel.
  139. If in doubt, say N.