diff options
author | Rich Felker <dalias@aerifal.cx> | 2012-07-11 23:36:46 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2012-07-11 23:36:46 -0400 |
commit | 92f8396b0c8e4f146563b87f46137484cfb36e31 (patch) | |
tree | 62bd8daab801d7127114a33a83db28f591e01669 /src/thread/pthread_detach.c | |
parent | a03f69d4456d3ac5120cc07a22af8ecb631444bb (diff) | |
download | musl-92f8396b0c8e4f146563b87f46137484cfb36e31.tar.gz musl-92f8396b0c8e4f146563b87f46137484cfb36e31.tar.bz2 musl-92f8396b0c8e4f146563b87f46137484cfb36e31.tar.xz musl-92f8396b0c8e4f146563b87f46137484cfb36e31.zip |
fix potential race condition in detached threads
after the thread unmaps its own stack/thread structure, the kernel,
performing child tid clear and futex wake, could clobber a new mapping
made at the same location as the just-removed thread's tid field.
disable kernel clearing of child tid to prevent this.
Diffstat (limited to 'src/thread/pthread_detach.c')
-rw-r--r-- | src/thread/pthread_detach.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/thread/pthread_detach.c b/src/thread/pthread_detach.c index 8ef03d51..e8032398 100644 --- a/src/thread/pthread_detach.c +++ b/src/thread/pthread_detach.c @@ -5,7 +5,7 @@ int pthread_detach(pthread_t t) /* Cannot detach a thread that's already exiting */ if (a_swap(&t->exitlock, 1)) return pthread_join(t, 0); - t->detached = 1; - t->exitlock = 0; + t->detached = 2; + a_store(&t->exitlock, 0); return 0; } |