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