233933
From 2adb5d540e9344149ae2591811ad34928775e6fd Mon Sep 17 00:00:00 2001
233933
From: Atin Mukherjee <amukherj@redhat.com>
233933
Date: Wed, 3 Jun 2015 11:09:21 +0530
233933
Subject: [PATCH 09/52] build: introduce security hardening flags in gluster
233933
233933
This patch introduces two of the security hardening compiler flags RELRO & PIE
233933
in gluster codebase. Using _hardened_build as 1 doesn't guarantee the existance
233933
of these flags in the compilation as different versions of RHEL have different
233933
redhat-rpm-config macro. So the idea is to export these flags at spec file
233933
level.
233933
233933
Label: DOWNSTREAM ONLY
233933
233933
Change-Id: I0a1a56d0a8f54f110d306ba5e55e39b1b073dc84
233933
Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
233933
Reviewed-on: https://code.engineering.redhat.com/gerrit/49780
233933
Reviewed-by: Balamurugan Arumugam <barumuga@redhat.com>
233933
Tested-by: Balamurugan Arumugam <barumuga@redhat.com>
233933
Reviewed-on: https://code.engineering.redhat.com/gerrit/60137
233933
Tested-by: Milind Changire <mchangir@redhat.com>
233933
---
233933
 glusterfs.spec.in | 19 +++++++++++++++++++
233933
 1 file changed, 19 insertions(+)
233933
233933
diff --git a/glusterfs.spec.in b/glusterfs.spec.in
233933
index eb04491..8a31a98 100644
233933
--- a/glusterfs.spec.in
233933
+++ b/glusterfs.spec.in
233933
@@ -736,6 +736,25 @@ done
233933
 
233933
 %build
233933
 
233933
+# In RHEL7 few hardening flags are available by default, however the RELRO
233933
+# default behaviour is partial, convert to full
233933
+%if ( 0%{?rhel} && 0%{?rhel} >= 7 )
233933
+LDFLAGS="$RPM_LD_FLAGS -Wl,-z,relro,-z,now"
233933
+export LDFLAGS
233933
+%else
233933
+%if ( 0%{?rhel} && 0%{?rhel} == 6 )
233933
+CFLAGS="$RPM_OPT_FLAGS -fPIE -DPIE"
233933
+LDFLAGS="$RPM_LD_FLAGS -pie -Wl,-z,relro,-z,now"
233933
+%else
233933
+#It appears that with gcc-4.1.2 in RHEL5 there is an issue using both -fPIC and
233933
+ # -fPIE that makes -z relro not work; -fPIE seems to undo what -fPIC does
233933
+CFLAGS="$CFLAGS $RPM_OPT_FLAGS"
233933
+LDFLAGS="$RPM_LD_FLAGS -Wl,-z,relro,-z,now"
233933
+%endif
233933
+export CFLAGS
233933
+export LDFLAGS
233933
+%endif
233933
+
233933
 ./autogen.sh && %configure \
233933
         %{?_with_asan} \
233933
         %{?_with_cmocka} \
233933
-- 
233933
1.8.3.1
233933