Skip to content

Commit 050e9ba

Browse files
committed
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 <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent be779f0 commit 050e9ba

33 files changed

+39
-39
lines changed

Documentation/kbuild/kconfig-language.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ There are several features that need compiler support. The recommended way
480480
to describe the dependency on the compiler feature is to use "depends on"
481481
followed by a test macro.
482482

483-
config CC_STACKPROTECTOR
483+
config STACKPROTECTOR
484484
bool "Stack Protector buffer overflow detection"
485485
depends on $(cc-option,-fstack-protector)
486486
...

Documentation/security/self-protection.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ The classic stack buffer overflow involves writing past the expected end
156156
of a variable stored on the stack, ultimately writing a controlled value
157157
to the stack frame's stored return address. The most widely used defense
158158
is the presence of a stack canary between the stack variables and the
159-
return address (``CONFIG_CC_STACKPROTECTOR``), which is verified just before
159+
return address (``CONFIG_STACKPROTECTOR``), which is verified just before
160160
the function returns. Other defenses include things like shadow stacks.
161161

162162
Stack depth overflow

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -687,8 +687,8 @@ KBUILD_CFLAGS += $(call cc-option,-Wframe-larger-than=${CONFIG_FRAME_WARN})
687687
endif
688688

689689
stackp-flags-$(CONFIG_CC_HAS_STACKPROTECTOR_NONE) := -fno-stack-protector
690-
stackp-flags-$(CONFIG_CC_STACKPROTECTOR) := -fstack-protector
691-
stackp-flags-$(CONFIG_CC_STACKPROTECTOR_STRONG) := -fstack-protector-strong
690+
stackp-flags-$(CONFIG_STACKPROTECTOR) := -fstack-protector
691+
stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG) := -fstack-protector-strong
692692

693693
KBUILD_CFLAGS += $(stackp-flags-y)
694694

arch/Kconfig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ config HAVE_CC_STACKPROTECTOR
558558
config CC_HAS_STACKPROTECTOR_NONE
559559
def_bool $(cc-option,-fno-stack-protector)
560560

561-
config CC_STACKPROTECTOR
561+
config STACKPROTECTOR
562562
bool "Stack Protector buffer overflow detection"
563563
depends on HAVE_CC_STACKPROTECTOR
564564
depends on $(cc-option,-fstack-protector)
@@ -582,9 +582,9 @@ config CC_STACKPROTECTOR
582582
about 3% of all kernel functions, which increases kernel code size
583583
by about 0.3%.
584584

585-
config CC_STACKPROTECTOR_STRONG
585+
config STACKPROTECTOR_STRONG
586586
bool "Strong Stack Protector"
587-
depends on CC_STACKPROTECTOR
587+
depends on STACKPROTECTOR
588588
depends on $(cc-option,-fstack-protector-strong)
589589
default y
590590
help

arch/arm/kernel/asm-offsets.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
int main(void)
6262
{
6363
DEFINE(TSK_ACTIVE_MM, offsetof(struct task_struct, active_mm));
64-
#ifdef CONFIG_CC_STACKPROTECTOR
64+
#ifdef CONFIG_STACKPROTECTOR
6565
DEFINE(TSK_STACK_CANARY, offsetof(struct task_struct, stack_canary));
6666
#endif
6767
BLANK();

arch/arm/kernel/entry-armv.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ ENTRY(__switch_to)
791791
ldr r6, [r2, #TI_CPU_DOMAIN]
792792
#endif
793793
switch_tls r1, r4, r5, r3, r7
794-
#if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP)
794+
#if defined(CONFIG_STACKPROTECTOR) && !defined(CONFIG_SMP)
795795
ldr r7, [r2, #TI_TASK]
796796
ldr r8, =__stack_chk_guard
797797
.if (TSK_STACK_CANARY > IMM12_MASK)
@@ -807,7 +807,7 @@ ENTRY(__switch_to)
807807
ldr r0, =thread_notify_head
808808
mov r1, #THREAD_NOTIFY_SWITCH
809809
bl atomic_notifier_call_chain
810-
#if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP)
810+
#if defined(CONFIG_STACKPROTECTOR) && !defined(CONFIG_SMP)
811811
str r7, [r8]
812812
#endif
813813
THUMB( mov ip, r4 )

arch/arm/kernel/process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#include <asm/tls.h>
4040
#include <asm/vdso.h>
4141

42-
#ifdef CONFIG_CC_STACKPROTECTOR
42+
#ifdef CONFIG_STACKPROTECTOR
4343
#include <linux/stackprotector.h>
4444
unsigned long __stack_chk_guard __read_mostly;
4545
EXPORT_SYMBOL(__stack_chk_guard);

arch/arm64/kernel/process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
#include <asm/processor.h>
6060
#include <asm/stacktrace.h>
6161

62-
#ifdef CONFIG_CC_STACKPROTECTOR
62+
#ifdef CONFIG_STACKPROTECTOR
6363
#include <linux/stackprotector.h>
6464
unsigned long __stack_chk_guard __read_mostly;
6565
EXPORT_SYMBOL(__stack_chk_guard);

arch/mips/kernel/asm-offsets.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ void output_task_defines(void)
8383
OFFSET(TASK_FLAGS, task_struct, flags);
8484
OFFSET(TASK_MM, task_struct, mm);
8585
OFFSET(TASK_PID, task_struct, pid);
86-
#if defined(CONFIG_CC_STACKPROTECTOR)
86+
#if defined(CONFIG_STACKPROTECTOR)
8787
OFFSET(TASK_STACK_CANARY, task_struct, stack_canary);
8888
#endif
8989
DEFINE(TASK_STRUCT_SIZE, sizeof(struct task_struct));

arch/mips/kernel/octeon_switch.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
#endif
6262
3:
6363

64-
#if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP)
64+
#if defined(CONFIG_STACKPROTECTOR) && !defined(CONFIG_SMP)
6565
PTR_LA t8, __stack_chk_guard
6666
LONG_L t9, TASK_STACK_CANARY(a1)
6767
LONG_S t9, 0(t8)

0 commit comments

Comments
 (0)