pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/mk Change PKGSRC_USE_SSP to a quad option. The option...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/34f84ada3ae6
branches:  trunk
changeset: 348421:34f84ada3ae6
user:      jperkin <jperkin%pkgsrc.org@localhost>
date:      Mon Jun 13 13:26:42 2016 +0000

description:
Change PKGSRC_USE_SSP to a quad option.  The options are now:

   "no"     Do not pass any stack protection flags (the default)
   "yes"    Pass -fstack-protector
   "strong" Pass -fstack-protector-strong
   "all"    Pass -fstack-protector-all

This allows users to configure the level of stack smashing protection they
require, and ensures consistent behaviour across platforms.  Users running
on NetBSD who previously used the option will need to change "yes" to "all"
to match the previous default configuration for that platform.

While here use _WRAP_EXTRA_ARGS to ensure the flag gets passed regardless
of whether the package honours CFLAGS, and support additional wrappers.

Discussed a while back with khorben, and used in production for the SmartOS
2016Q1 package sets with the "strong" option.

diffstat:

 mk/bsd.prefs.mk     |   4 ++--
 mk/compiler/gcc.mk  |  20 +++++++++++++++-----
 mk/defaults/mk.conf |  10 +++++++---
 3 files changed, 24 insertions(+), 10 deletions(-)

diffs (88 lines):

diff -r e0abe879458a -r 34f84ada3ae6 mk/bsd.prefs.mk
--- a/mk/bsd.prefs.mk   Mon Jun 13 12:26:49 2016 +0000
+++ b/mk/bsd.prefs.mk   Mon Jun 13 13:26:42 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.prefs.mk,v 1.386 2016/04/17 08:13:09 jperkin Exp $
+# $NetBSD: bsd.prefs.mk,v 1.387 2016/06/13 13:26:42 jperkin Exp $
 #
 # This file includes the mk.conf file, which contains the user settings.
 #
@@ -707,7 +707,7 @@
 .endif
 
 _PKGSRC_USE_SSP=       no
-.if (${PKGSRC_USE_SSP:tl} == "yes") && \
+.if (${PKGSRC_USE_SSP:tl} != "no") && \
     (${_OPSYS_SUPPORTS_SSP:Uno} == "yes")
 _PKGSRC_USE_SSP=       yes
 .endif
diff -r e0abe879458a -r 34f84ada3ae6 mk/compiler/gcc.mk
--- a/mk/compiler/gcc.mk        Mon Jun 13 12:26:49 2016 +0000
+++ b/mk/compiler/gcc.mk        Mon Jun 13 13:26:42 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: gcc.mk,v 1.167 2016/04/11 04:22:34 dbj Exp $
+# $NetBSD: gcc.mk,v 1.168 2016/06/13 13:26:42 jperkin Exp $
 #
 # This is the compiler definition for the GNU Compiler Collection.
 #
@@ -346,12 +346,10 @@
 # XXX for libraries a sink wrapper around gcc is required and used instead
 #_MKPIE_LDFLAGS.gcc=   -pie
 _RELRO_LDFLAGS.gcc=    -Wl,-z,relro -Wl,-z,now
-_SSP_CFLAGS.gcc=       -fstack-protector-all
 .endif
 
 .if ${OPSYS} == "SunOS"
 _FORTIFY_CFLAGS.gcc=   -D_FORTIFY_SOURCE=2
-_SSP_CFLAGS.gcc=       -fstack-protector
 .endif
 
 .if ${_PKGSRC_MKPIE} == "yes"
@@ -372,9 +370,21 @@
 CWRAPPERS_APPEND.ld+=  ${_RELRO_LDFLAGS.gcc}
 .endif
  
+# The user can choose the level of stack smashing protection.
+.if ${PKGSRC_USE_SSP} == "all"
+_SSP_CFLAGS=           -fstack-protector-all
+.elif ${PKGSRC_USE_SSP} == "strong"
+_SSP_CFLAGS=           -fstack-protector-strong
+.else
+_SSP_CFLAGS=           -fstack-protector
+.endif
+
 .if ${_PKGSRC_USE_SSP} == "yes"
-_GCC_CFLAGS+=          ${_SSP_CFLAGS.gcc}
-CWRAPPERS_APPEND.cc+=  ${_SSP_CFLAGS.gcc}
+_WRAP_EXTRA_ARGS.CC+=  ${_SSP_CFLAGS}
+_WRAP_EXTRA_ARGS.CXX+= ${_SSP_CFLAGS}
+CWRAPPERS_APPEND.cc+=  ${_SSP_CFLAGS}
+CWRAPPERS_APPEND.cxx+= ${_SSP_CFLAGS}
+CWRAPPERS_APPEND.f77+= ${_SSP_CFLAGS}
 .endif
 
 # GCC has this annoying behaviour where it advocates in a multi-line
diff -r e0abe879458a -r 34f84ada3ae6 mk/defaults/mk.conf
--- a/mk/defaults/mk.conf       Mon Jun 13 12:26:49 2016 +0000
+++ b/mk/defaults/mk.conf       Mon Jun 13 13:26:42 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mk.conf,v 1.263 2016/03/11 23:03:31 khorben Exp $
+# $NetBSD: mk.conf,v 1.264 2016/06/13 13:26:42 jperkin Exp $
 #
 
 # This file provides default values for variables that may be overridden
@@ -236,8 +236,12 @@
 # Default: no
 
 PKGSRC_USE_SSP?= no
-# Set this to yes to enable stack-smashing protection (on supported platforms).
-# Possible: yes, no
+# Configure this to enable stack smashing protection (on supported platforms).
+# Possible values:
+#      no:     Do not pass any stack protection flags
+#      yes:    Pass -fstack-protector
+#      strong: Pass -fstack-protector-strong
+#      all:    Pass -fstack-protector-all
 # Default: no
 
 # The default PREFER_PKGSRC should be empty, but due to historical reasons we have the list below.



Home | Main Index | Thread Index | Old Index