Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1 v2] gcc: Add support for --enable-default-pie configure option.
@ 2017-12-28 21:43 Stefan Fröberg
  2017-12-28 22:07 ` Thomas Petazzoni
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Fröberg @ 2017-12-28 21:43 UTC (permalink / raw)
  To: buildroot

By default, buildroot produces insecure binaries.

GCC 6.x added build time configuration option "--enable-default-pie".
With that enabled, GCC will produce PIE 
(Position-independent executables) binaries.

PIE is a requirement for ASLR (Address space layout randomization)
that will make exploits like return-to-libc attack impossible. 

If you want to have a modern, secure system then enable this option.

To override this default behaviour, you can use -no-pie
with your CFLAGS/CXXFLAGS.

https://gcc.gnu.org/onlinedocs/gcc-6.2.0/gcc/Link-Options.html

Signed-off-by: Stefan Fr?berg <stefan.froberg@petroprogram.com>
---
 package/gcc/Config.in.host | 10 ++++++++++
 package/gcc/gcc.mk         |  4 ++++
 2 files changed, 14 insertions(+)

diff --git a/package/gcc/Config.in.host b/package/gcc/Config.in.host
index 70cce0a5c5..bf646fa07b 100644
--- a/package/gcc/Config.in.host
+++ b/package/gcc/Config.in.host
@@ -152,3 +152,13 @@ config BR2_GCC_ENABLE_GRAPHITE
 
 comment "graphite support needs gcc >= 5.x"
 	depends on !BR2_TOOLCHAIN_GCC_AT_LEAST_5
+
+config BR2_GCC_ENABLE_DEFAULT_PIE
+	bool "Enable default PIE support"
+	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_6
+	help
+	  This option enables the GCC to make PIE
+	  binaries by default.
+
+comment "default PIE support needs gcc >= 6.x"
+	depends on !BR2_TOOLCHAIN_GCC_AT_LEAST_6
diff --git a/package/gcc/gcc.mk b/package/gcc/gcc.mk
index 27fc1e987c..0910fb3932 100644
--- a/package/gcc/gcc.mk
+++ b/package/gcc/gcc.mk
@@ -183,6 +183,10 @@ else
 HOST_GCC_COMMON_CONF_OPTS += --without-isl --without-cloog
 endif
 
+ifeq ($(BR2_GCC_ENABLE_DEFAULT_PIE),y)
+HOST_GCC_COMMON_CONF_OPTS += --enable-default-pie
+endif
+
 ifeq ($(BR2_arc)$(BR2_or1k),y)
 HOST_GCC_COMMON_DEPENDENCIES += host-flex host-bison
 endif
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-12-30  2:34 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-28 21:43 [Buildroot] [PATCH 1/1 v2] gcc: Add support for --enable-default-pie configure option Stefan Fröberg
2017-12-28 22:07 ` Thomas Petazzoni
     [not found]   ` <CANQCQpZ40Q3T2gOPqu8_vGHCTAup_fxgW3ubfYjewfgo7DwW0A@mail.gmail.com>
2017-12-28 23:28     ` Matthew Weber
2017-12-29 13:25   ` Stefan Fröberg
2017-12-29 13:34     ` Stefan Fröberg
2017-12-29 13:42     ` Thomas Petazzoni
2017-12-29 13:48       ` Stefan Fröberg
2017-12-29 14:04         ` Thomas Petazzoni
2017-12-30  2:34           ` Stefan Fröberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox