From 003a27e8195470f470f4d9384ca70d4e9fc8bd1b Mon Sep 17 00:00:00 2001 From: Nick Alcock Date: Mon, 26 Dec 2016 10:08:34 +0100 Subject: Initialize the stack guard earlier when linking statically [BZ #7065] The address of the stack canary is stored in a per-thread variable, which means that we must ensure that the TLS area is intialized before calling any -fstack-protector'ed functions. For dynamically linked applications, we ensure this (in a later patch) by disabling -fstack-protector for the whole dynamic linker, but for static applications, the AT_ENTRY address is called directly by the kernel, so we must deal with the problem differently. In static appliations, __libc_setup_tls performs the TCB setup and TLS initialization, so this commit arranges for it to be called early and unconditionally. The call (and the stack guard initialization) is before the DL_SYSDEP_OSCHECK hook, which if set will probably call functions which are stack-protected (it does on Linux and NaCL too). We also move apply_irel up, so that we can still safely call functions that require ifuncs while in __libc_setup_tls (though if stack-protection is enabled we still have to avoid calling functions that are not stack-protected at this stage). --- ChangeLog | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'ChangeLog') diff --git a/ChangeLog b/ChangeLog index f1b95e0e79..f17669931b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2016-12-26 Nick Alcock + Florian Weimer + + [BZ #7065] + Initialize the stack guard earlier when linking statically. + * sysdeps/generic/ldsodefs.h (__libc_setup_tls) + (__pthread_initialize_minimal): Declare. + * csu/libc-start.c (__pthread_initialize_minimal): Remove + declaration. + (LIBC_START_MAIN): Call __libc_setup_tls early and directly. Move + stack canary and apply_irel initialization up. Call + __pthread_initialize_minimal only if linked in. + * csu/libc-tls.c (__libc_setup_tls): Replace arguments with their + constant values. + (__pthread_initialize_minimal): Remove. + * nptl/nptl-init.c (__libc_setup_tls): Remove declaration. + (__pthread_initialize_minimal_internal): Do not call + __libc_setup_tls. + 2016-12-26 Nick Alcock [BZ #7065] -- cgit 1.4.1