0023-irq-Make-the-irqentry-text-section-unconditional.patch 7.7 KB

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