From: Rich Felker Date: Sun, 7 Oct 2012 03:57:51 +0000 (-0400) Subject: make new TLS setup block even implementation-internals signals X-Git-Tag: v0.9.7~50 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=00902c7384963192dda8a15938786a36dca7d7ab;p=oweals%2Fmusl.git make new TLS setup block even implementation-internals signals this is needed to ensure async-cancel-safety, i.e. to make it safe to access TLS objects when async cancellation is enabled. otherwise, if cancellation were acter upon after the atomic fetch/add but before the thread saved the obtained memory, another access to the same TLS in the cancellation handler could end up performing the atomic fetch/add again, consuming more memory than is actually available and overflowing into other objects on the heap. --- diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c index e944c8e1..93cfb429 100644 --- a/src/ldso/dynlink.c +++ b/src/ldso/dynlink.c @@ -730,8 +730,7 @@ void *__tls_get_addr(size_t *v) /* Block signals to make accessing new TLS async-signal-safe */ sigset_t set; - sigfillset(&set); - pthread_sigmask(SIG_BLOCK, &set, &set); + pthread_sigmask(SIG_BLOCK, SIGALL_SET, &set); if (self->dtv && v[0]<=(size_t)self->dtv[0] && self->dtv[v[0]]) { pthread_sigmask(SIG_SETMASK, &set, 0); return (char *)self->dtv[v[0]]+v[1];