diff options
author | Ulrich Drepper <drepper@redhat.com> | 2010-03-05 11:23:28 -0800 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2010-03-05 11:23:28 -0800 |
commit | 66f1b8eeb20c49c8566abeeacf36540f258ad5f4 (patch) | |
tree | 1149fbc80470ff586f1815d334b5308ad24cc4cb /nptl/pthread_create.c | |
parent | 01f1f5ee8b58d5a3dce5250ed3514e9dfa5ceff4 (diff) | |
download | glibc-66f1b8eeb20c49c8566abeeacf36540f258ad5f4.tar.gz glibc-66f1b8eeb20c49c8566abeeacf36540f258ad5f4.tar.xz glibc-66f1b8eeb20c49c8566abeeacf36540f258ad5f4.zip |
Fix setxid race with thread creation
Diffstat (limited to 'nptl/pthread_create.c')
-rw-r--r-- | nptl/pthread_create.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c index 89938b3fb8..194a8ba0ab 100644 --- a/nptl/pthread_create.c +++ b/nptl/pthread_create.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2007,2008,2009 Free Software Foundation, Inc. +/* Copyright (C) 2002-2007,2008,2009,2010 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -239,6 +239,10 @@ start_thread (void *arg) /* Initialize resolver state pointer. */ __resp = &pd->res; + /* Allow setxid from now onwards. */ + if (__builtin_expect (atomic_exchange_acq (&pd->setxid_futex, 0) == -2, 0)) + lll_futex_wake (&pd->setxid_futex, 1, LLL_PRIVATE); + #ifdef __NR_set_robust_list # ifndef __ASSUME_SET_ROBUST_LIST if (__set_robust_list_avail >= 0) @@ -538,6 +542,9 @@ __pthread_create_2_1 (newthread, attr, start_routine, arg) } } + /* Don't allow setxid until cloned. */ + pd->setxid_futex = -1; + /* Pass the descriptor to the caller. */ *newthread = (pthread_t) pd; |