0036-x86-kconfig-Consolidate-unwinders-into-multiple-choi.patch 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. From 73cf1dd35105d9cf270caf4a72b400b0a3ab4bb2 Mon Sep 17 00:00:00 2001
  2. From: Josh Poimboeuf <[email protected]>
  3. Date: Tue, 25 Jul 2017 08:54:24 -0500
  4. Subject: [PATCH 036/242] x86/kconfig: Consolidate unwinders into multiple
  5. choice selection
  6. MIME-Version: 1.0
  7. Content-Type: text/plain; charset=UTF-8
  8. Content-Transfer-Encoding: 8bit
  9. CVE-2017-5754
  10. There are three mutually exclusive unwinders. Make that more obvious by
  11. combining them into a multiple-choice selection:
  12. CONFIG_FRAME_POINTER_UNWINDER
  13. CONFIG_ORC_UNWINDER
  14. CONFIG_GUESS_UNWINDER (if CONFIG_EXPERT=y)
  15. Frame pointers are still the default (for now).
  16. The old CONFIG_FRAME_POINTER option is still used in some
  17. arch-independent places, so keep it around, but make it
  18. invisible to the user on x86 - it's now selected by
  19. CONFIG_FRAME_POINTER_UNWINDER=y.
  20. Suggested-by: Ingo Molnar <[email protected]>
  21. Signed-off-by: Josh Poimboeuf <[email protected]>
  22. Cc: Andy Lutomirski <[email protected]>
  23. Cc: Borislav Petkov <[email protected]>
  24. Cc: Brian Gerst <[email protected]>
  25. Cc: Denys Vlasenko <[email protected]>
  26. Cc: H. Peter Anvin <[email protected]>
  27. Cc: Jiri Slaby <[email protected]>
  28. Cc: Linus Torvalds <[email protected]>
  29. Cc: Mike Galbraith <[email protected]>
  30. Cc: Peter Zijlstra <[email protected]>
  31. Cc: Thomas Gleixner <[email protected]>
  32. Cc: [email protected]
  33. Link: http://lkml.kernel.org/r/20170725135424.zukjmgpz3plf5pmt@treble
  34. Signed-off-by: Ingo Molnar <[email protected]>
  35. (cherry picked from commit 81d387190039c14edac8de2b3ec789beb899afd9)
  36. Signed-off-by: Andy Whitcroft <[email protected]>
  37. Signed-off-by: Kleber Sacilotto de Souza <[email protected]>
  38. (cherry picked from commit 26ddacc1e6333555e4a6bd63c4c935b323509f92)
  39. Signed-off-by: Fabian Grünbichler <[email protected]>
  40. ---
  41. arch/x86/include/asm/unwind.h | 4 ++--
  42. arch/x86/Kconfig | 3 +--
  43. arch/x86/Kconfig.debug | 45 +++++++++++++++++++++++++++++++++++++------
  44. arch/x86/configs/tiny.config | 2 ++
  45. 4 files changed, 44 insertions(+), 10 deletions(-)
  46. diff --git a/arch/x86/include/asm/unwind.h b/arch/x86/include/asm/unwind.h
  47. index 25b8d31a007d..e9f793e2df7a 100644
  48. --- a/arch/x86/include/asm/unwind.h
  49. +++ b/arch/x86/include/asm/unwind.h
  50. @@ -16,7 +16,7 @@ struct unwind_state {
  51. bool signal, full_regs;
  52. unsigned long sp, bp, ip;
  53. struct pt_regs *regs;
  54. -#elif defined(CONFIG_FRAME_POINTER)
  55. +#elif defined(CONFIG_FRAME_POINTER_UNWINDER)
  56. bool got_irq;
  57. unsigned long *bp, *orig_sp, ip;
  58. struct pt_regs *regs;
  59. @@ -50,7 +50,7 @@ void unwind_start(struct unwind_state *state, struct task_struct *task,
  60. __unwind_start(state, task, regs, first_frame);
  61. }
  62. -#if defined(CONFIG_ORC_UNWINDER) || defined(CONFIG_FRAME_POINTER)
  63. +#if defined(CONFIG_ORC_UNWINDER) || defined(CONFIG_FRAME_POINTER_UNWINDER)
  64. static inline struct pt_regs *unwind_get_entry_regs(struct unwind_state *state)
  65. {
  66. if (unwind_done(state))
  67. diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
  68. index d6f45f6d1054..3a0b8cb57caf 100644
  69. --- a/arch/x86/Kconfig
  70. +++ b/arch/x86/Kconfig
  71. @@ -73,7 +73,6 @@ config X86
  72. select ARCH_USE_QUEUED_RWLOCKS
  73. select ARCH_USE_QUEUED_SPINLOCKS
  74. select ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH
  75. - select ARCH_WANT_FRAME_POINTERS
  76. select ARCH_WANTS_DYNAMIC_TASK_STRUCT
  77. select ARCH_WANTS_THP_SWAP if X86_64
  78. select BUILDTIME_EXTABLE_SORT
  79. @@ -169,7 +168,7 @@ config X86
  80. select HAVE_PERF_REGS
  81. select HAVE_PERF_USER_STACK_DUMP
  82. select HAVE_REGS_AND_STACK_ACCESS_API
  83. - select HAVE_RELIABLE_STACKTRACE if X86_64 && FRAME_POINTER && STACK_VALIDATION
  84. + select HAVE_RELIABLE_STACKTRACE if X86_64 && FRAME_POINTER_UNWINDER && STACK_VALIDATION
  85. select HAVE_STACK_VALIDATION if X86_64
  86. select HAVE_SYSCALL_TRACEPOINTS
  87. select HAVE_UNSTABLE_SCHED_CLOCK
  88. diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
  89. index d5bca2ec8a74..c441b5d65ec8 100644
  90. --- a/arch/x86/Kconfig.debug
  91. +++ b/arch/x86/Kconfig.debug
  92. @@ -356,6 +356,29 @@ config PUNIT_ATOM_DEBUG
  93. The current power state can be read from
  94. /sys/kernel/debug/punit_atom/dev_power_state
  95. +choice
  96. + prompt "Choose kernel unwinder"
  97. + default FRAME_POINTER_UNWINDER
  98. + ---help---
  99. + This determines which method will be used for unwinding kernel stack
  100. + traces for panics, oopses, bugs, warnings, perf, /proc/<pid>/stack,
  101. + livepatch, lockdep, and more.
  102. +
  103. +config FRAME_POINTER_UNWINDER
  104. + bool "Frame pointer unwinder"
  105. + select FRAME_POINTER
  106. + ---help---
  107. + This option enables the frame pointer unwinder for unwinding kernel
  108. + stack traces.
  109. +
  110. + The unwinder itself is fast and it uses less RAM than the ORC
  111. + unwinder, but the kernel text size will grow by ~3% and the kernel's
  112. + overall performance will degrade by roughly 5-10%.
  113. +
  114. + This option is recommended if you want to use the livepatch
  115. + consistency model, as this is currently the only way to get a
  116. + reliable stack trace (CONFIG_HAVE_RELIABLE_STACKTRACE).
  117. +
  118. config ORC_UNWINDER
  119. bool "ORC unwinder"
  120. depends on X86_64
  121. @@ -373,12 +396,22 @@ config ORC_UNWINDER
  122. Enabling this option will increase the kernel's runtime memory usage
  123. by roughly 2-4MB, depending on your kernel config.
  124. -config FRAME_POINTER_UNWINDER
  125. - def_bool y
  126. - depends on !ORC_UNWINDER && FRAME_POINTER
  127. -
  128. config GUESS_UNWINDER
  129. - def_bool y
  130. - depends on !ORC_UNWINDER && !FRAME_POINTER
  131. + bool "Guess unwinder"
  132. + depends on EXPERT
  133. + ---help---
  134. + This option enables the "guess" unwinder for unwinding kernel stack
  135. + traces. It scans the stack and reports every kernel text address it
  136. + finds. Some of the addresses it reports may be incorrect.
  137. +
  138. + While this option often produces false positives, it can still be
  139. + useful in many cases. Unlike the other unwinders, it has no runtime
  140. + overhead.
  141. +
  142. +endchoice
  143. +
  144. +config FRAME_POINTER
  145. + depends on !ORC_UNWINDER && !GUESS_UNWINDER
  146. + bool
  147. endmenu
  148. diff --git a/arch/x86/configs/tiny.config b/arch/x86/configs/tiny.config
  149. index 4b429df40d7a..550cd5012b73 100644
  150. --- a/arch/x86/configs/tiny.config
  151. +++ b/arch/x86/configs/tiny.config
  152. @@ -1,3 +1,5 @@
  153. CONFIG_NOHIGHMEM=y
  154. # CONFIG_HIGHMEM4G is not set
  155. # CONFIG_HIGHMEM64G is not set
  156. +CONFIG_GUESS_UNWINDER=y
  157. +# CONFIG_FRAME_POINTER_UNWINDER is not set
  158. --
  159. 2.14.2