d8307d
commit 94a4e9e4f401ffe829a992820439977ead0a0ce7
d8307d
Author: Florian Weimer <fweimer@redhat.com>
d8307d
Date:   Thu Apr 25 10:41:43 2019 +0200
d8307d
d8307d
    Extend BIND_NOW to installed programs with --enable-bind-now
d8307d
    
d8307d
    Commit 2d6ab5df3b675e96ee587ae6a8c2ce004c6b1ba9 ("Document and fix
d8307d
    --enable-bind-now [BZ #21015]") extended BIND_NOW to all installed
d8307d
    shared objects.  This change also covers installed programs.
d8307d
    
d8307d
    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
d8307d
d8307d
diff --git a/INSTALL b/INSTALL
d8307d
index d6c8e899fbb47dac..d56e102ec9ed3281 100644
d8307d
--- a/INSTALL
d8307d
+++ b/INSTALL
d8307d
@@ -169,10 +169,10 @@ if 'CFLAGS' is specified it must enable optimization.  For example:
d8307d
      protection.
d8307d
 
d8307d
 '--enable-bind-now'
d8307d
-     Disable lazy binding for installed shared objects.  This provides
d8307d
-     additional security hardening because it enables full RELRO and a
d8307d
-     read-only global offset table (GOT), at the cost of slightly
d8307d
-     increased program load times.
d8307d
+     Disable lazy binding for installed shared objects and programs.
d8307d
+     This provides additional security hardening because it enables full
d8307d
+     RELRO and a read-only global offset table (GOT), at the cost of
d8307d
+     slightly increased program load times.
d8307d
 
d8307d
 '--enable-pt_chown'
d8307d
      The file 'pt_chown' is a helper binary for 'grantpt' (*note
d8307d
diff --git a/Makeconfig b/Makeconfig
d8307d
index 8dc2fec9dc683416..742c0c0783a14bfa 100644
d8307d
--- a/Makeconfig
d8307d
+++ b/Makeconfig
d8307d
@@ -398,6 +398,8 @@ endif
d8307d
 # test modules.
d8307d
 ifeq ($(bind-now),yes)
d8307d
 LDFLAGS-lib.so += -Wl,-z,now
d8307d
+# Extra flags for dynamically linked non-test main programs.
d8307d
+link-extra-flags += -Wl,-z,now
d8307d
 endif
d8307d
 
d8307d
 # Command to run after every final link (executable or shared object).
d8307d
@@ -426,7 +428,7 @@ ifndef +link-pie
d8307d
 	     $(link-extra-libs)
d8307d
 +link-pie-after-libc = $(+postctorS) $(+postinit)
d8307d
 define +link-pie
d8307d
-$(+link-pie-before-libc) $(rtld-LDFLAGS) $(link-libc) $(+link-pie-after-libc)
d8307d
+$(+link-pie-before-libc) $(rtld-LDFLAGS) $(link-extra-flags) $(link-libc) $(+link-pie-after-libc)
d8307d
 $(call after-link,$@)
d8307d
 endef
d8307d
 define +link-pie-tests
d8307d
@@ -454,7 +456,7 @@ ifndef +link-static
d8307d
 	      $(link-extra-libs-static)
d8307d
 +link-static-after-libc = $(+postctorT) $(+postinit)
d8307d
 define +link-static
d8307d
-$(+link-static-before-libc) $(link-libc-static) $(+link-static-after-libc)
d8307d
+$(+link-static-before-libc) $(link-extra-flags) $(link-libc-static) $(+link-static-after-libc)
d8307d
 $(call after-link,$@)
d8307d
 endef
d8307d
 define +link-static-tests
d8307d
@@ -485,7 +487,7 @@ else  # not build-pie-default
d8307d
 	      $(link-extra-libs)
d8307d
 +link-after-libc = $(+postctor) $(+postinit)
d8307d
 define +link
d8307d
-$(+link-before-libc) $(rtld-LDFLAGS) $(link-libc) $(+link-after-libc)
d8307d
+$(+link-before-libc) $(rtld-LDFLAGS) $(link-extra-flags) $(link-libc) $(+link-after-libc)
d8307d
 $(call after-link,$@)
d8307d
 endef
d8307d
 define +link-tests
d8307d
diff --git a/manual/install.texi b/manual/install.texi
d8307d
index e757891dc2eebb2e..351d67c68b255f62 100644
d8307d
--- a/manual/install.texi
d8307d
+++ b/manual/install.texi
d8307d
@@ -199,10 +199,10 @@ number of routines called directly from assembler are excluded from this
d8307d
 protection.
d8307d
 
d8307d
 @item --enable-bind-now
d8307d
-Disable lazy binding for installed shared objects.  This provides
d8307d
-additional security hardening because it enables full RELRO and a
d8307d
-read-only global offset table (GOT), at the cost of slightly increased
d8307d
-program load times.
d8307d
+Disable lazy binding for installed shared objects and programs.  This
d8307d
+provides additional security hardening because it enables full RELRO
d8307d
+and a read-only global offset table (GOT), at the cost of slightly
d8307d
+increased program load times.
d8307d
 
d8307d
 @pindex pt_chown
d8307d
 @findex grantpt