@@ -33,11 +33,8 @@ extern void __libc_init_first (int argc, char **argv, char **envp);
#include <tls.h>
#ifndef SHARED
# include <dl-osinfo.h>
-# ifndef THREAD_SET_STACK_GUARD
-/* Only exported for architectures that don't store the stack guard canary
- in thread local area. */
+/* Also export to architectures which prefer -mstack-protector-guard=tls. */
uintptr_t __stack_chk_guard attribute_relro;
-# endif
# ifndef THREAD_SET_POINTER_GUARD
/* Only exported for architectures that don't store the pointer guard
value in thread local area. */
@@ -206,9 +203,8 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
uintptr_t stack_chk_guard = _dl_setup_stack_chk_guard (_dl_random);
# ifdef THREAD_SET_STACK_GUARD
THREAD_SET_STACK_GUARD (stack_chk_guard);
-# else
+# endif
__stack_chk_guard = stack_chk_guard;
-# endif
# ifdef DL_SYSDEP_OSCHECK
{
@@ -1,3 +1,6 @@
+%if __has_include("tls.h")
+%include "tls.h"
+%endif
libc {
GLIBC_2.0 {
%ifdef EXPORT_UNWIND_FIND_FDE
@@ -50,7 +53,15 @@ ld {
}
GLIBC_2.4 {
# stack canary
+%ifndef THREAD_SET_STACK_GUARD
__stack_chk_guard;
+%endif
+ }
+ GLIBC_2.33 {
+ # stack canary
+%ifdef THREAD_SET_STACK_GUARD
+ __stack_chk_guard;
+%endif
}
GLIBC_PRIVATE {
# Those are in the dynamic linker, but used by libc.so.
@@ -154,11 +154,8 @@ unsigned int _dl_skip_args attribute_relro attribute_hidden;
#endif
rtld_hidden_data_def (_dl_argv)
-#ifndef THREAD_SET_STACK_GUARD
-/* Only exported for architectures that don't store the stack guard canary
- in thread local area. */
+/* Also export to architectures which prefer -mstack-protector-guard=tls. */
uintptr_t __stack_chk_guard attribute_relro;
-#endif
/* Only exported for architectures that don't store the pointer guard
value in thread local area. */
@@ -865,9 +862,8 @@ security_init (void)
uintptr_t stack_chk_guard = _dl_setup_stack_chk_guard (_dl_random);
#ifdef THREAD_SET_STACK_GUARD
THREAD_SET_STACK_GUARD (stack_chk_guard);
-#else
+#endif
__stack_chk_guard = stack_chk_guard;
-#endif
/* Set up the pointer guard as well, if necessary. */
uintptr_t pointer_chk_guard
@@ -68,6 +68,13 @@ _Static_assert (offsetof (tcbhead_t, __private_ss) == 0x30,
the SSE memory functions. */
#define STACK_ALIGN 16
+/* Set the stack guard field in TCB head. Referenced by elf/Versions. */
+#define THREAD_SET_STACK_GUARD(value) \
+ THREAD_SETMEM (THREAD_SELF, header.stack_guard, value)
+#define THREAD_COPY_STACK_GUARD(descr) \
+ ((descr)->header.stack_guard \
+ = THREAD_GETMEM (THREAD_SELF, header.stack_guard))
+
#ifndef __ASSEMBLER__
/* Get system call information. */
# include <sysdep.h>
@@ -358,14 +365,6 @@ tls_fill_user_desc (union user_desc_init *desc,
}})
-/* Set the stack guard field in TCB head. */
-#define THREAD_SET_STACK_GUARD(value) \
- THREAD_SETMEM (THREAD_SELF, header.stack_guard, value)
-#define THREAD_COPY_STACK_GUARD(descr) \
- ((descr)->header.stack_guard \
- = THREAD_GETMEM (THREAD_SELF, header.stack_guard))
-
-
/* Set the pointer guard field in the TCB head. */
#define THREAD_SET_POINTER_GUARD(value) \
THREAD_SETMEM (THREAD_SELF, header.pointer_guard, value)
@@ -46,6 +46,13 @@ register struct pthread *__thread_self __asm__("r13");
/* Alignment requirement for the stack. */
#define STACK_ALIGN 16
+/* Set the stack guard field in TCB head. Referenced by elf/Versions. */
+#define THREAD_SET_STACK_GUARD(value) \
+ (((uintptr_t *) __thread_self)[-1] = (value))
+#define THREAD_COPY_STACK_GUARD(descr) \
+ (((uintptr_t *) ((char *) (descr) + TLS_PRE_TCB_SIZE))[-1] \
+ = ((uintptr_t *) __thread_self)[-1])
+
#ifndef __ASSEMBLER__
/* Get system call information. */
# include <sysdep.h>
@@ -138,13 +145,6 @@ register struct pthread *__thread_self __asm__("r13");
#define THREAD_SETMEM_NC(descr, member, idx, value) \
descr->member[idx] = (value)
-/* Set the stack guard field in TCB head. */
-#define THREAD_SET_STACK_GUARD(value) \
- (((uintptr_t *) __thread_self)[-1] = (value))
-#define THREAD_COPY_STACK_GUARD(descr) \
- (((uintptr_t *) ((char *) (descr) + TLS_PRE_TCB_SIZE))[-1] \
- = ((uintptr_t *) __thread_self)[-1])
-
/* Set the pointer guard field in TCB head. */
#define THREAD_GET_POINTER_GUARD() \
(((uintptr_t *) __thread_self)[-2])
@@ -16,4 +16,5 @@ GLIBC_2.2.6 _r_debug D 0x14
GLIBC_2.2.6 abort F
GLIBC_2.3 ___tls_get_addr F
GLIBC_2.3 __tls_get_addr F
+GLIBC_2.33 __stack_chk_guard D 0x4
GLIBC_2.33 __x86_get_cpu_features F
@@ -79,6 +79,13 @@ typedef struct
"Segment Base".) On such machines, a cache line is 64 bytes. */
#define TCB_ALIGNMENT 64
+/* Set the stack guard field in TCB head. Referenced by elf/Versions. */
+#define THREAD_SET_STACK_GUARD(value) \
+ THREAD_SETMEM (THREAD_SELF, stack_guard, value)
+#define THREAD_COPY_STACK_GUARD(descr) \
+ ((descr)->stack_guard \
+ = THREAD_GETMEM (THREAD_SELF, stack_guard))
+
#ifndef __ASSEMBLER__
/* Use i386-specific RPCs to arrange that %gs segment register prefix
@@ -296,13 +303,6 @@ out:
_dtv; })
-/* Set the stack guard field in TCB head. */
-#define THREAD_SET_STACK_GUARD(value) \
- THREAD_SETMEM (THREAD_SELF, stack_guard, value)
-#define THREAD_COPY_STACK_GUARD(descr) \
- ((descr)->stack_guard \
- = THREAD_GETMEM (THREAD_SELF, stack_guard))
-
/* Set the pointer guard field in the TCB head. */
#define THREAD_SET_POINTER_GUARD(value) \
THREAD_SETMEM (THREAD_SELF, pointer_guard, value)
@@ -33,6 +33,16 @@
# include <asm/ptrace.h>
#endif /* __ASSEMBLER__ */
+/* Set the stack guard field in TCB head. Used by elf/Versions. */
+# define THREAD_SET_STACK_GUARD(value) \
+ (((tcbhead_t *) ((char *) __thread_register \
+ - TLS_TCB_OFFSET))[-1].stack_guard = (value))
+# define THREAD_COPY_STACK_GUARD(descr) \
+ (((tcbhead_t *) ((char *) (descr) \
+ + TLS_PRE_TCB_SIZE))[-1].stack_guard \
+ = ((tcbhead_t *) ((char *) __thread_register \
+ - TLS_TCB_OFFSET))[-1].stack_guard)
+
#ifndef __powerpc64__
/* Register r2 (tp) is reserved by the ABI as "thread pointer". */
# define PT_THREAD_POINTER PT_R2
@@ -191,16 +201,6 @@ typedef struct
# define THREAD_SETMEM_NC(descr, member, idx, value) \
((void)(descr), (THREAD_SELF)->member[idx] = (value))
-/* Set the stack guard field in TCB head. */
-# define THREAD_SET_STACK_GUARD(value) \
- (((tcbhead_t *) ((char *) __thread_register \
- - TLS_TCB_OFFSET))[-1].stack_guard = (value))
-# define THREAD_COPY_STACK_GUARD(descr) \
- (((tcbhead_t *) ((char *) (descr) \
- + TLS_PRE_TCB_SIZE))[-1].stack_guard \
- = ((tcbhead_t *) ((char *) __thread_register \
- - TLS_TCB_OFFSET))[-1].stack_guard)
-
/* Set the stack guard field in TCB head. */
# define THREAD_GET_POINTER_GUARD() \
(((tcbhead_t *) ((char *) __thread_register \
@@ -57,6 +57,18 @@ typedef struct
the SSE memory functions. */
#define STACK_ALIGN 16
+/* Set the stack guard field in TCB head. Referenced by elf/Versions. */
+#define THREAD_SET_STACK_GUARD(value) \
+ do \
+ { \
+ __asm__ __volatile__ ("" : : : "a0", "a1"); \
+ THREAD_SETMEM (THREAD_SELF, header.stack_guard, value); \
+ } \
+ while (0)
+#define THREAD_COPY_STACK_GUARD(descr) \
+ ((descr)->header.stack_guard \
+ = THREAD_GETMEM (THREAD_SELF, header.stack_guard))
+
#ifndef __ASSEMBLER__
/* Get system call information. */
# include <sysdep.h>
@@ -145,18 +157,6 @@ typedef struct
#define THREAD_SETMEM_NC(descr, member, idx, value) \
descr->member[idx] = (value)
-/* Set the stack guard field in TCB head. */
-#define THREAD_SET_STACK_GUARD(value) \
- do \
- { \
- __asm__ __volatile__ ("" : : : "a0", "a1"); \
- THREAD_SETMEM (THREAD_SELF, header.stack_guard, value); \
- } \
- while (0)
-#define THREAD_COPY_STACK_GUARD(descr) \
- ((descr)->header.stack_guard \
- = THREAD_GETMEM (THREAD_SELF, header.stack_guard))
-
/* s390 doesn't have HP_TIMING_*, so for the time being
use stack_guard as pointer_guard. */
#define THREAD_GET_POINTER_GUARD() \
@@ -51,6 +51,12 @@ typedef struct
# include <tcb-offsets.h>
#endif /* __ASSEMBLER__ */
+/* Set the stack guard field in TCB head. Referenced by elf/Versions. */
+#define THREAD_SET_STACK_GUARD(value) \
+ THREAD_SETMEM (THREAD_SELF, header.stack_guard, value)
+# define THREAD_COPY_STACK_GUARD(descr) \
+ ((descr)->header.stack_guard \
+ = THREAD_GETMEM (THREAD_SELF, header.stack_guard))
#ifndef __ASSEMBLER__
/* Get system call information. */
@@ -122,13 +128,6 @@ register struct pthread *__thread_self __asm__("%g7");
#define THREAD_SETMEM_NC(descr, member, idx, value) \
descr->member[idx] = (value)
-/* Set the stack guard field in TCB head. */
-#define THREAD_SET_STACK_GUARD(value) \
- THREAD_SETMEM (THREAD_SELF, header.stack_guard, value)
-# define THREAD_COPY_STACK_GUARD(descr) \
- ((descr)->header.stack_guard \
- = THREAD_GETMEM (THREAD_SELF, header.stack_guard))
-
/* Get/set the stack guard field in TCB head. */
#define THREAD_GET_POINTER_GUARD() \
THREAD_GETMEM (THREAD_SELF, header.pointer_guard)
@@ -3,4 +3,5 @@ GLIBC_2.1 __libc_stack_end D 0x4
GLIBC_2.1 _dl_mcount F
GLIBC_2.3 ___tls_get_addr F
GLIBC_2.3 __tls_get_addr F
+GLIBC_2.33 __stack_chk_guard D 0x4
GLIBC_2.33 __x86_get_cpu_features F
@@ -2,3 +2,4 @@ GLIBC_2.2 __libc_stack_end D 0x8
GLIBC_2.2 _dl_mcount F
GLIBC_2.2 _r_debug D 0x28
GLIBC_2.3 __tls_get_addr F
+GLIBC_2.33 __stack_chk_guard D 0x8
@@ -4,3 +4,4 @@ GLIBC_2.1 _dl_mcount F
GLIBC_2.22 __tls_get_addr_opt F
GLIBC_2.23 __parse_hwcap_and_convert_at_platform F
GLIBC_2.3 __tls_get_addr F
+GLIBC_2.33 __stack_chk_guard D 0x4
@@ -4,3 +4,4 @@ GLIBC_2.3 __libc_stack_end D 0x8
GLIBC_2.3 __tls_get_addr F
GLIBC_2.3 _dl_mcount F
GLIBC_2.3 _r_debug D 0x28
+GLIBC_2.33 __stack_chk_guard D 0x8
@@ -4,3 +4,4 @@ GLIBC_2.17 _dl_mcount F
GLIBC_2.17 _r_debug D 0x28
GLIBC_2.22 __tls_get_addr_opt F
GLIBC_2.23 __parse_hwcap_and_convert_at_platform F
+GLIBC_2.33 __stack_chk_guard D 0x8
@@ -2,3 +2,4 @@ GLIBC_2.0 _r_debug D 0x14
GLIBC_2.1 __libc_stack_end D 0x4
GLIBC_2.1 _dl_mcount F
GLIBC_2.3 __tls_get_offset F
+GLIBC_2.33 __stack_chk_guard D 0x4
@@ -2,3 +2,4 @@ GLIBC_2.2 __libc_stack_end D 0x8
GLIBC_2.2 _dl_mcount F
GLIBC_2.2 _r_debug D 0x28
GLIBC_2.3 __tls_get_offset F
+GLIBC_2.33 __stack_chk_guard D 0x8
@@ -2,3 +2,4 @@ GLIBC_2.0 _r_debug D 0x14
GLIBC_2.1 __libc_stack_end D 0x4
GLIBC_2.1 _dl_mcount F
GLIBC_2.3 __tls_get_addr F
+GLIBC_2.33 __stack_chk_guard D 0x4
@@ -2,3 +2,4 @@ GLIBC_2.2 __libc_stack_end D 0x8
GLIBC_2.2 _dl_mcount F
GLIBC_2.2 _r_debug D 0x28
GLIBC_2.3 __tls_get_addr F
+GLIBC_2.33 __stack_chk_guard D 0x8
@@ -2,4 +2,5 @@ GLIBC_2.2.5 __libc_stack_end D 0x8
GLIBC_2.2.5 _dl_mcount F
GLIBC_2.2.5 _r_debug D 0x28
GLIBC_2.3 __tls_get_addr F
+GLIBC_2.33 __stack_chk_guard D 0x8
GLIBC_2.33 __x86_get_cpu_features F
@@ -2,4 +2,5 @@ GLIBC_2.16 __libc_stack_end D 0x4
GLIBC_2.16 __tls_get_addr F
GLIBC_2.16 _dl_mcount F
GLIBC_2.16 _r_debug D 0x14
+GLIBC_2.33 __stack_chk_guard D 0x4
GLIBC_2.33 __x86_get_cpu_features F
@@ -94,6 +94,13 @@ _Static_assert (offsetof (tcbhead_t, __glibc_unused2) == 0x80,
/* Alignment requirement for the stack. */
#define STACK_ALIGN 16
+/* Set the stack guard field in TCB head. Used by elf/Versions. */
+# define THREAD_SET_STACK_GUARD(value) \
+ THREAD_SETMEM (THREAD_SELF, header.stack_guard, value)
+# define THREAD_COPY_STACK_GUARD(descr) \
+ ((descr)->header.stack_guard \
+ = THREAD_GETMEM (THREAD_SELF, header.stack_guard))
+
#ifndef __ASSEMBLER__
/* Get system call information. */
@@ -303,14 +310,6 @@ _Static_assert (offsetof (tcbhead_t, __glibc_unused2) == 0x80,
}})
-/* Set the stack guard field in TCB head. */
-# define THREAD_SET_STACK_GUARD(value) \
- THREAD_SETMEM (THREAD_SELF, header.stack_guard, value)
-# define THREAD_COPY_STACK_GUARD(descr) \
- ((descr)->header.stack_guard \
- = THREAD_GETMEM (THREAD_SELF, header.stack_guard))
-
-
/* Set the pointer guard field in the TCB head. */
# define THREAD_SET_POINTER_GUARD(value) \
THREAD_SETMEM (THREAD_SELF, header.pointer_guard, value)