Commit 893ab004 authored by Masahiro Yamada's avatar Masahiro Yamada
Browse files

kbuild: remove cc-option test of -fno-stack-protector

Some Makefiles already pass -fno-stack-protector unconditionally.
For example, arch/arm64/kernel/vdso/Makefile, arch/x86/xen/Makefile.

No problem report so far about hard-coding this option. So, we can
assume all supported compilers know -fno-stack-protector.

GCC 4.8 and Clang support this option (https://godbolt.org/z/_HDGzN

)

Get rid of cc-option from -fno-stack-protector.

Remove CONFIG_CC_HAS_STACKPROTECTOR_NONE, which is always 'y'.

Note:
arch/mips/vdso/Makefile adds -fno-stack-protector twice, first
unconditionally, and second conditionally. I removed the second one.

Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
Reviewed-by: default avatarKees Cook <keescook@chromium.org>
Acked-by: default avatarArd Biesheuvel <ardb@kernel.org>
Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
parent dd7699e3
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -540,8 +540,8 @@ followed by a test macro::
If you need to expose a compiler capability to makefiles and/or C source files,
`CC_HAS_` is the recommended prefix for the config option::

  config CC_HAS_STACKPROTECTOR_NONE
	def_bool $(cc-option,-fno-stack-protector)
  config CC_HAS_ASM_GOTO
	def_bool $(success,$(srctree)/scripts/gcc-goto.sh $(CC))

Build as module only
~~~~~~~~~~~~~~~~~~~~
+1 −1
Original line number Diff line number Diff line
@@ -762,7 +762,7 @@ ifneq ($(CONFIG_FRAME_WARN),0)
KBUILD_CFLAGS += -Wframe-larger-than=$(CONFIG_FRAME_WARN)
endif

stackp-flags-$(CONFIG_CC_HAS_STACKPROTECTOR_NONE) := -fno-stack-protector
stackp-flags-y                                    := -fno-stack-protector
stackp-flags-$(CONFIG_STACKPROTECTOR)             := -fstack-protector
stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG)      := -fstack-protector-strong

+0 −3
Original line number Diff line number Diff line
@@ -478,9 +478,6 @@ config HAVE_STACKPROTECTOR
	  An arch should select this symbol if:
	  - it has implemented a stack canary (e.g. __stack_chk_guard)

config CC_HAS_STACKPROTECTOR_NONE
	def_bool $(cc-option,-fno-stack-protector)

config STACKPROTECTOR
	bool "Stack Protector buffer overflow detection"
	depends on HAVE_STACKPROTECTOR
+1 −2
Original line number Diff line number Diff line
@@ -84,9 +84,8 @@ endif

# -fstack-protector-strong triggers protection checks in this code,
# but it is being used too early to link to meaningful stack_chk logic.
nossp-flags-$(CONFIG_CC_HAS_STACKPROTECTOR_NONE) := -fno-stack-protector
$(foreach o, $(libfdt_objs) atags_to_fdt.o, \
	$(eval CFLAGS_$(o) := -I $(srctree)/scripts/dtc/libfdt $(nossp-flags-y)))
	$(eval CFLAGS_$(o) := -I $(srctree)/scripts/dtc/libfdt -fno-stack-protector))

# These were previously generated C files. When you are building the kernel
# with O=, make sure to remove the stale files in the output tree. Otherwise,
+1 −2
Original line number Diff line number Diff line
@@ -35,8 +35,7 @@ cflags-vdso := $(ccflags-vdso) \
	-O3 -g -fPIC -fno-strict-aliasing -fno-common -fno-builtin -G 0 \
	-mrelax-pic-calls $(call cc-option, -mexplicit-relocs) \
	-fno-stack-protector -fno-jump-tables -DDISABLE_BRANCH_PROFILING \
	$(call cc-option, -fno-asynchronous-unwind-tables) \
	$(call cc-option, -fno-stack-protector)
	$(call cc-option, -fno-asynchronous-unwind-tables)
aflags-vdso := $(ccflags-vdso) \
	-D__ASSEMBLY__ -Wa,-gdwarf-2

Loading