8ae002
From a014cecd82b71b70a6a843e250e06b541ad524f7 Mon Sep 17 00:00:00 2001
8ae002
From: Florian Weimer <fweimer@redhat.com>
8ae002
Date: Thu, 15 Oct 2015 09:23:07 +0200
8ae002
Subject: [PATCH] Always enable pointer guard [BZ #18928]
8ae002
8ae002
Honoring the LD_POINTER_GUARD environment variable in AT_SECURE mode
8ae002
has security implications.  This commit enables pointer guard
8ae002
unconditionally, and the environment variable is now ignored.
8ae002
8ae002
        [BZ #18928]
8ae002
        * sysdeps/generic/ldsodefs.h (struct rtld_global_ro): Remove
8ae002
        _dl_pointer_guard member.
8ae002
        * elf/rtld.c (_rtld_global_ro): Remove _dl_pointer_guard
8ae002
        initializer.
8ae002
        (security_init): Always set up pointer guard.
8ae002
        (process_envvars): Do not process LD_POINTER_GUARD.
8ae002
8ae002
diff -rup a/elf/rtld.c b/elf/rtld.c
8ae002
--- a/elf/rtld.c	2017-03-06 14:38:55.000000000 -0500
8ae002
+++ b/elf/rtld.c	2017-03-06 14:41:19.502556336 -0500
8ae002
@@ -160,7 +160,6 @@ struct rtld_global_ro _rtld_global_ro at
8ae002
     ._dl_hwcap_mask = HWCAP_IMPORTANT,
8ae002
     ._dl_lazy = 1,
8ae002
     ._dl_fpu_control = _FPU_DEFAULT,
8ae002
-    ._dl_pointer_guard = 1,
8ae002
     ._dl_pagesize = EXEC_PAGESIZE,
8ae002
     ._dl_inhibit_cache = 0,
8ae002
 
8ae002
@@ -844,15 +843,12 @@ security_init (void)
8ae002
 #endif
8ae002
 
8ae002
   /* Set up the pointer guard as well, if necessary.  */
8ae002
-  if (GLRO(dl_pointer_guard))
8ae002
-    {
8ae002
-      uintptr_t pointer_chk_guard = _dl_setup_pointer_guard (_dl_random,
8ae002
-							     stack_chk_guard);
8ae002
+  uintptr_t pointer_chk_guard
8ae002
+    = _dl_setup_pointer_guard (_dl_random, stack_chk_guard);
8ae002
 #ifdef THREAD_SET_POINTER_GUARD
8ae002
-      THREAD_SET_POINTER_GUARD (pointer_chk_guard);
8ae002
+  THREAD_SET_POINTER_GUARD (pointer_chk_guard);
8ae002
 #endif
8ae002
-      __pointer_chk_guard_local = pointer_chk_guard;
8ae002
-    }
8ae002
+  __pointer_chk_guard_local = pointer_chk_guard;
8ae002
 
8ae002
   /* We do not need the _dl_random value anymore.  The less
8ae002
      information we leave behind, the better, so clear the
8ae002
@@ -2599,9 +2595,6 @@ process_envvars (enum mode *modep)
8ae002
 	      GLRO(dl_use_load_bias) = envline[14] == '1' ? -1 : 0;
8ae002
 	      break;
8ae002
 	    }
8ae002
-
8ae002
-	  if (memcmp (envline, "POINTER_GUARD", 13) == 0)
8ae002
-	    GLRO(dl_pointer_guard) = envline[14] != '0';
8ae002
 	  break;
8ae002
 
8ae002
 	case 14:
8ae002
diff -rup a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
8ae002
--- a/sysdeps/generic/ldsodefs.h	2017-03-06 14:38:57.000000000 -0500
8ae002
+++ b/sysdeps/generic/ldsodefs.h	2017-03-06 14:41:19.506556361 -0500
8ae002
@@ -588,9 +588,6 @@ struct rtld_global_ro
8ae002
   /* List of auditing interfaces.  */
8ae002
   struct audit_ifaces *_dl_audit;
8ae002
   unsigned int _dl_naudit;
8ae002
-
8ae002
-  /* 0 if internal pointer values should not be guarded, 1 if they should.  */
8ae002
-  EXTERN int _dl_pointer_guard;
8ae002
 };
8ae002
 # define __rtld_global_attribute__
8ae002
 # if IS_IN (rtld)