]>
Commit | Line | Data |
---|---|---|
59d5af67 | 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
321d628a FG |
2 | From: Masami Hiramatsu <mhiramat@kernel.org> |
3 | Date: Thu, 3 Aug 2017 11:38:21 +0900 | |
59d5af67 | 4 | Subject: [PATCH] irq: Make the irqentry text section unconditional |
321d628a FG |
5 | MIME-Version: 1.0 |
6 | Content-Type: text/plain; charset=UTF-8 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ||
9 | CVE-2017-5754 | |
10 | ||
11 | Generate irqentry and softirqentry text sections without | |
12 | any Kconfig dependencies. This will add extra sections, but | |
13 | there should be no performace impact. | |
14 | ||
15 | Suggested-by: Ingo Molnar <mingo@kernel.org> | |
16 | Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> | |
17 | Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com> | |
18 | Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> | |
19 | Cc: Chris Zankel <chris@zankel.net> | |
20 | Cc: David S . Miller <davem@davemloft.net> | |
21 | Cc: Francis Deslauriers <francis.deslauriers@efficios.com> | |
22 | Cc: Jesper Nilsson <jesper.nilsson@axis.com> | |
23 | Cc: Linus Torvalds <torvalds@linux-foundation.org> | |
24 | Cc: Max Filippov <jcmvbkbc@gmail.com> | |
25 | Cc: Mikael Starvik <starvik@axis.com> | |
26 | Cc: Peter Zijlstra <peterz@infradead.org> | |
27 | Cc: Thomas Gleixner <tglx@linutronix.de> | |
28 | Cc: Yoshinori Sato <ysato@users.sourceforge.jp> | |
29 | Cc: linux-arch@vger.kernel.org | |
30 | Cc: linux-cris-kernel@axis.com | |
31 | Cc: mathieu.desnoyers@efficios.com | |
32 | Link: http://lkml.kernel.org/r/150172789110.27216.3955739126693102122.stgit@devbox | |
33 | Signed-off-by: Ingo Molnar <mingo@kernel.org> | |
34 | (cherry picked from commit 229a71860547ec856b156179a9c6bef2de426f66) | |
35 | Signed-off-by: Andy Whitcroft <apw@canonical.com> | |
36 | Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com> | |
37 | (cherry picked from commit 8fd2f68cc93ae772cfddf4151d13448ff17d0229) | |
38 | Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com> | |
39 | --- | |
40 | arch/arm/include/asm/traps.h | 7 ------- | |
41 | arch/arm64/include/asm/traps.h | 7 ------- | |
42 | include/asm-generic/sections.h | 4 ++++ | |
43 | include/asm-generic/vmlinux.lds.h | 8 -------- | |
44 | include/linux/interrupt.h | 14 +------------- | |
45 | arch/x86/kernel/unwind_frame.c | 2 -- | |
46 | arch/x86/entry/entry_64.S | 9 ++------- | |
47 | 7 files changed, 7 insertions(+), 44 deletions(-) | |
48 | ||
49 | diff --git a/arch/arm/include/asm/traps.h b/arch/arm/include/asm/traps.h | |
50 | index f555bb3664dc..683d9230984a 100644 | |
51 | --- a/arch/arm/include/asm/traps.h | |
52 | +++ b/arch/arm/include/asm/traps.h | |
53 | @@ -18,7 +18,6 @@ struct undef_hook { | |
54 | void register_undef_hook(struct undef_hook *hook); | |
55 | void unregister_undef_hook(struct undef_hook *hook); | |
56 | ||
57 | -#ifdef CONFIG_FUNCTION_GRAPH_TRACER | |
58 | static inline int __in_irqentry_text(unsigned long ptr) | |
59 | { | |
60 | extern char __irqentry_text_start[]; | |
61 | @@ -27,12 +26,6 @@ static inline int __in_irqentry_text(unsigned long ptr) | |
62 | return ptr >= (unsigned long)&__irqentry_text_start && | |
63 | ptr < (unsigned long)&__irqentry_text_end; | |
64 | } | |
65 | -#else | |
66 | -static inline int __in_irqentry_text(unsigned long ptr) | |
67 | -{ | |
68 | - return 0; | |
69 | -} | |
70 | -#endif | |
71 | ||
72 | static inline int in_exception_text(unsigned long ptr) | |
73 | { | |
74 | diff --git a/arch/arm64/include/asm/traps.h b/arch/arm64/include/asm/traps.h | |
75 | index 02e9035b0685..47a9066f7c86 100644 | |
76 | --- a/arch/arm64/include/asm/traps.h | |
77 | +++ b/arch/arm64/include/asm/traps.h | |
78 | @@ -37,18 +37,11 @@ void unregister_undef_hook(struct undef_hook *hook); | |
79 | ||
80 | void arm64_notify_segfault(struct pt_regs *regs, unsigned long addr); | |
81 | ||
82 | -#ifdef CONFIG_FUNCTION_GRAPH_TRACER | |
83 | static inline int __in_irqentry_text(unsigned long ptr) | |
84 | { | |
85 | return ptr >= (unsigned long)&__irqentry_text_start && | |
86 | ptr < (unsigned long)&__irqentry_text_end; | |
87 | } | |
88 | -#else | |
89 | -static inline int __in_irqentry_text(unsigned long ptr) | |
90 | -{ | |
91 | - return 0; | |
92 | -} | |
93 | -#endif | |
94 | ||
95 | static inline int in_exception_text(unsigned long ptr) | |
96 | { | |
97 | diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h | |
98 | index 532372c6cf15..e5da44eddd2f 100644 | |
99 | --- a/include/asm-generic/sections.h | |
100 | +++ b/include/asm-generic/sections.h | |
101 | @@ -27,6 +27,8 @@ | |
102 | * __kprobes_text_start, __kprobes_text_end | |
103 | * __entry_text_start, __entry_text_end | |
104 | * __ctors_start, __ctors_end | |
105 | + * __irqentry_text_start, __irqentry_text_end | |
106 | + * __softirqentry_text_start, __softirqentry_text_end | |
107 | */ | |
108 | extern char _text[], _stext[], _etext[]; | |
109 | extern char _data[], _sdata[], _edata[]; | |
110 | @@ -39,6 +41,8 @@ extern char __per_cpu_load[], __per_cpu_start[], __per_cpu_end[]; | |
111 | extern char __kprobes_text_start[], __kprobes_text_end[]; | |
112 | extern char __entry_text_start[], __entry_text_end[]; | |
113 | extern char __start_rodata[], __end_rodata[]; | |
114 | +extern char __irqentry_text_start[], __irqentry_text_end[]; | |
115 | +extern char __softirqentry_text_start[], __softirqentry_text_end[]; | |
116 | ||
117 | /* Start and end of .ctors section - used for constructor calls. */ | |
118 | extern char __ctors_start[], __ctors_end[]; | |
119 | diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h | |
120 | index 9623d78f8494..e7e955d4ab9e 100644 | |
121 | --- a/include/asm-generic/vmlinux.lds.h | |
122 | +++ b/include/asm-generic/vmlinux.lds.h | |
123 | @@ -497,25 +497,17 @@ | |
124 | *(.entry.text) \ | |
125 | VMLINUX_SYMBOL(__entry_text_end) = .; | |
126 | ||
127 | -#if defined(CONFIG_FUNCTION_GRAPH_TRACER) || defined(CONFIG_KASAN) | |
128 | #define IRQENTRY_TEXT \ | |
129 | ALIGN_FUNCTION(); \ | |
130 | VMLINUX_SYMBOL(__irqentry_text_start) = .; \ | |
131 | *(.irqentry.text) \ | |
132 | VMLINUX_SYMBOL(__irqentry_text_end) = .; | |
133 | -#else | |
134 | -#define IRQENTRY_TEXT | |
135 | -#endif | |
136 | ||
137 | -#if defined(CONFIG_FUNCTION_GRAPH_TRACER) || defined(CONFIG_KASAN) | |
138 | #define SOFTIRQENTRY_TEXT \ | |
139 | ALIGN_FUNCTION(); \ | |
140 | VMLINUX_SYMBOL(__softirqentry_text_start) = .; \ | |
141 | *(.softirqentry.text) \ | |
142 | VMLINUX_SYMBOL(__softirqentry_text_end) = .; | |
143 | -#else | |
144 | -#define SOFTIRQENTRY_TEXT | |
145 | -#endif | |
146 | ||
147 | /* Section used for early init (in .S files) */ | |
148 | #define HEAD_TEXT *(.head.text) | |
149 | diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h | |
150 | index a2fddddb0d60..59ba11661b6e 100644 | |
151 | --- a/include/linux/interrupt.h | |
152 | +++ b/include/linux/interrupt.h | |
153 | @@ -18,6 +18,7 @@ | |
154 | #include <linux/atomic.h> | |
155 | #include <asm/ptrace.h> | |
156 | #include <asm/irq.h> | |
157 | +#include <asm/sections.h> | |
158 | ||
159 | /* | |
160 | * These correspond to the IORESOURCE_IRQ_* defines in | |
161 | @@ -726,7 +727,6 @@ extern int early_irq_init(void); | |
162 | extern int arch_probe_nr_irqs(void); | |
163 | extern int arch_early_irq_init(void); | |
164 | ||
165 | -#if defined(CONFIG_FUNCTION_GRAPH_TRACER) || defined(CONFIG_KASAN) | |
166 | /* | |
167 | * We want to know which function is an entrypoint of a hardirq or a softirq. | |
168 | */ | |
169 | @@ -734,16 +734,4 @@ extern int arch_early_irq_init(void); | |
170 | #define __softirq_entry \ | |
171 | __attribute__((__section__(".softirqentry.text"))) | |
172 | ||
173 | -/* Limits of hardirq entrypoints */ | |
174 | -extern char __irqentry_text_start[]; | |
175 | -extern char __irqentry_text_end[]; | |
176 | -/* Limits of softirq entrypoints */ | |
177 | -extern char __softirqentry_text_start[]; | |
178 | -extern char __softirqentry_text_end[]; | |
179 | - | |
180 | -#else | |
181 | -#define __irq_entry | |
182 | -#define __softirq_entry | |
183 | -#endif | |
184 | - | |
185 | #endif | |
186 | diff --git a/arch/x86/kernel/unwind_frame.c b/arch/x86/kernel/unwind_frame.c | |
187 | index b9389d72b2f7..c29e5bc7e9c9 100644 | |
188 | --- a/arch/x86/kernel/unwind_frame.c | |
189 | +++ b/arch/x86/kernel/unwind_frame.c | |
190 | @@ -91,10 +91,8 @@ static bool in_entry_code(unsigned long ip) | |
191 | if (addr >= __entry_text_start && addr < __entry_text_end) | |
192 | return true; | |
193 | ||
194 | -#if defined(CONFIG_FUNCTION_GRAPH_TRACER) || defined(CONFIG_KASAN) | |
195 | if (addr >= __irqentry_text_start && addr < __irqentry_text_end) | |
196 | return true; | |
197 | -#endif | |
198 | ||
199 | return false; | |
200 | } | |
201 | diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S | |
202 | index 4dbb336a1fdd..ca0b250eefc4 100644 | |
203 | --- a/arch/x86/entry/entry_64.S | |
204 | +++ b/arch/x86/entry/entry_64.S | |
205 | @@ -761,13 +761,8 @@ apicinterrupt3 \num trace(\sym) smp_trace(\sym) | |
206 | #endif | |
207 | ||
208 | /* Make sure APIC interrupt handlers end up in the irqentry section: */ | |
209 | -#if defined(CONFIG_FUNCTION_GRAPH_TRACER) || defined(CONFIG_KASAN) | |
210 | -# define PUSH_SECTION_IRQENTRY .pushsection .irqentry.text, "ax" | |
211 | -# define POP_SECTION_IRQENTRY .popsection | |
212 | -#else | |
213 | -# define PUSH_SECTION_IRQENTRY | |
214 | -# define POP_SECTION_IRQENTRY | |
215 | -#endif | |
216 | +#define PUSH_SECTION_IRQENTRY .pushsection .irqentry.text, "ax" | |
217 | +#define POP_SECTION_IRQENTRY .popsection | |
218 | ||
219 | .macro apicinterrupt num sym do_sym | |
220 | PUSH_SECTION_IRQENTRY | |
221 | -- | |
222 | 2.14.2 | |
223 |