Skip to content
This repository was archived by the owner on Jun 9, 2020. It is now read-only.

Commit fcab6c6

Browse files
committed
Fix futex() to return EWOULDBLOCK if *uaddr != val
futex() did not implement this, causing pthread_join() to wait forever if FUTEX_WAIT is called after FUTEX_WAKE.
1 parent 46437cb commit fcab6c6

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/ipc/futex.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ do_private_futex(gaddr_t uaddr, int op, uint32_t val, gaddr_t timeout_ptr, gaddr
117117
return do_private_futex_wake(uaddr, val, false, 0);
118118
}
119119
case LINUX_FUTEX_WAIT: {
120+
uint32_t uval;
121+
if (copy_from_user(&uval, uaddr, sizeof uval))
122+
return -LINUX_EFAULT;
123+
if (uval != val)
124+
return -EWOULDBLOCK;
120125
struct timespec ts;
121126
if (timeout_ptr != 0) {
122127
struct l_timespec timeout;

0 commit comments

Comments
 (0)