Skip to contentSkip to conversation

purgatory: Disabling GCC's stack protection

PATCH In review Kevin Hao 2 participants 4 messages Apr 28, 2015 – Apr 30, 2015

Subsystems (2)
lore
Share & tools
lore

Kevin Hao

author
#0 lore raw

PATCH 1/1 purgatory: Disabling GCC's stack protection

If the GCC's stack protection is enabled by default, the purgatory will also be built with this option. But it makes no sense to enable this for the purgatory code, and would cause error when we are trying to relocate the purgatory codes because symbol like __stack_chk_fail is unresolved. Instead of disabling this for some archs specifically, disable it for all the archs.

---
 purgatory/Makefile            | 3 ++-
 purgatory/arch/ppc64/Makefile | 2 +-
 purgatory/arch/s390/Makefile  | 1 -
 3 files changed, 3 insertions(+), 3 deletions(-)
purgatory/Makefile +2 -1
index 19457029e79f..a25b2626be4d 100644
@@ -47,7 +47,8 @@ purgatory/sha256.o: $(srcdir)/util_lib/sha256.c
 $(PURGATORY): CC=$(TARGET_CC)
 $(PURGATORY): CFLAGS+=$(PURGATORY_EXTRA_CFLAGS) \
 		      $($(ARCH)_PURGATORY_EXTRA_CFLAGS) \
-		      -Os -fno-builtin -ffreestanding
+		      -Os -fno-builtin -ffreestanding \
+		      -fno-stack-protector
 
 $(PURGATORY): CPPFLAGS=$($(ARCH)_PURGATORY_EXTRA_CFLAGS) \
 			-I$(srcdir)/purgatory/include \
purgatory/arch/ppc64/Makefile +1 -1
index 712e2b194bee..31076e91c281 100644
@@ -9,7 +9,7 @@ ppc64_PURGATORY_SRCS += purgatory/arch/ppc64/console-ppc64.c
 ppc64_PURGATORY_SRCS += purgatory/arch/ppc64/crashdump_backup.c
 ppc64_PURGATORY_SRCS += purgatory/arch/ppc64/misc.S
 
-ppc64_PURGATORY_EXTRA_CFLAGS += -m64 -msoft-float -fno-stack-protector
+ppc64_PURGATORY_EXTRA_CFLAGS += -m64 -msoft-float
 ppc64_PURGATORY_EXTRA_ASFLAGS += -m64
 ifeq ($(SUBARCH),BE)
 	ppc64_PURGATORY_EXTRA_LDFLAGS += -melf64ppc
purgatory/arch/s390/Makefile +0 -1
index 09749bd51a7f..c94cc3cec9eb 100644
@@ -2,7 +2,6 @@
 # Purgatory s390
 #
 
-s390_PURGATORY_EXTRA_CFLAGS += -fno-stack-protector
 s390_PURGATORY_SRCS += purgatory/arch/s390/console-s390.c
 s390_PURGATORY_SRCS += purgatory/arch/s390/setup-s390.S
 s390_PURGATORY_SRCS += purgatory/arch/s390/purgatory-s390.c
Signature · 7 lines
2.1.0


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#1 lore raw

Hi Kevin,

Quoted 8 lines · Kevin Hao

If the GCC's stack protection is enabled by default, the purgatory will also be built with this option. But it makes no sense to enable this for the purgatory code, and would cause error when we are trying to relocate the purgatory codes because symbol like __stack_chk_fail is unresolved. Instead of disabling this for some archs specifically, disable it for all the archs.

This seems like a reasonable change to me, however, it does not apply cleanly to the kexec tree on kernel.org which I maintain.

https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git

Could you rebase and repost?

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#2 lore raw
Quoted 10 lines · Simon Horman

Hi Kevin,

Quoted 7 lines · Kevin Hao

If the GCC's stack protection is enabled by default, the purgatory will also be built with this option. But it makes no sense to enable this for the purgatory code, and would cause error when we are trying to relocate the purgatory codes because symbol like __stack_chk_fail is unresolved. Instead of disabling this for some archs specifically, disable it for all the archs.

Quoted 8 lines
Quoted 1 line

This seems like a reasonable change to me, however, it does not apply cleanly to the kexec tree on kernel.org which I maintain.

https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git

Could you rebase and repost?

I have now realised that Mike Frysinger has posted a similar, slightly more comprehensive, patch which I have now applied.

Could you see if it addresses the problem you are seeing?

It is the following commit in the above tree:

4a837c9a19f9 purgatory: force PIC/PIE/SSP off

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

author
#3 lore raw
Quoted 20 lines · Simon Horman
Quoted 10 lines · Simon Horman

Hi Kevin,

Quoted 7 lines · Kevin Hao

If the GCC's stack protection is enabled by default, the purgatory will also be built with this option. But it makes no sense to enable this for the purgatory code, and would cause error when we are trying to relocate the purgatory codes because symbol like __stack_chk_fail is unresolved. Instead of disabling this for some archs specifically, disable it for all the archs.

Quoted 8 lines
Quoted 1 line

This seems like a reasonable change to me, however, it does not apply cleanly to the kexec tree on kernel.org which I maintain.

https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git

Could you rebase and repost?

Quoted 8 lines

I have now realised that Mike Frysinger has posted a similar, slightly more comprehensive, patch which I have now applied.

Could you see if it addresses the problem you are seeing?

It is the following commit in the above tree:

4a837c9a19f9 purgatory: force PIC/PIE/SSP off

Yes, it should solve my problem too. I didn't realized there already have a patch for this issue. Sorry for the noise.

Thanks,
Kevin

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec