浏览代码

nptl: sh: fix race condition in lll_wait_tid

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>
Stas Sergeev 13 年之前
父节点
当前提交
0dcc13bf7a
共有 1 个文件被更改,包括 3 次插入3 次删除
  1. 3 3
      libpthread/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h

+ 3 - 3
libpthread/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h

@@ -396,9 +396,9 @@ extern int __lll_unlock_wake (int *__futex, int private) attribute_hidden;
 
 
 #define lll_wait_tid(tid) \
 #define lll_wait_tid(tid) \
   do {									      \
   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)
   } while (0)
 
 
 extern int __lll_timedwait_tid (int *tid, const struct timespec *abstime)
 extern int __lll_timedwait_tid (int *tid, const struct timespec *abstime)