|
|
34e815 |
From 9673dcd70489c1c9df22aa0eb7a98afbccc0ced3 Mon Sep 17 00:00:00 2001
|
|
|
34e815 |
From: Andreas Schneider <asn@samba.org>
|
|
|
34e815 |
Date: Mon, 3 Sep 2018 10:35:08 +0200
|
|
|
34e815 |
Subject: [PATCH 1/2] waf: Check for -fstack-protect-strong support
|
|
|
34e815 |
|
|
|
34e815 |
The -fstack-protector* flags are compiler only flags, don't pass them to
|
|
|
34e815 |
the linker.
|
|
|
34e815 |
|
|
|
34e815 |
https://developers.redhat.com/blog/2018/03/21/compiler-and-linker-flags-gcc/
|
|
|
34e815 |
|
|
|
34e815 |
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13601
|
|
|
34e815 |
|
|
|
34e815 |
Signed-off-by: Andreas Schneider <asn@samba.org>
|
|
|
34e815 |
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
|
|
|
34e815 |
(cherry picked from commit 38e97f8b52e85bdfcf2d74a4fb3c848fa46ba371)
|
|
|
34e815 |
---
|
|
|
34e815 |
buildtools/wafsamba/samba_autoconf.py | 36 ++++++++++++++-------------
|
|
|
34e815 |
1 file changed, 19 insertions(+), 17 deletions(-)
|
|
|
34e815 |
|
|
|
34e815 |
diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py
|
|
|
34e815 |
index c4391d0c4dc..bfd6f9710db 100644
|
|
|
34e815 |
--- a/buildtools/wafsamba/samba_autoconf.py
|
|
|
34e815 |
+++ b/buildtools/wafsamba/samba_autoconf.py
|
|
|
34e815 |
@@ -674,23 +674,25 @@ def SAMBA_CONFIG_H(conf, path=None):
|
|
|
34e815 |
return
|
|
|
34e815 |
|
|
|
34e815 |
# we need to build real code that can't be optimized away to test
|
|
|
34e815 |
- if conf.check(fragment='''
|
|
|
34e815 |
- #include <stdio.h>
|
|
|
34e815 |
-
|
|
|
34e815 |
- int main(void)
|
|
|
34e815 |
- {
|
|
|
34e815 |
- char t[100000];
|
|
|
34e815 |
- while (fgets(t, sizeof(t), stdin));
|
|
|
34e815 |
- return 0;
|
|
|
34e815 |
- }
|
|
|
34e815 |
- ''',
|
|
|
34e815 |
- execute=0,
|
|
|
34e815 |
- ccflags='-fstack-protector',
|
|
|
34e815 |
- ldflags='-fstack-protector',
|
|
|
34e815 |
- mandatory=False,
|
|
|
34e815 |
- msg='Checking if toolchain accepts -fstack-protector'):
|
|
|
34e815 |
- conf.ADD_CFLAGS('-fstack-protector')
|
|
|
34e815 |
- conf.ADD_LDFLAGS('-fstack-protector')
|
|
|
34e815 |
+ stack_protect_list = ['-fstack-protector-strong', '-fstack-protector']
|
|
|
34e815 |
+ for stack_protect_flag in stack_protect_list:
|
|
|
34e815 |
+ flag_supported = conf.check(fragment='''
|
|
|
34e815 |
+ #include <stdio.h>
|
|
|
34e815 |
+
|
|
|
34e815 |
+ int main(void)
|
|
|
34e815 |
+ {
|
|
|
34e815 |
+ char t[100000];
|
|
|
34e815 |
+ while (fgets(t, sizeof(t), stdin));
|
|
|
34e815 |
+ return 0;
|
|
|
34e815 |
+ }
|
|
|
34e815 |
+ ''',
|
|
|
34e815 |
+ execute=0,
|
|
|
34e815 |
+ ccflags=[ '-Werror', '-Wp,-D_FORTIFY_SOURCE=2', stack_protect_flag],
|
|
|
34e815 |
+ mandatory=False,
|
|
|
34e815 |
+ msg='Checking if compiler accepts %s' % (stack_protect_flag))
|
|
|
34e815 |
+ if flag_supported:
|
|
|
34e815 |
+ conf.ADD_CFLAGS('-Wp,-D_FORTIFY_SOURCE=2 %s' % (stack_protect_flag))
|
|
|
34e815 |
+ break
|
|
|
34e815 |
|
|
|
34e815 |
if Options.options.debug:
|
|
|
34e815 |
conf.ADD_CFLAGS('-g', testflags=True)
|
|
|
34e815 |
--
|
|
|
34e815 |
2.18.0
|
|
|
34e815 |
|
|
|
34e815 |
|
|
|
34e815 |
From 5cfefc8d4c7fc4aba5b1dc2b7ea6f02c126d4070 Mon Sep 17 00:00:00 2001
|
|
|
34e815 |
From: Andreas Schneider <asn@samba.org>
|
|
|
34e815 |
Date: Mon, 3 Sep 2018 10:49:52 +0200
|
|
|
34e815 |
Subject: [PATCH 2/2] waf: Add -fstack-clash-protection
|
|
|
34e815 |
|
|
|
34e815 |
https://developers.redhat.com/blog/2018/03/21/compiler-and-linker-flags-gcc/
|
|
|
34e815 |
|
|
|
34e815 |
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13601
|
|
|
34e815 |
|
|
|
34e815 |
Signed-off-by: Andreas Schneider <asn@samba.org>
|
|
|
34e815 |
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
|
|
|
34e815 |
(cherry picked from commit fc4df251c88365142515a81bea1120b2b84cc4a0)
|
|
|
34e815 |
---
|
|
|
34e815 |
buildtools/wafsamba/samba_autoconf.py | 17 +++++++++++++++++
|
|
|
34e815 |
1 file changed, 17 insertions(+)
|
|
|
34e815 |
|
|
|
34e815 |
diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py
|
|
|
34e815 |
index bfd6f9710db..f2b3ec8db8d 100644
|
|
|
34e815 |
--- a/buildtools/wafsamba/samba_autoconf.py
|
|
|
34e815 |
+++ b/buildtools/wafsamba/samba_autoconf.py
|
|
|
34e815 |
@@ -694,6 +694,23 @@ def SAMBA_CONFIG_H(conf, path=None):
|
|
|
34e815 |
conf.ADD_CFLAGS('-Wp,-D_FORTIFY_SOURCE=2 %s' % (stack_protect_flag))
|
|
|
34e815 |
break
|
|
|
34e815 |
|
|
|
34e815 |
+ flag_supported = conf.check(fragment='''
|
|
|
34e815 |
+ #include <stdio.h>
|
|
|
34e815 |
+
|
|
|
34e815 |
+ int main(void)
|
|
|
34e815 |
+ {
|
|
|
34e815 |
+ char t[100000];
|
|
|
34e815 |
+ while (fgets(t, sizeof(t), stdin));
|
|
|
34e815 |
+ return 0;
|
|
|
34e815 |
+ }
|
|
|
34e815 |
+ ''',
|
|
|
34e815 |
+ execute=0,
|
|
|
34e815 |
+ ccflags=[ '-Werror', '-fstack-clash-protection'],
|
|
|
34e815 |
+ mandatory=False,
|
|
|
34e815 |
+ msg='Checking if compiler accepts -fstack-clash-protection')
|
|
|
34e815 |
+ if flag_supported:
|
|
|
34e815 |
+ conf.ADD_CFLAGS('-fstack-clash-protection')
|
|
|
34e815 |
+
|
|
|
34e815 |
if Options.options.debug:
|
|
|
34e815 |
conf.ADD_CFLAGS('-g', testflags=True)
|
|
|
34e815 |
|
|
|
34e815 |
--
|
|
|
34e815 |
2.18.0
|
|
|
34e815 |
|