aboutsummaryrefslogtreecommitdiffstats
path: root/libc/bionic/pthread.c
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2012-10-25 12:22:34 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-10-25 12:22:34 -0700
commitdf7f24f310ee3ceb1dc9413d59d5a8816eb584ef (patch)
tree3ea53e1b84167d1479e4688be60fa036c8be7ce4 /libc/bionic/pthread.c
parent60c7ac262241588f7942ca068f33d706c8fe5cc4 (diff)
parent7b68e3f799d87e84c56687033326924fd8fec84c (diff)
downloadandroid_bionic-df7f24f310ee3ceb1dc9413d59d5a8816eb584ef.tar.gz
android_bionic-df7f24f310ee3ceb1dc9413d59d5a8816eb584ef.tar.bz2
android_bionic-df7f24f310ee3ceb1dc9413d59d5a8816eb584ef.zip
am 7b68e3f7: Merge "Per-thread -fstack-protector guards for x86."
* commit '7b68e3f799d87e84c56687033326924fd8fec84c': Per-thread -fstack-protector guards for x86.
Diffstat (limited to 'libc/bionic/pthread.c')
-rw-r--r--libc/bionic/pthread.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libc/bionic/pthread.c b/libc/bionic/pthread.c
index 719bc83b5..7c22b45b2 100644
--- a/libc/bionic/pthread.c
+++ b/libc/bionic/pthread.c
@@ -48,6 +48,7 @@
#include "bionic_atomic_inline.h"
#include "bionic_futex.h"
#include "bionic_pthread.h"
+#include "bionic_ssp.h"
#include "bionic_tls.h"
#include "pthread_internal.h"
#include "thread_private.h"
@@ -171,12 +172,14 @@ void __init_tls(void** tls, void* thread) {
tls[i] = NULL;
}
- // Slot 0 must point to the tls area, this is required by the implementation
- // of the x86 Linux kernel thread-local-storage.
+ // Slot 0 must point to itself. The x86 Linux kernel reads the TLS from %fs:0.
tls[TLS_SLOT_SELF] = (void*) tls;
tls[TLS_SLOT_THREAD_ID] = thread;
+ // Stack guard generation may make system calls, and those system calls may fail.
+ // If they do, they'll try to set errno, so we can only do this after calling __set_tls.
__set_tls((void*) tls);
+ tls[TLS_SLOT_STACK_GUARD] = __generate_stack_chk_guard();
}