From e06b8b98da071f7dd78fb7822991694288047df0 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Wed, 13 Feb 2008 22:43:28 +0100 Subject: kbuild: allow -fstack-protector to take effect Arjan van de Ven wrote: === I just read the excellent LWN writeup of the vmsplice security thing, and that got me wondering why this attack wasn't stopped by the CONFIG_CC_STACKPROTECTOR option... because it plain should have been... Some analysis later.. it turns out that the following line in the top level Makefile, added by you in October 2007, entirely disables CONFIG_CC_STACKPROTECTOR ;( With this line removed the exploit will be nicely stopped. CFLAGS += $(call cc-option, -fno-stack-protector) Now I realize that certain distros have patched gcc to compensate for their lack of distro wide CFLAGS, and it's great to work around that... but would there be a way to NOT disable this for CONFIG_CC_STACKPROTECTOR please? It would have made this exploit not possible for those kernels that enable this feature (and that includes distros like Fedora) === Move the assignment to KBUILD_CFLAGS up before including the arch specific Makefile so arch makefiles may override the setting. Signed-off-by: Sam Ravnborg Cc: Arjan van de Ven Cc: stable@kernel.org --- Makefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index c162370c736..d7386518837 100644 --- a/Makefile +++ b/Makefile @@ -507,6 +507,10 @@ else KBUILD_CFLAGS += -O2 endif +# Force gcc to behave correct even for buggy distributions +# Arch Makefiles may override this setting +KBUILD_CFLAGS += $(call cc-option, -fno-stack-protector) + include $(srctree)/arch/$(SRCARCH)/Makefile ifdef CONFIG_FRAME_POINTER @@ -525,9 +529,6 @@ ifdef CONFIG_DEBUG_SECTION_MISMATCH KBUILD_CFLAGS += $(call cc-option, -fno-inline-functions-called-once) endif -# Force gcc to behave correct even for buggy distributions -KBUILD_CFLAGS += $(call cc-option, -fno-stack-protector) - # arch Makefile may override CC so keep this after arch Makefile is included NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) CHECKFLAGS += $(NOSTDINC_FLAGS) -- cgit v1.2.3 From cf87dcd14064e7660f2b11b35b9e4949e9812fd2 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Wed, 13 Feb 2008 22:50:24 +0100 Subject: kbuild: fix building vmlinux.o Ingo Molnar wrote: > > i've got a build log from a weird build error below: > > LD init/built-in.o > distcc[12023] ERROR: compile (null) on localhost failed > make: *** [vmlinux.o] Error 1 > make: *** Waiting for unfinished jobs.... > LD .tmp_vmlinux1 > Building vmlinux.o were moved up in the dependency chain so we started to build it before the kallsym stuff. This was done to let modpost report section mismatch bugs even when the final link failed. Originally I had expected the dependency of $(kallsyms.o) to cover this but it turns out that we need to be even more explicit. Fix this by adding a conditional dependency on firat target used in the kallsyms serie of builds. Signed-off-by: Sam Ravnborg Cc: Ingo Molnar Cc: Roland McGrath --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index d7386518837..0d585c09d60 100644 --- a/Makefile +++ b/Makefile @@ -811,7 +811,9 @@ endif $(Q)rm -f .old_version # build vmlinux.o first to catch section mismatch errors early -$(kallsyms.o): vmlinux.o +ifdef CONFIG_KALLSYMS +.tmp_vmlinux1: vmlinux.o +endif vmlinux.o: $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) FORCE $(call if_changed_rule,vmlinux-modpost) -- cgit v1.2.3