summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-06-13 23:21:18 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-06-13 23:21:18 -0400
commit050e9baa9dc9fbd9ce2b27f0056990fc9e0a08a0 (patch)
tree5087d180ea4c26c6b89f10bc160c15559cc02785
parentbe779f03d563981c65cc7417cc5e0dbbc5b89d30 (diff)
Kbuild: rename CC_STACKPROTECTOR[_STRONG] config variables
The changes to automatically test for working stack protector compiler support in the Kconfig files removed the special STACKPROTECTOR_AUTO option that picked the strongest stack protector that the compiler supported. That was all a nice cleanup - it makes no sense to have the AUTO case now that the Kconfig phase can just determine the compiler support directly. HOWEVER. It also meant that doing "make oldconfig" would now _disable_ the strong stackprotector if you had AUTO enabled, because in a legacy config file, the sane stack protector configuration would look like CONFIG_HAVE_CC_STACKPROTECTOR=y # CONFIG_CC_STACKPROTECTOR_NONE is not set # CONFIG_CC_STACKPROTECTOR_REGULAR is not set # CONFIG_CC_STACKPROTECTOR_STRONG is not set CONFIG_CC_STACKPROTECTOR_AUTO=y and when you ran this through "make oldconfig" with the Kbuild changes, it would ask you about the regular CONFIG_CC_STACKPROTECTOR (that had been renamed from CONFIG_CC_STACKPROTECTOR_REGULAR to just CONFIG_CC_STACKPROTECTOR), but it would think that the STRONG version used to be disabled (because it was really enabled by AUTO), and would disable it in the new config, resulting in: CONFIG_HAVE_CC_STACKPROTECTOR=y CONFIG_CC_HAS_STACKPROTECTOR_NONE=y CONFIG_CC_STACKPROTECTOR=y # CONFIG_CC_STACKPROTECTOR_STRONG is not set CONFIG_CC_HAS_SANE_STACKPROTECTOR=y That's dangerously subtle - people could suddenly find themselves with the weaker stack protector setup without even realizing. The solution here is to just rename not just the old RECULAR stack protector option, but also the strong one. This does that by just removing the CC_ prefix entirely for the user choices, because it really is not about the compiler support (the compiler support now instead automatially impacts _visibility_ of the options to users). This results in "make oldconfig" actually asking the user for their choice, so that we don't have any silent subtle security model changes. The end result would generally look like this: CONFIG_HAVE_CC_STACKPROTECTOR=y CONFIG_CC_HAS_STACKPROTECTOR_NONE=y CONFIG_STACKPROTECTOR=y CONFIG_STACKPROTECTOR_STRONG=y CONFIG_CC_HAS_SANE_STACKPROTECTOR=y where the "CC_" versions really are about internal compiler infrastructure, not the user selections. Acked-by: Masahiro Yamada <yamada.masahiro@socionext.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--Documentation/kbuild/kconfig-language.txt2
-rw-r--r--Documentation/security/self-protection.rst2
-rw-r--r--Makefile4
-rw-r--r--arch/Kconfig6
-rw-r--r--arch/arm/kernel/asm-offsets.c2
-rw-r--r--arch/arm/kernel/entry-armv.S4
-rw-r--r--arch/arm/kernel/process.c2
-rw-r--r--arch/arm64/kernel/process.c2
-rw-r--r--arch/mips/kernel/asm-offsets.c2
-rw-r--r--arch/mips/kernel/octeon_switch.S2
-rw-r--r--arch/mips/kernel/process.c2
-rw-r--r--arch/mips/kernel/r2300_switch.S2
-rw-r--r--arch/mips/kernel/r4k_switch.S2
-rw-r--r--arch/sh/kernel/process.c2
-rw-r--r--arch/sh/kernel/process_32.c2
-rw-r--r--arch/x86/entry/entry_32.S2
-rw-r--r--arch/x86/entry/entry_64.S2
-rw-r--r--arch/x86/include/asm/processor.h2
-rw-r--r--arch/x86/include/asm/segment.h2
-rw-r--r--arch/x86/include/asm/stackprotector.h6
-rw-r--r--arch/x86/kernel/asm-offsets.c2
-rw-r--r--arch/x86/kernel/asm-offsets_32.c2
-rw-r--r--arch/x86/kernel/asm-offsets_64.c2
-rw-r--r--arch/x86/kernel/cpu/common.c2
-rw-r--r--arch/x86/kernel/head_32.S2
-rw-r--r--arch/xtensa/kernel/asm-offsets.c2
-rw-r--r--arch/xtensa/kernel/entry.S2
-rw-r--r--arch/xtensa/kernel/process.c2
-rw-r--r--include/linux/sched.h2
-rw-r--r--include/linux/stackprotector.h2
-rw-r--r--kernel/configs/android-recommended.config2
-rw-r--r--kernel/fork.c2
-rw-r--r--kernel/panic.c2
33 files changed, 39 insertions, 39 deletions
diff --git a/Documentation/kbuild/kconfig-language.txt b/Documentation/kbuild/kconfig-language.txt
index a4eb01843c04..3534a84d206c 100644
--- a/Documentation/kbuild/kconfig-language.txt
+++ b/Documentation/kbuild/kconfig-language.txt
@@ -480,7 +480,7 @@ There are several features that need compiler support. The recommended way
480to describe the dependency on the compiler feature is to use "depends on" 480to describe the dependency on the compiler feature is to use "depends on"
481followed by a test macro. 481followed by a test macro.
482 482
483config CC_STACKPROTECTOR 483config STACKPROTECTOR
484 bool "Stack Protector buffer overflow detection" 484 bool "Stack Protector buffer overflow detection"
485 depends on $(cc-option,-fstack-protector) 485 depends on $(cc-option,-fstack-protector)
486 ... 486 ...
diff --git a/Documentation/security/self-protection.rst b/Documentation/security/self-protection.rst
index 0f53826c78b9..e1ca698e0006 100644
--- a/Documentation/security/self-protection.rst
+++ b/Documentation/security/self-protection.rst
@@ -156,7 +156,7 @@ The classic stack buffer overflow involves writing past the expected end
156of a variable stored on the stack, ultimately writing a controlled value 156of a variable stored on the stack, ultimately writing a controlled value
157to the stack frame's stored return address. The most widely used defense 157to the stack frame's stored return address. The most widely used defense
158is the presence of a stack canary between the stack variables and the 158is the presence of a stack canary between the stack variables and the
159return address (``CONFIG_CC_STACKPROTECTOR``), which is verified just before 159return address (``CONFIG_STACKPROTECTOR``), which is verified just before
160the function returns. Other defenses include things like shadow stacks. 160the function returns. Other defenses include things like shadow stacks.
161 161
162Stack depth overflow 162Stack depth overflow
diff --git a/Makefile b/Makefile
index 73f0bb2c7a98..8a26b5937241 100644
--- a/Makefile
+++ b/Makefile
@@ -687,8 +687,8 @@ KBUILD_CFLAGS += $(call cc-option,-Wframe-larger-than=${CONFIG_FRAME_WARN})
687endif 687endif
688 688
689stackp-flags-$(CONFIG_CC_HAS_STACKPROTECTOR_NONE) := -fno-stack-protector 689stackp-flags-$(CONFIG_CC_HAS_STACKPROTECTOR_NONE) := -fno-stack-protector
690stackp-flags-$(CONFIG_CC_STACKPROTECTOR) := -fstack-protector 690stackp-flags-$(CONFIG_STACKPROTECTOR) := -fstack-protector
691stackp-flags-$(CONFIG_CC_STACKPROTECTOR_STRONG) := -fstack-protector-strong 691stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG) := -fstack-protector-strong
692 692
693KBUILD_CFLAGS += $(stackp-flags-y) 693KBUILD_CFLAGS += $(stackp-flags-y)
694 694
diff --git a/arch/Kconfig b/arch/Kconfig
index ebbb45096191..c302b3dd0058 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -558,7 +558,7 @@ config HAVE_CC_STACKPROTECTOR
558config CC_HAS_STACKPROTECTOR_NONE 558config CC_HAS_STACKPROTECTOR_NONE
559 def_bool $(cc-option,-fno-stack-protector) 559 def_bool $(cc-option,-fno-stack-protector)
560 560
561config CC_STACKPROTECTOR 561config STACKPROTECTOR
562 bool "Stack Protector buffer overflow detection" 562 bool "Stack Protector buffer overflow detection"
563 depends on HAVE_CC_STACKPROTECTOR 563 depends on HAVE_CC_STACKPROTECTOR
564 depends on $(cc-option,-fstack-protector) 564 depends on $(cc-option,-fstack-protector)
@@ -582,9 +582,9 @@ config CC_STACKPROTECTOR
582 about 3% of all kernel functions, which increases kernel code size 582 about 3% of all kernel functions, which increases kernel code size
583 by about 0.3%. 583 by about 0.3%.
584 584
585config CC_STACKPROTECTOR_STRONG 585config STACKPROTECTOR_STRONG
586 bool "Strong Stack Protector" 586 bool "Strong Stack Protector"
587 depends on CC_STACKPROTECTOR 587 depends on STACKPROTECTOR
588 depends on $(cc-option,-fstack-protector-strong) 588 depends on $(cc-option,-fstack-protector-strong)
589 default y 589 default y
590 help 590 help
diff --git a/arch/arm/kernel/asm-offsets.c b/arch/arm/kernel/asm-offsets.c
index 27c5381518d8..974d8d7d1bcd 100644
--- a/arch/arm/kernel/asm-offsets.c
+++ b/arch/arm/kernel/asm-offsets.c
@@ -61,7 +61,7 @@
61int main(void) 61int main(void)
62{ 62{
63 DEFINE(TSK_ACTIVE_MM, offsetof(struct task_struct, active_mm)); 63 DEFINE(TSK_ACTIVE_MM, offsetof(struct task_struct, active_mm));
64#ifdef CONFIG_CC_STACKPROTECTOR 64#ifdef CONFIG_STACKPROTECTOR
65 DEFINE(TSK_STACK_CANARY, offsetof(struct task_struct, stack_canary)); 65 DEFINE(TSK_STACK_CANARY, offsetof(struct task_struct, stack_canary));
66#endif 66#endif
67 BLANK(); 67 BLANK();
diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
index 1752033b0070..179a9f6bd1e3 100644
--- a/arch/arm/kernel/entry-armv.S
+++ b/arch/arm/kernel/entry-armv.S
@@ -791,7 +791,7 @@ ENTRY(__switch_to)
791 ldr r6, [r2, #TI_CPU_DOMAIN] 791 ldr r6, [r2, #TI_CPU_DOMAIN]
792#endif 792#endif
793 switch_tls r1, r4, r5, r3, r7 793 switch_tls r1, r4, r5, r3, r7
794#if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP) 794#if defined(CONFIG_STACKPROTECTOR) && !defined(CONFIG_SMP)
795 ldr r7, [r2, #TI_TASK] 795 ldr r7, [r2, #TI_TASK]
796 ldr r8, =__stack_chk_guard 796 ldr r8, =__stack_chk_guard
797 .if (TSK_STACK_CANARY > IMM12_MASK) 797 .if (TSK_STACK_CANARY > IMM12_MASK)
@@ -807,7 +807,7 @@ ENTRY(__switch_to)
807 ldr r0, =thread_notify_head 807 ldr r0, =thread_notify_head
808 mov r1, #THREAD_NOTIFY_SWITCH 808 mov r1, #THREAD_NOTIFY_SWITCH
809 bl atomic_notifier_call_chain 809 bl atomic_notifier_call_chain
810#if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP) 810#if defined(CONFIG_STACKPROTECTOR) && !defined(CONFIG_SMP)
811 str r7, [r8] 811 str r7, [r8]
812#endif 812#endif
813 THUMB( mov ip, r4 ) 813 THUMB( mov ip, r4 )
diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index 1523cb18b109..225d1c58d2de 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -39,7 +39,7 @@
39#include <asm/tls.h> 39#include <asm/tls.h>
40#include <asm/vdso.h> 40#include <asm/vdso.h>
41 41
42#ifdef CONFIG_CC_STACKPROTECTOR 42#ifdef CONFIG_STACKPROTECTOR
43#include <linux/stackprotector.h> 43#include <linux/stackprotector.h>
44unsigned long __stack_chk_guard __read_mostly; 44unsigned long __stack_chk_guard __read_mostly;
45EXPORT_SYMBOL(__stack_chk_guard); 45EXPORT_SYMBOL(__stack_chk_guard);
diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
index f08a2ed9db0d..e10bc363f533 100644
--- a/arch/arm64/kernel/process.c
+++ b/arch/arm64/kernel/process.c
@@ -59,7 +59,7 @@
59#include <asm/processor.h> 59#include <asm/processor.h>
60#include <asm/stacktrace.h> 60#include <asm/stacktrace.h>
61 61
62#ifdef CONFIG_CC_STACKPROTECTOR 62#ifdef CONFIG_STACKPROTECTOR
63#include <linux/stackprotector.h> 63#include <linux/stackprotector.h>
64unsigned long __stack_chk_guard __read_mostly; 64unsigned long __stack_chk_guard __read_mostly;
65EXPORT_SYMBOL(__stack_chk_guard); 65EXPORT_SYMBOL(__stack_chk_guard);
diff --git a/arch/mips/kernel/asm-offsets.c b/arch/mips/kernel/asm-offsets.c
index c1cd41456d42..cbe4742d2fff 100644
--- a/arch/mips/kernel/asm-offsets.c
+++ b/arch/mips/kernel/asm-offsets.c
@@ -83,7 +83,7 @@ void output_task_defines(void)
83 OFFSET(TASK_FLAGS, task_struct, flags); 83 OFFSET(TASK_FLAGS, task_struct, flags);
84 OFFSET(TASK_MM, task_struct, mm); 84 OFFSET(TASK_MM, task_struct, mm);
85 OFFSET(TASK_PID, task_struct, pid); 85 OFFSET(TASK_PID, task_struct, pid);
86#if defined(CONFIG_CC_STACKPROTECTOR) 86#if defined(CONFIG_STACKPROTECTOR)
87 OFFSET(TASK_STACK_CANARY, task_struct, stack_canary); 87 OFFSET(TASK_STACK_CANARY, task_struct, stack_canary);
88#endif 88#endif
89 DEFINE(TASK_STRUCT_SIZE, sizeof(struct task_struct)); 89 DEFINE(TASK_STRUCT_SIZE, sizeof(struct task_struct));
diff --git a/arch/mips/kernel/octeon_switch.S b/arch/mips/kernel/octeon_switch.S
index e42113fe2762..896080b445c2 100644
--- a/arch/mips/kernel/octeon_switch.S
+++ b/arch/mips/kernel/octeon_switch.S
@@ -61,7 +61,7 @@
61#endif 61#endif
623: 623:
63 63
64#if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP) 64#if defined(CONFIG_STACKPROTECTOR) && !defined(CONFIG_SMP)
65 PTR_LA t8, __stack_chk_guard 65 PTR_LA t8, __stack_chk_guard
66 LONG_L t9, TASK_STACK_CANARY(a1) 66 LONG_L t9, TASK_STACK_CANARY(a1)
67 LONG_S t9, 0(t8) 67 LONG_S t9, 0(t8)
diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
index 3775a8d694fb..8d85046adcc8 100644
--- a/arch/mips/kernel/process.c
+++ b/arch/mips/kernel/process.c
@@ -180,7 +180,7 @@ int copy_thread_tls(unsigned long clone_flags, unsigned long usp,
180 return 0; 180 return 0;
181} 181}
182 182
183#ifdef CONFIG_CC_STACKPROTECTOR 183#ifdef CONFIG_STACKPROTECTOR
184#include <linux/stackprotector.h> 184#include <linux/stackprotector.h>
185unsigned long __stack_chk_guard __read_mostly; 185unsigned long __stack_chk_guard __read_mostly;
186EXPORT_SYMBOL(__stack_chk_guard); 186EXPORT_SYMBOL(__stack_chk_guard);
diff --git a/arch/mips/kernel/r2300_switch.S b/arch/mips/kernel/r2300_switch.S
index 665897139f30..71b1aafae1bb 100644
--- a/arch/mips/kernel/r2300_switch.S
+++ b/arch/mips/kernel/r2300_switch.S
@@ -36,7 +36,7 @@ LEAF(resume)
36 cpu_save_nonscratch a0 36 cpu_save_nonscratch a0
37 sw ra, THREAD_REG31(a0) 37 sw ra, THREAD_REG31(a0)
38 38
39#if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP) 39#if defined(CONFIG_STACKPROTECTOR) && !defined(CONFIG_SMP)
40 PTR_LA t8, __stack_chk_guard 40 PTR_LA t8, __stack_chk_guard
41 LONG_L t9, TASK_STACK_CANARY(a1) 41 LONG_L t9, TASK_STACK_CANARY(a1)
42 LONG_S t9, 0(t8) 42 LONG_S t9, 0(t8)
diff --git a/arch/mips/kernel/r4k_switch.S b/arch/mips/kernel/r4k_switch.S
index 17cf9341c1cf..58232ae6cfae 100644
--- a/arch/mips/kernel/r4k_switch.S
+++ b/arch/mips/kernel/r4k_switch.S
@@ -31,7 +31,7 @@
31 cpu_save_nonscratch a0 31 cpu_save_nonscratch a0
32 LONG_S ra, THREAD_REG31(a0) 32 LONG_S ra, THREAD_REG31(a0)
33 33
34#if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP) 34#if defined(CONFIG_STACKPROTECTOR) && !defined(CONFIG_SMP)
35 PTR_LA t8, __stack_chk_guard 35 PTR_LA t8, __stack_chk_guard
36 LONG_L t9, TASK_STACK_CANARY(a1) 36 LONG_L t9, TASK_STACK_CANARY(a1)
37 LONG_S t9, 0(t8) 37 LONG_S t9, 0(t8)
diff --git a/arch/sh/kernel/process.c b/arch/sh/kernel/process.c
index 68b1a67533ce..4d1bfc848dd3 100644
--- a/arch/sh/kernel/process.c
+++ b/arch/sh/kernel/process.c
@@ -12,7 +12,7 @@
12struct kmem_cache *task_xstate_cachep = NULL; 12struct kmem_cache *task_xstate_cachep = NULL;
13unsigned int xstate_size; 13unsigned int xstate_size;
14 14
15#ifdef CONFIG_CC_STACKPROTECTOR 15#ifdef CONFIG_STACKPROTECTOR
16unsigned long __stack_chk_guard __read_mostly; 16unsigned long __stack_chk_guard __read_mostly;
17EXPORT_SYMBOL(__stack_chk_guard); 17EXPORT_SYMBOL(__stack_chk_guard);
18#endif 18#endif
diff --git a/arch/sh/kernel/process_32.c b/arch/sh/kernel/process_32.c
index 93522069cb15..27fddb56b3e1 100644
--- a/arch/sh/kernel/process_32.c
+++ b/arch/sh/kernel/process_32.c
@@ -177,7 +177,7 @@ __switch_to(struct task_struct *prev, struct task_struct *next)
177{ 177{
178 struct thread_struct *next_t = &next->thread; 178 struct thread_struct *next_t = &next->thread;
179 179
180#if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP) 180#if defined(CONFIG_STACKPROTECTOR) && !defined(CONFIG_SMP)
181 __stack_chk_guard = next->stack_canary; 181 __stack_chk_guard = next->stack_canary;
182#endif 182#endif
183 183
diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S
index bef8e2b202a8..2582881d19ce 100644
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -239,7 +239,7 @@ ENTRY(__switch_to_asm)
239 movl %esp, TASK_threadsp(%eax) 239 movl %esp, TASK_threadsp(%eax)
240 movl TASK_threadsp(%edx), %esp 240 movl TASK_threadsp(%edx), %esp
241 241
242#ifdef CONFIG_CC_STACKPROTECTOR 242#ifdef CONFIG_STACKPROTECTOR
243 movl TASK_stack_canary(%edx), %ebx 243 movl TASK_stack_canary(%edx), %ebx
244 movl %ebx, PER_CPU_VAR(stack_canary)+stack_canary_offset 244 movl %ebx, PER_CPU_VAR(stack_canary)+stack_canary_offset
245#endif 245#endif
diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index 3166b9674429..73a522d53b53 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -357,7 +357,7 @@ ENTRY(__switch_to_asm)
357 movq %rsp, TASK_threadsp(%rdi) 357 movq %rsp, TASK_threadsp(%rdi)
358 movq TASK_threadsp(%rsi), %rsp 358 movq TASK_threadsp(%rsi), %rsp
359 359
360#ifdef CONFIG_CC_STACKPROTECTOR 360#ifdef CONFIG_STACKPROTECTOR
361 movq TASK_stack_canary(%rsi), %rbx 361 movq TASK_stack_canary(%rsi), %rbx
362 movq %rbx, PER_CPU_VAR(irq_stack_union)+stack_canary_offset 362 movq %rbx, PER_CPU_VAR(irq_stack_union)+stack_canary_offset
363#endif 363#endif
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index e28add6b791f..cfd29ee8c3da 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -412,7 +412,7 @@ extern asmlinkage void ignore_sysret(void);
412void save_fsgs_for_kvm(void); 412void save_fsgs_for_kvm(void);
413#endif 413#endif
414#else /* X86_64 */ 414#else /* X86_64 */
415#ifdef CONFIG_CC_STACKPROTECTOR 415#ifdef CONFIG_STACKPROTECTOR
416/* 416/*
417 * Make sure stack canary segment base is cached-aligned: 417 * Make sure stack canary segment base is cached-aligned:
418 * "For Intel Atom processors, avoid non zero segment base address 418 * "For Intel Atom processors, avoid non zero segment base address
diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
index 8f09012b92e7..e293c122d0d5 100644
--- a/arch/x86/include/asm/segment.h
+++ b/arch/x86/include/asm/segment.h
@@ -146,7 +146,7 @@
146# define __KERNEL_PERCPU 0 146# define __KERNEL_PERCPU 0
147#endif 147#endif
148 148
149#ifdef CONFIG_CC_STACKPROTECTOR 149#ifdef CONFIG_STACKPROTECTOR
150# define __KERNEL_STACK_CANARY (GDT_ENTRY_STACK_CANARY*8) 150# define __KERNEL_STACK_CANARY (GDT_ENTRY_STACK_CANARY*8)
151#else 151#else
152# define __KERNEL_STACK_CANARY 0 152# define __KERNEL_STACK_CANARY 0
diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
index 371b3a4af000..8ec97a62c245 100644
--- a/arch/x86/include/asm/stackprotector.h
+++ b/arch/x86/include/asm/stackprotector.h
@@ -34,7 +34,7 @@
34#ifndef _ASM_STACKPROTECTOR_H 34#ifndef _ASM_STACKPROTECTOR_H
35#define _ASM_STACKPROTECTOR_H 1 35#define _ASM_STACKPROTECTOR_H 1
36 36
37#ifdef CONFIG_CC_STACKPROTECTOR 37#ifdef CONFIG_STACKPROTECTOR
38 38
39#include <asm/tsc.h> 39#include <asm/tsc.h>
40#include <asm/processor.h> 40#include <asm/processor.h>
@@ -105,7 +105,7 @@ static inline void load_stack_canary_segment(void)
105#endif 105#endif
106} 106}
107 107
108#else /* CC_STACKPROTECTOR */ 108#else /* STACKPROTECTOR */
109 109
110#define GDT_STACK_CANARY_INIT 110#define GDT_STACK_CANARY_INIT
111 111
@@ -121,5 +121,5 @@ static inline void load_stack_canary_segment(void)
121#endif 121#endif
122} 122}
123 123
124#endif /* CC_STACKPROTECTOR */ 124#endif /* STACKPROTECTOR */
125#endif /* _ASM_STACKPROTECTOR_H */ 125#endif /* _ASM_STACKPROTECTOR_H */
diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
index 76417a9aab73..dcb008c320fe 100644
--- a/arch/x86/kernel/asm-offsets.c
+++ b/arch/x86/kernel/asm-offsets.c
@@ -32,7 +32,7 @@
32void common(void) { 32void common(void) {
33 BLANK(); 33 BLANK();
34 OFFSET(TASK_threadsp, task_struct, thread.sp); 34 OFFSET(TASK_threadsp, task_struct, thread.sp);
35#ifdef CONFIG_CC_STACKPROTECTOR 35#ifdef CONFIG_STACKPROTECTOR
36 OFFSET(TASK_stack_canary, task_struct, stack_canary); 36 OFFSET(TASK_stack_canary, task_struct, stack_canary);
37#endif 37#endif
38 38
diff --git a/arch/x86/kernel/asm-offsets_32.c b/arch/x86/kernel/asm-offsets_32.c
index f91ba53e06c8..a4a3be399f4b 100644
--- a/arch/x86/kernel/asm-offsets_32.c
+++ b/arch/x86/kernel/asm-offsets_32.c
@@ -50,7 +50,7 @@ void foo(void)
50 DEFINE(TSS_sysenter_sp0, offsetof(struct cpu_entry_area, tss.x86_tss.sp0) - 50 DEFINE(TSS_sysenter_sp0, offsetof(struct cpu_entry_area, tss.x86_tss.sp0) -
51 offsetofend(struct cpu_entry_area, entry_stack_page.stack)); 51 offsetofend(struct cpu_entry_area, entry_stack_page.stack));
52 52
53#ifdef CONFIG_CC_STACKPROTECTOR 53#ifdef CONFIG_STACKPROTECTOR
54 BLANK(); 54 BLANK();
55 OFFSET(stack_canary_offset, stack_canary, canary); 55 OFFSET(stack_canary_offset, stack_canary, canary);
56#endif 56#endif
diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
index bf51e51d808d..b2dcd161f514 100644
--- a/arch/x86/kernel/asm-offsets_64.c
+++ b/arch/x86/kernel/asm-offsets_64.c
@@ -69,7 +69,7 @@ int main(void)
69 OFFSET(TSS_sp1, tss_struct, x86_tss.sp1); 69 OFFSET(TSS_sp1, tss_struct, x86_tss.sp1);
70 BLANK(); 70 BLANK();
71 71
72#ifdef CONFIG_CC_STACKPROTECTOR 72#ifdef CONFIG_STACKPROTECTOR
73 DEFINE(stack_canary_offset, offsetof(union irq_stack_union, stack_canary)); 73 DEFINE(stack_canary_offset, offsetof(union irq_stack_union, stack_canary));
74 BLANK(); 74 BLANK();
75#endif 75#endif
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 910b47ee8078..0df7151cfef4 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1599,7 +1599,7 @@ DEFINE_PER_CPU(unsigned long, cpu_current_top_of_stack) =
1599 (unsigned long)&init_thread_union + THREAD_SIZE; 1599 (unsigned long)&init_thread_union + THREAD_SIZE;
1600EXPORT_PER_CPU_SYMBOL(cpu_current_top_of_stack); 1600EXPORT_PER_CPU_SYMBOL(cpu_current_top_of_stack);
1601 1601
1602#ifdef CONFIG_CC_STACKPROTECTOR 1602#ifdef CONFIG_STACKPROTECTOR
1603DEFINE_PER_CPU_ALIGNED(struct stack_canary, stack_canary); 1603DEFINE_PER_CPU_ALIGNED(struct stack_canary, stack_canary);
1604#endif 1604#endif
1605 1605
diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
index b59e4fb40fd9..abe6df15a8fb 100644
--- a/arch/x86/kernel/head_32.S
+++ b/arch/x86/kernel/head_32.S
@@ -375,7 +375,7 @@ ENDPROC(startup_32_smp)
375 */ 375 */
376__INIT 376__INIT
377setup_once: 377setup_once:
378#ifdef CONFIG_CC_STACKPROTECTOR 378#ifdef CONFIG_STACKPROTECTOR
379 /* 379 /*
380 * Configure the stack canary. The linker can't handle this by 380 * Configure the stack canary. The linker can't handle this by
381 * relocation. Manually set base address in stack canary 381 * relocation. Manually set base address in stack canary
diff --git a/arch/xtensa/kernel/asm-offsets.c b/arch/xtensa/kernel/asm-offsets.c
index 022cf918ec20..67904f55f188 100644
--- a/arch/xtensa/kernel/asm-offsets.c
+++ b/arch/xtensa/kernel/asm-offsets.c
@@ -76,7 +76,7 @@ int main(void)
76 DEFINE(TASK_PID, offsetof (struct task_struct, pid)); 76 DEFINE(TASK_PID, offsetof (struct task_struct, pid));
77 DEFINE(TASK_THREAD, offsetof (struct task_struct, thread)); 77 DEFINE(TASK_THREAD, offsetof (struct task_struct, thread));
78 DEFINE(TASK_THREAD_INFO, offsetof (struct task_struct, stack)); 78 DEFINE(TASK_THREAD_INFO, offsetof (struct task_struct, stack));
79#ifdef CONFIG_CC_STACKPROTECTOR 79#ifdef CONFIG_STACKPROTECTOR
80 DEFINE(TASK_STACK_CANARY, offsetof(struct task_struct, stack_canary)); 80 DEFINE(TASK_STACK_CANARY, offsetof(struct task_struct, stack_canary));
81#endif 81#endif
82 DEFINE(TASK_STRUCT_SIZE, sizeof (struct task_struct)); 82 DEFINE(TASK_STRUCT_SIZE, sizeof (struct task_struct));
diff --git a/arch/xtensa/kernel/entry.S b/arch/xtensa/kernel/entry.S
index 5caff0744f3c..9cbc380e9572 100644
--- a/arch/xtensa/kernel/entry.S
+++ b/arch/xtensa/kernel/entry.S
@@ -1971,7 +1971,7 @@ ENTRY(_switch_to)
1971 s32i a1, a2, THREAD_SP # save stack pointer 1971 s32i a1, a2, THREAD_SP # save stack pointer
1972#endif 1972#endif
1973 1973
1974#if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP) 1974#if defined(CONFIG_STACKPROTECTOR) && !defined(CONFIG_SMP)
1975 movi a6, __stack_chk_guard 1975 movi a6, __stack_chk_guard
1976 l32i a8, a3, TASK_STACK_CANARY 1976 l32i a8, a3, TASK_STACK_CANARY
1977 s32i a8, a6, 0 1977 s32i a8, a6, 0
diff --git a/arch/xtensa/kernel/process.c b/arch/xtensa/kernel/process.c
index 8dd0593fb2c4..483dcfb6e681 100644
--- a/arch/xtensa/kernel/process.c
+++ b/arch/xtensa/kernel/process.c
@@ -58,7 +58,7 @@ void (*pm_power_off)(void) = NULL;
58EXPORT_SYMBOL(pm_power_off); 58EXPORT_SYMBOL(pm_power_off);
59 59
60 60
61#ifdef CONFIG_CC_STACKPROTECTOR 61#ifdef CONFIG_STACKPROTECTOR
62#include <linux/stackprotector.h> 62#include <linux/stackprotector.h>
63unsigned long __stack_chk_guard __read_mostly; 63unsigned long __stack_chk_guard __read_mostly;
64EXPORT_SYMBOL(__stack_chk_guard); 64EXPORT_SYMBOL(__stack_chk_guard);
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 16e4d984fe51..cfb7da88c217 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -742,7 +742,7 @@ struct task_struct {
742 pid_t pid; 742 pid_t pid;
743 pid_t tgid; 743 pid_t tgid;
744 744
745#ifdef CONFIG_CC_STACKPROTECTOR 745#ifdef CONFIG_STACKPROTECTOR
746 /* Canary value for the -fstack-protector GCC feature: */ 746 /* Canary value for the -fstack-protector GCC feature: */
747 unsigned long stack_canary; 747 unsigned long stack_canary;
748#endif 748#endif
diff --git a/include/linux/stackprotector.h b/include/linux/stackprotector.h
index 03696c729fb4..6b792d080eee 100644
--- a/include/linux/stackprotector.h
+++ b/include/linux/stackprotector.h
@@ -6,7 +6,7 @@
6#include <linux/sched.h> 6#include <linux/sched.h>
7#include <linux/random.h> 7#include <linux/random.h>
8 8
9#ifdef CONFIG_CC_STACKPROTECTOR 9#ifdef CONFIG_STACKPROTECTOR
10# include <asm/stackprotector.h> 10# include <asm/stackprotector.h>
11#else 11#else
12static inline void boot_init_stack_canary(void) 12static inline void boot_init_stack_canary(void)
diff --git a/kernel/configs/android-recommended.config b/kernel/configs/android-recommended.config
index 946fb92418f7..81e9af7dcec2 100644
--- a/kernel/configs/android-recommended.config
+++ b/kernel/configs/android-recommended.config
@@ -12,7 +12,7 @@ CONFIG_BLK_DEV_DM=y
12CONFIG_BLK_DEV_LOOP=y 12CONFIG_BLK_DEV_LOOP=y
13CONFIG_BLK_DEV_RAM=y 13CONFIG_BLK_DEV_RAM=y
14CONFIG_BLK_DEV_RAM_SIZE=8192 14CONFIG_BLK_DEV_RAM_SIZE=8192
15CONFIG_CC_STACKPROTECTOR_STRONG=y 15CONFIG_STACKPROTECTOR_STRONG=y
16CONFIG_COMPACTION=y 16CONFIG_COMPACTION=y
17CONFIG_CPU_SW_DOMAIN_PAN=y 17CONFIG_CPU_SW_DOMAIN_PAN=y
18CONFIG_DM_CRYPT=y 18CONFIG_DM_CRYPT=y
diff --git a/kernel/fork.c b/kernel/fork.c
index 08c6e5e217a0..92870be50bba 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -811,7 +811,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig, int node)
811 clear_tsk_need_resched(tsk); 811 clear_tsk_need_resched(tsk);
812 set_task_stack_end_magic(tsk); 812 set_task_stack_end_magic(tsk);
813 813
814#ifdef CONFIG_CC_STACKPROTECTOR 814#ifdef CONFIG_STACKPROTECTOR
815 tsk->stack_canary = get_random_canary(); 815 tsk->stack_canary = get_random_canary();
816#endif 816#endif
817 817
diff --git a/kernel/panic.c b/kernel/panic.c
index 42e487488554..8b2e002d52eb 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -623,7 +623,7 @@ static __init int register_warn_debugfs(void)
623device_initcall(register_warn_debugfs); 623device_initcall(register_warn_debugfs);
624#endif 624#endif
625 625
626#ifdef CONFIG_CC_STACKPROTECTOR 626#ifdef CONFIG_STACKPROTECTOR
627 627
628/* 628/*
629 * Called when gcc's -fstack-protector feature is used, and 629 * Called when gcc's -fstack-protector feature is used, and