This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFC: Add __pointer_guard_t for pointer_guard


As described in

http://sourceware.org/ml/libc-alpha/2012-05/msg01253.html

on x32, PTR_DEMANGLE/PTR_MANGLE are used on 64-bit registers, which
requires the pointer_guard field in tcbhead_t to be 64-bit. But
uintptr_t is 32-bit on x32.  This patch adds __pointer_guard_t for
pointer_guard and reorders tcbhead_t for x32.  By pure luck, stack_guard
and __private_tm offsets used by GCC stay the same.  Any comments?

Thanks.


H.J.

	* bits/types.h (__pointer_guard_t): New type.
	* bits/typesizes.h (__POINTER_GUARD_T_TYPE): New macro.
	sysdeps/mach/hurd/bits/typesizes.h (__POINTER_GUARD_T_TYPE):
	Likewise.
	* sysdeps/unix/bsd/bsd4.4/freebsd/bits/typesizes.h
	(__POINTER_GUARD_T_TYPE): Likewise.
	* sysdeps/unix/sysv/linux/s390/bits/typesizes.h
	(__POINTER_GUARD_T_TYPE): Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
	(__POINTER_GUARD_T_TYPE): Likewise.
	* sysdeps/unix/sysv/linux/x86_64/bits/typesizes.h
	(__POINTER_GUARD_T_TYPE): Likewise.
	* elf/rtld.c (__pointer_chk_guard_local): Replace uintptr_t
	with __pointer_guard_t.
	(pointer_chk_guard): Likewise.
	* sysdeps/generic/dl-osinfo.h (_dl_setup_pointer_guard):
	Likewise.
	* sysdeps/unix/sysv/linux/dl-osinfo.h (_dl_setup_pointer_guard):
	Likewise.

nptl/

	* sysdeps/x86_64/tls.h (tcbhead_t): Replace uintptr_t with
	__pointer_guard_t on pointer_guard.  Reordor fields for x32.

diff --git a/bits/types.h b/bits/types.h
index 041ace6..a46dc34 100644
--- a/bits/types.h
+++ b/bits/types.h
@@ -179,6 +179,9 @@ __STD_TYPE __FSFILCNT64_T_TYPE __fsfilcnt64_t;
 /* Type of miscellaneous file system fields.  */
 __STD_TYPE __FSWORD_T_TYPE __fsword_t;
 
+/* Type of pointer guard.  */
+__STD_TYPE __POINTER_GUARD_T_TYPE __pointer_guard_t;
+
 __STD_TYPE __SSIZE_T_TYPE __ssize_t; /* Type of a byte count, or error.  */
 
 /* Signed long type used in system calls.  */
diff --git a/bits/typesizes.h b/bits/typesizes.h
index 3fd4a2e..f365cb2 100644
--- a/bits/typesizes.h
+++ b/bits/typesizes.h
@@ -45,6 +45,7 @@
 #define	__FSFILCNT_T_TYPE	__ULONGWORD_TYPE
 #define	__FSFILCNT64_T_TYPE	__UQUAD_TYPE
 #define	__FSWORD_T_TYPE		__SWORD_TYPE
+#define	__POINTER_GUARD_T_TYPE	__UWORD_TYPE
 #define	__ID_T_TYPE		__U32_TYPE
 #define __CLOCK_T_TYPE		__SLONGWORD_TYPE
 #define __TIME_T_TYPE		__SLONGWORD_TYPE
diff --git a/elf/rtld.c b/elf/rtld.c
index a5b0ab9..0ef047b 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -92,7 +92,7 @@ uintptr_t __stack_chk_guard attribute_relro;
 
 /* Only exported for architectures that don't store the pointer guard
    value in thread local area.  */
-uintptr_t __pointer_chk_guard_local
+__pointer_guard_t __pointer_chk_guard_local
      attribute_relro attribute_hidden __attribute__ ((nocommon));
 #ifndef THREAD_SET_POINTER_GUARD
 strong_alias (__pointer_chk_guard_local, __pointer_chk_guard)
@@ -865,8 +865,8 @@ security_init (void)
   /* Set up the pointer guard as well, if necessary.  */
   if (GLRO(dl_pointer_guard))
     {
-      uintptr_t pointer_chk_guard = _dl_setup_pointer_guard (_dl_random,
-							     stack_chk_guard);
+      __pointer_guard_t pointer_chk_guard
+	= _dl_setup_pointer_guard (_dl_random, stack_chk_guard);
 #ifdef THREAD_SET_POINTER_GUARD
       THREAD_SET_POINTER_GUARD (pointer_chk_guard);
 #endif
diff --git a/nptl/sysdeps/x86_64/tls.h b/nptl/sysdeps/x86_64/tls.h
index f838916..a185d10 100644
--- a/nptl/sysdeps/x86_64/tls.h
+++ b/nptl/sysdeps/x86_64/tls.h
@@ -52,17 +52,25 @@ typedef struct
   int gscope_flag;
   uintptr_t sysinfo;
   uintptr_t stack_guard;
-  uintptr_t pointer_guard;
+# ifdef __ILP32__
+  int rtld_must_xmm_save;
+  __pointer_guard_t pointer_guard;	/* Align offset to 8 bytes.  */
   unsigned long int vgetcpu_cache[2];
-# ifndef __ASSUME_PRIVATE_FUTEX
-  int private_futex;
+  /* Reservation of some values for the TM ABI.  */
+  void *__private_tm[5];
 # else
+  __pointer_guard_t pointer_guard;
+  unsigned long int vgetcpu_cache[2];
+#  ifndef __ASSUME_PRIVATE_FUTEX
+  int private_futex;
+#  else
   int __unused1;
-# endif
+#  endif
   int rtld_must_xmm_save;
   /* Reservation of some values for the TM ABI.  */
   void *__private_tm[5];
   long int __unused2;
+# endif
   /* Have space for the post-AVX register size.  */
   __m128 rtld_savespace_sse[8][4] __attribute__ ((aligned (32)));
 
diff --git a/sysdeps/generic/dl-osinfo.h b/sysdeps/generic/dl-osinfo.h
index 983cd55..08c7a60 100644
--- a/sysdeps/generic/dl-osinfo.h
+++ b/sysdeps/generic/dl-osinfo.h
@@ -47,10 +47,11 @@ _dl_setup_stack_chk_guard (void *dl_random)
   return ret.num;
 }
 
-static inline uintptr_t __attribute__ ((always_inline))
-_dl_setup_pointer_guard (void *dl_random, uintptr_t stack_chk_guard)
+static inline __pointer_guard_t __attribute__ ((always_inline))
+_dl_setup_pointer_guard (void *dl_random,
+			 __pointer_guard_t stack_chk_guard)
 {
-  uintptr_t ret;
+  __pointer_guard_t ret;
   if (dl_random == NULL)
     ret = stack_chk_guard;
   else
diff --git a/sysdeps/mach/hurd/bits/typesizes.h b/sysdeps/mach/hurd/bits/typesizes.h
index efc1314..7d9a9bb 100644
--- a/sysdeps/mach/hurd/bits/typesizes.h
+++ b/sysdeps/mach/hurd/bits/typesizes.h
@@ -45,6 +45,7 @@
 #define	__FSFILCNT_T_TYPE	__ULONGWORD_TYPE
 #define	__FSFILCNT64_T_TYPE	__UQUAD_TYPE
 #define	__FSWORD_T_TYPE		__SWORD_TYPE
+#define	__POINTER_GUARD_T_TYPE	__UWORD_TYPE
 #define	__ID_T_TYPE		__U32_TYPE
 #define __CLOCK_T_TYPE		__SLONGWORD_TYPE
 #define __TIME_T_TYPE		__SLONGWORD_TYPE
diff --git a/sysdeps/unix/bsd/bsd4.4/freebsd/bits/typesizes.h b/sysdeps/unix/bsd/bsd4.4/freebsd/bits/typesizes.h
index 02c24e4..39cd475 100644
--- a/sysdeps/unix/bsd/bsd4.4/freebsd/bits/typesizes.h
+++ b/sysdeps/unix/bsd/bsd4.4/freebsd/bits/typesizes.h
@@ -45,6 +45,7 @@
 #define	__FSFILCNT_T_TYPE	__ULONGWORD_TYPE
 #define	__FSFILCNT64_T_TYPE	__UQUAD_TYPE
 #define	__FSWORD_T_TYPE		__SWORD_TYPE
+#define	__POINTER_GUARD_T_TYPE	__UWORD_TYPE
 #define	__ID_T_TYPE		__U32_TYPE
 #define __CLOCK_T_TYPE		__S32_TYPE
 #define __TIME_T_TYPE		__SLONGWORD_TYPE
diff --git a/sysdeps/unix/sysv/linux/dl-osinfo.h b/sysdeps/unix/sysv/linux/dl-osinfo.h
index 82d6e22..6b0ed2e 100644
--- a/sysdeps/unix/sysv/linux/dl-osinfo.h
+++ b/sysdeps/unix/sysv/linux/dl-osinfo.h
@@ -93,10 +93,11 @@ _dl_setup_stack_chk_guard (void *dl_random)
   return ret.num;
 }
 
-static inline uintptr_t __attribute__ ((always_inline))
-_dl_setup_pointer_guard (void *dl_random, uintptr_t stack_chk_guard)
+static inline __pointer_guard_t __attribute__ ((always_inline))
+_dl_setup_pointer_guard (void *dl_random,
+			 __pointer_guard_t stack_chk_guard)
 {
-  uintptr_t ret;
+  __pointer_guard_t ret;
 #ifndef __ASSUME_AT_RANDOM
   if (dl_random == NULL)
     {
diff --git a/sysdeps/unix/sysv/linux/s390/bits/typesizes.h b/sysdeps/unix/sysv/linux/s390/bits/typesizes.h
index def84cc..fb52f72 100644
--- a/sysdeps/unix/sysv/linux/s390/bits/typesizes.h
+++ b/sysdeps/unix/sysv/linux/s390/bits/typesizes.h
@@ -45,6 +45,7 @@
 #define	__FSFILCNT_T_TYPE	__ULONGWORD_TYPE
 #define	__FSFILCNT64_T_TYPE	__UQUAD_TYPE
 #define	__FSWORD_T_TYPE		__SWORD_TYPE
+#define	__POINTER_GUARD_T_TYPE	__UWORD_TYPE
 #define	__ID_T_TYPE		__U32_TYPE
 #define __CLOCK_T_TYPE		__SLONGWORD_TYPE
 #define __TIME_T_TYPE		__SLONGWORD_TYPE
diff --git a/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h b/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
index b65a1a5..46c690f 100644
--- a/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
+++ b/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
@@ -45,6 +45,7 @@
 #define	__FSFILCNT_T_TYPE	__ULONGWORD_TYPE
 #define	__FSFILCNT64_T_TYPE	__UQUAD_TYPE
 #define	__FSWORD_T_TYPE		__SWORD_TYPE
+#define	__POINTER_GUARD_T_TYPE	__UWORD_TYPE
 #define	__ID_T_TYPE		__U32_TYPE
 #define __CLOCK_T_TYPE		__SLONGWORD_TYPE
 #define __TIME_T_TYPE		__SLONGWORD_TYPE
diff --git a/sysdeps/unix/sysv/linux/x86_64/bits/typesizes.h b/sysdeps/unix/sysv/linux/x86_64/bits/typesizes.h
index cbad9a3..477ae64 100644
--- a/sysdeps/unix/sysv/linux/x86_64/bits/typesizes.h
+++ b/sysdeps/unix/sysv/linux/x86_64/bits/typesizes.h
@@ -54,6 +54,7 @@
 #define __FSFILCNT_T_TYPE	__SYSCALL_ULONG_TYPE
 #define __FSFILCNT64_T_TYPE	__UQUAD_TYPE
 #define __FSWORD_T_TYPE		__SYSCALL_SLONG_TYPE
+#define	__POINTER_GUARD_T_TYPE	__SYSCALL_ULONG_TYPE
 #define __ID_T_TYPE		__U32_TYPE
 #define __CLOCK_T_TYPE		__SYSCALL_SLONG_TYPE
 #define __TIME_T_TYPE		__SYSCALL_SLONG_TYPE


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]