Skip to contentSkip to conversation

toolchain/buildroot: properly handle SSP

PATCH New Gustavo Zacarias 2 participants 4 messages Jul 4, 2013 – Jul 27, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 toolchain/buildroot: properly handle SSP

The current SSP handling is incomplete.

First we need to build uClibc with SSP support for a complete "experience".

Second, it doesn't hurt to add -fstack-protector-all to the CFLAGS/CXXFLAGS since most users would expect buildroot to do this rather than adding the flags themselves.

---
 package/Makefile.in                       |  5 +++++
 package/uclibc/uclibc.mk                  | 10 ++++++++--
 toolchain/toolchain-buildroot/Config.in.2 |  2 +-
 3 files changed, 14 insertions(+), 3 deletions(-)
package/Makefile.in +5 -0
index 66e45d2..01c1256 100644
@@ -119,6 +119,11 @@ TARGET_CFLAGS += -msep-data
 TARGET_CXXFLAGS += -msep-data
 endif
 
+ifeq ($(BR2_TOOLCHAIN_BUILDROOT_USE_SSP),y)
+TARGET_CFLAGS += -fstack-protector-all
+TARGET_CXXFLAGS += -fstack-protector-all
+endif
+
 ifeq ($(BR2_TOOLCHAIN_BUILDROOT)$(BR2_TOOLCHAIN_CTNG),y)
 TARGET_CROSS=$(HOST_DIR)/usr/bin/$(GNU_TARGET_NAME)-
 else
package/uclibc/uclibc.mk +8 -2
index 5cbc011..6060efa 100644
@@ -255,9 +255,15 @@ endif
 # SSP
 #
 ifeq ($(BR2_TOOLCHAIN_BUILDROOT_USE_SSP),y)
-UCLIBC_SSP_CONFIG = $(call UCLIBC_OPT_SET,UCLIBC_HAS_SSP,y,$(@D))
+define UCLIBC_SSP_CONFIG
+	$(call UCLIBC_OPT_SET,UCLIBC_HAS_SSP,y,$(@D))
+	$(call UCLIBC_OPT_SET,UCLIBC_BUILD_SSP,y,$(@D))
+endef
 else
-UCLIBC_SSP_CONFIG = $(call UCLIBC_OPT_UNSET,UCLIBC_HAS_SSP,$(@D))
+define UCLIBC_SSP_CONFIG
+	$(call UCLIBC_OPT_UNSET,UCLIBC_HAS_SSP,$(@D))
+	$(call UCLIBC_OPT_UNSET,UCLIBC_BUILD_SSP,$(@D))
+endef
 endif
 
 #
toolchain/toolchain-buildroot/Config.in.2 +1 -1
index 9bbf016..67aecaa 100644
@@ -16,7 +16,7 @@ config BR2_TOOLCHAIN_BUILDROOT_USE_SSP
 	bool "Enable stack protection support"
 	help
 	  Enable stack smashing protection support using GCCs
-	  -fstack-protector[-all] option.
+	  -fstack-protector-all option.
 
 	  See http://www.linuxfromscratch.org/hints/downloads/files/ssp.txt
 	  for details.
Signature · 1 line
1.8.1.5
#1 lore raw

PATCH 1/1 toolchain/buildroot: properly handle SSP

Dear Gustavo Zacarias,

Quoted 10 lines · Gustavo Zacarias

The current SSP handling is incomplete.

First we need to build uClibc with SSP support for a complete "experience".

Second, it doesn't hurt to add -fstack-protector-all to the CFLAGS/CXXFLAGS since most users would expect buildroot to do this rather than adding the flags themselves.

Committed thanks. It would be nice to check whether something specific is needed for eglibc.

Thanks,

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#2 lore raw

PATCH 1/1 toolchain/buildroot: properly handle SSP

Quoted 2 lines · Thomas Petazzoni

Committed thanks. It would be nice to check whether something specific is needed for eglibc.

It's default on for eglibc as long as gcc supports -fstack-protector. And it doesn't seem to care much if i try to disable it, though i'd be a bit wary of doing so being upstream default.
Regards.

#3 lore raw

PATCH 1/1 toolchain/buildroot: properly handle SSP

Dear Gustavo Zacarias,

Quoted 7 lines · Gustavo Zacarias
Quoted 2 lines

Committed thanks. It would be nice to check whether something specific is needed for eglibc.

It's default on for eglibc as long as gcc supports -fstack-protector. And it doesn't seem to care much if i try to disable it, though i'd be a bit wary of doing so being upstream default.
Regards.

Ok, thanks!

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com