mirror of
git://sourceware.org/git/glibc.git
synced 2025-01-24 12:25:35 +08:00
* sysdeps/unix/sysv/linux/lowlevelrobustlock.c
(__lll_robust_lock_wait): Fix race caused by reloading of futex value. (__lll_robust_timedlock_wait): Likewise. Reported by Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>.
This commit is contained in:
parent
f84ecfd74f
commit
6780bc44e8
@ -1,3 +1,10 @@
|
|||||||
|
2007-05-07 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* sysdeps/unix/sysv/linux/lowlevelrobustlock.c
|
||||||
|
(__lll_robust_lock_wait): Fix race caused by reloading of futex value.
|
||||||
|
(__lll_robust_timedlock_wait): Likewise.
|
||||||
|
Reported by Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>.
|
||||||
|
|
||||||
2007-05-06 Mike Frysinger <vapier@gentoo.org>
|
2007-05-06 Mike Frysinger <vapier@gentoo.org>
|
||||||
|
|
||||||
[BZ #4465]
|
[BZ #4465]
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2006 Free Software Foundation, Inc.
|
/* Copyright (C) 2006, 2007 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Jakub Jelinek <jakub@redhat.com>, 2006.
|
Contributed by Jakub Jelinek <jakub@redhat.com>, 2006.
|
||||||
|
|
||||||
@ -30,6 +30,10 @@ __lll_robust_lock_wait (int *futex)
|
|||||||
int oldval = *futex;
|
int oldval = *futex;
|
||||||
int tid = THREAD_GETMEM (THREAD_SELF, tid);
|
int tid = THREAD_GETMEM (THREAD_SELF, tid);
|
||||||
|
|
||||||
|
/* If the futex changed meanwhile try locking again. */
|
||||||
|
if (oldval == 0)
|
||||||
|
goto try;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (__builtin_expect (oldval & FUTEX_OWNER_DIED, 0))
|
if (__builtin_expect (oldval & FUTEX_OWNER_DIED, 0))
|
||||||
@ -41,6 +45,9 @@ __lll_robust_lock_wait (int *futex)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
lll_futex_wait (futex, newval);
|
lll_futex_wait (futex, newval);
|
||||||
|
|
||||||
|
try:
|
||||||
|
;
|
||||||
}
|
}
|
||||||
while ((oldval = atomic_compare_and_exchange_val_acq (futex,
|
while ((oldval = atomic_compare_and_exchange_val_acq (futex,
|
||||||
tid | FUTEX_WAITERS,
|
tid | FUTEX_WAITERS,
|
||||||
@ -57,6 +64,11 @@ __lll_robust_timedlock_wait (int *futex, const struct timespec *abstime)
|
|||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
int tid = THREAD_GETMEM (THREAD_SELF, tid);
|
int tid = THREAD_GETMEM (THREAD_SELF, tid);
|
||||||
|
int oldval = *futex;
|
||||||
|
|
||||||
|
/* If the futex changed meanwhile try locking again. */
|
||||||
|
if (oldval == 0)
|
||||||
|
goto try;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -80,7 +92,6 @@ __lll_robust_timedlock_wait (int *futex, const struct timespec *abstime)
|
|||||||
return ETIMEDOUT;
|
return ETIMEDOUT;
|
||||||
|
|
||||||
/* Wait. */
|
/* Wait. */
|
||||||
int oldval = *futex;
|
|
||||||
if (__builtin_expect (oldval & FUTEX_OWNER_DIED, 0))
|
if (__builtin_expect (oldval & FUTEX_OWNER_DIED, 0))
|
||||||
return oldval;
|
return oldval;
|
||||||
|
|
||||||
@ -90,8 +101,13 @@ __lll_robust_timedlock_wait (int *futex, const struct timespec *abstime)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
lll_futex_timed_wait (futex, newval, &rt);
|
lll_futex_timed_wait (futex, newval, &rt);
|
||||||
|
|
||||||
|
try:
|
||||||
|
;
|
||||||
}
|
}
|
||||||
while (atomic_compare_and_exchange_bool_acq (futex, tid | FUTEX_WAITERS, 0));
|
while ((oldval = atomic_compare_and_exchange_val_acq (futex,
|
||||||
|
tid | FUTEX_WAITERS,
|
||||||
|
0)) != 0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user