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