ARM: fix atags_to_fdt with stack-protector-strong
PATCH v3 1/1 ARM: fix atags_to_fdt with stack-protector-strong
Building with CONFIG_CC_STACKPROTECTOR_STRONG triggers protection code generation under CONFIG_ARM_ATAG_DTB_COMPAT but this is too early for being able to use any of the stack_chk code. Explicitly disable it for only the atags_to_fdt bits.
---
v3:
- actually send to everyone correctly
v2:
- use call cc-option unconditionally, arnd
--- arch/arm/boot/compressed/Makefile | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/arm/boot/compressed/Makefile +8 -0
@@ -106,6 +106,14 @@ ORIG_CFLAGS := $(KBUILD_CFLAGS) KBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS)) endif +# -fstack-protector-strong triggers protection checks in this code, +# but it is being used too early to link to meaningful stack_chk logic. +CFLAGS_atags_to_fdt.o := $(call cc-option, -fno-stack-protector) +CFLAGS_fdt.o := $(call cc-option, -fno-stack-protector) +CFLAGS_fdt_ro.o := $(call cc-option, -fno-stack-protector) +CFLAGS_fdt_rw.o := $(call cc-option, -fno-stack-protector) +CFLAGS_fdt_wip.o := $(call cc-option, -fno-stack-protector) + ccflags-y := -fpic -mno-single-pic-base -fno-builtin -I$(obj) asflags-y := -DZIMAGE
Signature · 6 lines
2.6.3 -- Kees Cook Chrome OS & Brillo Security
Quoted 8 lines · On Wednesday 06 January 2016 15:36:56 Kees Cook wrote:
Building with
CONFIG_CC_STACKPROTECTOR_STRONGtriggers protection code generation underCONFIG_ARM_ATAG_DTB_COMPATbut this is too early for being able to use any of thestack_chkcode. Explicitly disable it for only theatags_to_fdtbits.Suggested-by zhxihu <[email protected]>Signed-off-by Kees Cook <[email protected]>
Quoted 5 lines · Kees Cook
arch/arm/boot/compressed/Makefile +0
-0
arch/arm/boot/compressed/Makefile ORIG_CFLAGS := $(KBUILD_CFLAGS) · line 115
Quoted 10 lines
arch/arm/boot/compressed/Makefile +7
-0@@ -106,6 +106,14 @@ ORIG_CFLAGS := $(KBUILD_CFLAGS) KBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS)) endif +# -fstack-protector-strong triggers protection checks in this code, +# but it is being used too early to link to meaningful stack_chk logic. +CFLAGS_atags_to_fdt.o := $(call cc-option, -fno-stack-protector) +CFLAGS_fdt.o := $(call cc-option, -fno-stack-protector) +CFLAGS_fdt_ro.o := $(call cc-option, -fno-stack-protector) +CFLAGS_fdt_rw.o := $(call cc-option, -fno-stack-protector) +CFLAGS_fdt_wip.o := $(call cc-option, -fno-stack-protector)
This will result in "$(call cc-option, -fno-stack-protector)" being called five times when this Makefile is parsed, which seems very wasteful. I'm sure there's better solutions to that - maybe caching the value in a variable in a higher level makefile (eg, arch/arm/Makefile) ?
Also, I suspect that all of the decompressor should be built with -fno-stack-protector as we don't have sufficient environment here. Maybe it should be placed in the global CFLAGS for the decompressor?
Signature · 3 lines
RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/ FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net.
Quoted 9 lines · Russell King - ARM Linux
Quoted 8 lines · Kees Cook
arch/arm/boot/compressed/Makefile +0
-0@@ -106,6 +106,14 @@ ORIG_CFLAGS := $(KBUILD_CFLAGS) KBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS)) endif
Quoted 13 lines
arch/arm/boot/compressed/Makefile ORIG_CFLAGS := $(KBUILD_CFLAGS) · line 115
Quoted 7 lines
arch/arm/boot/compressed/Makefile +7
-0+# -fstack-protector-strong triggers protection checks in this code, +# but it is being used too early to link to meaningful stack_chk logic. +CFLAGS_atags_to_fdt.o := $(call cc-option, -fno-stack-protector) +CFLAGS_fdt.o := $(call cc-option, -fno-stack-protector) +CFLAGS_fdt_ro.o := $(call cc-option, -fno-stack-protector) +CFLAGS_fdt_rw.o := $(call cc-option, -fno-stack-protector) +CFLAGS_fdt_wip.o := $(call cc-option, -fno-stack-protector)This will result in "$(call cc-option, -fno-stack-protector)" being called five times when this
Makefileis parsed, which seems very wasteful. I'm sure there's better solutions to that - maybe caching the value in a variable in a higher level makefile (eg,arch/arm/Makefile) ?
Good point; I will adjust this to get a single invocation.
Quoted 3 lines
Also, I suspect that all of the decompressor should be built with -fno-stack-protector as we don't have sufficient environment here. Maybe it should be placed in the global CFLAGS for the decompressor?
I prefer keeping it disabled in as narrow a range as possible. If other code gains a level of complexity that it triggers the stack protector code insertion, I think that's worth examining when it happens. If this ever becomes an actual burden, then yeah, let's do it for the whole decompressor, but I think it'd be best to revisit it if it happens again.
-Kees
Signature · 2 lines
Kees Cook Chrome OS & Brillo Security
Hi Kees,
Quoted 10 lines · Kees Cook
Quoted 3 lines
Also, I suspect that all of the decompressor should be built with -fno-stack-protector as we don't have sufficient environment here. Maybe it should be placed in the global CFLAGS for the decompressor?
I prefer keeping it disabled in as narrow a range as possible. If other code gains a level of complexity that it triggers the stack protector code insertion, I think that's worth examining when it happens. If this ever becomes an actual burden, then yeah, let's do it for the whole decompressor, but I think it'd be best to revisit it if it happens again.
What's the failure mode if the stack protector code insertion is triggered?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Quoted 7 lines · Geert Uytterhoeven
Hi Kees,
Quoted 4 lines · Kees Cook
Quoted 3 lines
Also, I suspect that all of the decompressor should be built with -fno-stack-protector as we don't have sufficient environment here. Maybe it should be placed in the global CFLAGS for the decompressor?
Quoted 8 lines
Quoted 6 lines
I prefer keeping it disabled in as narrow a range as possible. If other code gains a level of complexity that it triggers the stack protector code insertion, I think that's worth examining when it happens. If this ever becomes an actual burden, then yeah, let's do it for the whole decompressor, but I think it'd be best to revisit it if it happens again.
What's the failure mode if the stack protector code insertion is triggered?
AIUI, this code shouldn't even link if the ssp code gets inserted since it can't resolve __stack_chk_fail.
-Kees
Signature · 2 lines
Kees Cook Chrome OS & Brillo Security