From: Andreas Schwab Date: Fri, 25 Jun 2010 08:41:17 +0000 (+0200) Subject: Fix setxid race handling exiting threads X-Git-Tag: glibc-2.14.1~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=69c1dfc1a7964cc15d429350905aea821803a40c;p=thirdparty%2Fglibc.git Fix setxid race handling exiting threads (cherry picked from commit 523df511514331a7fa0668b37a917b52f71684af) --- diff --git a/nptl/ChangeLog b/nptl/ChangeLog index 7411ae5e6fe..c4ae3cb38b0 100644 --- a/nptl/ChangeLog +++ b/nptl/ChangeLog @@ -1,3 +1,8 @@ +2011-08-31 Andreas Schwab + + * allocatestack.c (setxid_mark_thread): Ensure that the exiting + thread is woken up. + 2011-08-08 Andreas Schwab * sysdeps/unix/sysv/linux/x86_64/cancellation.S: Maintain aligned diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c index 82408f5178f..d4364bf218b 100644 --- a/nptl/allocatestack.c +++ b/nptl/allocatestack.c @@ -999,7 +999,16 @@ setxid_mark_thread (struct xid_command *cmdp, struct pthread *t) /* If the thread is exiting right now, ignore it. */ if ((ch & EXITING_BITMASK) != 0) - return; + { + /* Release the futex if there is no other setxid in + progress. */ + if ((ch & SETXID_BITMASK) == 0) + { + t->setxid_futex = 1; + lll_futex_wake (&t->setxid_futex, 1, LLL_PRIVATE); + } + return; + } } while (atomic_compare_and_exchange_bool_acq (&t->cancelhandling, ch | SETXID_BITMASK, ch));