mirror of
https://sourceware.org/git/glibc.git
synced 2025-09-02 16:01:20 +03:00
* elf/Versions [GLIBC_PRIVATE]: Export __pointer_chk_guard if defined.
* elf/rtld.c: Define __pointer_chk_guard_local and if necessary __pointer_chk_guard. (_rtld_global_ro): Initialize _dl_pointer_guard. (dl_main): Initialize __pointer_chk_guard_local and either __pointer_chk_guard or TLS value if necessary. (process_envvars): Recognize and handle LD_POINTER_GUARD. * sysdeps/generic/ldsodefs.h (rtld_global_ro): Add _dl_pointer_guard. * sysdeps/i386/__longjmp.S: Use PTR_DEMANGLE for PC if defined. * sysdeps/x86_64/__longjmp.S: Likewise. * sysdeps/i386/bsd-_setjmp.S: Use PTR_MANGLE for PC if defined. * sysdeps/i386/bsd-_setjmp.S: Likewise. * sysdeps/i386/setjmp.S: Likewise. [IS_IN_rtld]: Avoid call to __sigjmp_save. * sysdeps/i386/setjmp.S: Likewise. * sysdeps/unix/sysv/linux/i386/sysdep.h: Define PTR_MANGLE and PTR_DEMANGLE. * sysdeps/unix/sysv/linux/x86_64/sysdep.h: Likewise. * sysdeps/i386/elf/setjmp.S: Removed. * sysdeps/i386/elf/bsd-setjmp.S: Removed.
This commit is contained in:
32
elf/rtld.c
32
elf/rtld.c
@@ -90,6 +90,15 @@ INTDEF(_dl_argv)
|
||||
uintptr_t __stack_chk_guard attribute_relro;
|
||||
#endif
|
||||
|
||||
/* Only exported for architectures that don't store the pointer guard
|
||||
value in thread local area. */
|
||||
uintptr_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)
|
||||
#endif
|
||||
|
||||
|
||||
/* List of auditing DSOs. */
|
||||
static struct audit_list
|
||||
{
|
||||
@@ -142,6 +151,7 @@ struct rtld_global_ro _rtld_global_ro attribute_relro =
|
||||
._dl_hwcap_mask = HWCAP_IMPORTANT,
|
||||
._dl_lazy = 1,
|
||||
._dl_fpu_control = _FPU_DEFAULT,
|
||||
._dl_pointer_guard = 1,
|
||||
|
||||
/* Function pointers. */
|
||||
._dl_debug_printf = _dl_debug_printf,
|
||||
@@ -1823,6 +1833,20 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n",
|
||||
__stack_chk_guard = stack_chk_guard;
|
||||
#endif
|
||||
|
||||
/* Set up the pointer guard as well, if necessary. */
|
||||
if (GLRO(dl_pointer_guard))
|
||||
{
|
||||
// XXX If it is cheap, we should use a separate value.
|
||||
uintptr_t pointer_chk_guard;
|
||||
hp_timing_t now;
|
||||
HP_TIMING_NOW (now);
|
||||
pointer_chk_guard = stack_chk_guard ^ now;
|
||||
#ifdef THREAD_SET_POINTER_GUARD
|
||||
THREAD_SET_POINTER_GUARD (pointer_chk_guard);
|
||||
#endif
|
||||
__pointer_chk_guard_local = pointer_chk_guard;
|
||||
}
|
||||
|
||||
if (__builtin_expect (mode, normal) != normal)
|
||||
{
|
||||
/* We were run just to list the shared libraries. It is
|
||||
@@ -2575,7 +2599,13 @@ process_envvars (enum mode *modep)
|
||||
#endif
|
||||
if (!INTUSE(__libc_enable_secure)
|
||||
&& memcmp (envline, "USE_LOAD_BIAS", 13) == 0)
|
||||
GLRO(dl_use_load_bias) = envline[14] == '1' ? -1 : 0;
|
||||
{
|
||||
GLRO(dl_use_load_bias) = envline[14] == '1' ? -1 : 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (memcmp (envline, "POINTER_GUARD", 13) == 0)
|
||||
GLRO(dl_pointer_guard) = envline[14] == '0';
|
||||
break;
|
||||
|
||||
case 14:
|
||||
|
Reference in New Issue
Block a user