e7a346
From ada27d07526acb0ef09f37de7f364fa3dcea0b36 Mon Sep 17 00:00:00 2001
e7a346
From: Atin Mukherjee <amukherj@redhat.com>
e7a346
Date: Wed, 3 Jun 2015 11:09:21 +0530
e7a346
Subject: [PATCH 11/74] build: introduce security hardening flags in gluster
e7a346
e7a346
This patch introduces two of the security hardening compiler flags RELRO & PIE
e7a346
in gluster codebase. Using _hardened_build as 1 doesn't guarantee the existance
e7a346
of these flags in the compilation as different versions of RHEL have different
e7a346
redhat-rpm-config macro. So the idea is to export these flags at spec file
e7a346
level.
e7a346
e7a346
Label: DOWNSTREAM ONLY
e7a346
e7a346
Change-Id: I0a1a56d0a8f54f110d306ba5e55e39b1b073dc84
e7a346
Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
e7a346
Reviewed-on: https://code.engineering.redhat.com/gerrit/49780
e7a346
Reviewed-by: Balamurugan Arumugam <barumuga@redhat.com>
e7a346
Tested-by: Balamurugan Arumugam <barumuga@redhat.com>
e7a346
Reviewed-on: https://code.engineering.redhat.com/gerrit/60137
e7a346
Tested-by: Milind Changire <mchangir@redhat.com>
e7a346
---
e7a346
 glusterfs.spec.in | 25 +++++++++++++++++++++++--
e7a346
 1 file changed, 23 insertions(+), 2 deletions(-)
e7a346
e7a346
diff --git a/glusterfs.spec.in b/glusterfs.spec.in
e7a346
index dbdb818..458b8bc 100644
e7a346
--- a/glusterfs.spec.in
e7a346
+++ b/glusterfs.spec.in
e7a346
@@ -709,6 +709,24 @@ GlusterFS Events
e7a346
 CFLAGS=-DUSE_INSECURE_OPENSSL
e7a346
 export CFLAGS
e7a346
 %endif
e7a346
+# In RHEL7 few hardening flags are available by default, however the RELRO
e7a346
+# default behaviour is partial, convert to full
e7a346
+%if ( 0%{?rhel} && 0%{?rhel} >= 7 )
e7a346
+LDFLAGS="$RPM_LD_FLAGS -Wl,-z,relro,-z,now"
e7a346
+export LDFLAGS
e7a346
+%else
e7a346
+%if ( 0%{?rhel} && 0%{?rhel} == 6 )
e7a346
+CFLAGS="$RPM_OPT_FLAGS -fPIE -DPIE"
e7a346
+LDFLAGS="$RPM_LD_FLAGS -pie -Wl,-z,relro,-z,now"
e7a346
+%else
e7a346
+#It appears that with gcc-4.1.2 in RHEL5 there is an issue using both -fPIC and
e7a346
+ # -fPIE that makes -z relro not work; -fPIE seems to undo what -fPIC does
e7a346
+CFLAGS="$CFLAGS $RPM_OPT_FLAGS"
e7a346
+LDFLAGS="$RPM_LD_FLAGS -Wl,-z,relro,-z,now"
e7a346
+%endif
e7a346
+export CFLAGS
e7a346
+export LDFLAGS
e7a346
+%endif
e7a346
 
e7a346
 ./autogen.sh && %configure \
e7a346
         %{?_with_cmocka} \
e7a346
@@ -2110,8 +2128,11 @@ end
e7a346
 * Fri Jun 12 2015 Aravinda VK <avishwan@redhat.com>
e7a346
 - Added rsync as dependency to georeplication rpm (#1231205)
e7a346
 
e7a346
-* Tue Jun 02 2015 Aravinda VK <avishwan@redhat.com>
e7a346
-- Added post hook for volume delete as part of glusterfind (#1225465)
e7a346
+* Thu Jun 11 2015 Atin Mukherjee <amukherj@redhat.com>
e7a346
+- Security hardening flags inclusion (#1200815)
e7a346
+
e7a346
+* Thu Jun 11 2015 Aravinda VK <avishwan@redhat.com>
e7a346
+- Added post hook for volume delete as part of glusterfind (#1225551)
e7a346
 
e7a346
 * Wed May 27 2015 Aravinda VK <avishwan@redhat.com>
e7a346
 - Added stop-all-gluster-processes.sh in glusterfs-server section (#1204641)
e7a346
-- 
e7a346
1.8.3.1
e7a346