Fix setxid race handling exiting threads
authorAndreas Schwab <schwab@redhat.com>
Fri, 25 Jun 2010 08:41:17 +0000 (10:41 +0200)
committerAndreas Schwab <schwab@redhat.com>
Wed, 31 Aug 2011 09:21:13 +0000 (11:21 +0200)
nptl/ChangeLog
nptl/allocatestack.c

index 06d19b9..c44ce2a 100644 (file)
@@ -1,3 +1,8 @@
+2011-08-31  Andreas Schwab  <schwab@redhat.com>
+
+       * allocatestack.c (setxid_mark_thread): Ensure that the exiting
+       thread is woken up.
+
 2011-08-20  David S. Miller  <davem@davemloft.net>
 
        * Makefile (tst-cleanup0.out): Fix typo in output redirection.
index 9b8b0ce..23d2ce5 100644 (file)
@@ -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));