OSDN Git Service

nptl: sh: fix race condition in lll_wait_tid
authorStas Sergeev <stsp@users.sourceforge.net>
Wed, 13 Jun 2012 23:00:02 +0000 (01:00 +0200)
committerCarmelo Amoroso <carmelo.amoroso@st.com>
Tue, 19 Jun 2012 07:42:31 +0000 (09:42 +0200)
Make a local copy of the tid value to avoid a race condition,
as the value could have been changed to 0, thus using a pointer
it would have been passed to the lll_futex_wait modified.

Signed-off-by: Stas Sergeev <stsp@users.sourceforge.net>
Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
libpthread/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h

index d10cd61..b83d863 100644 (file)
@@ -396,9 +396,9 @@ extern int __lll_unlock_wake (int *__futex, int private) attribute_hidden;
 
 #define lll_wait_tid(tid) \
   do {                                                                       \
-    __typeof (tid) *__tid = &(tid);                                          \
-    while (*__tid != 0)                                                              \
-      lll_futex_wait (__tid, *__tid, LLL_SHARED);                            \
+    __typeof (tid) __tid;                                                    \
+    while ((__tid = (tid)) != 0)                                                     \
+      lll_futex_wait (&(tid), __tid, LLL_SHARED);                            \
   } while (0)
 
 extern int __lll_timedwait_tid (int *tid, const struct timespec *abstime)