Skip to content

Commit

Permalink
linux-user: Use safe_syscall for futex
Browse files Browse the repository at this point in the history
Signed-off-by: Petros Angelatos <[email protected]>
  • Loading branch information
petrosagg committed Feb 9, 2016
1 parent 313be80 commit 5fc23bc
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions linux-user/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,6 @@ _syscall1(int,exit_group,int,error_code)
#if defined(TARGET_NR_set_tid_address) && defined(__NR_set_tid_address)
_syscall1(int,set_tid_address,int *,tidptr)
#endif
#if defined(TARGET_NR_futex) && defined(__NR_futex)
_syscall6(int,sys_futex,int *,uaddr,int,op,int,val,
const struct timespec *,timeout,int *,uaddr2,int,val3)
#endif
#define __NR_sys_sched_getaffinity __NR_sched_getaffinity
_syscall3(int, sys_sched_getaffinity, pid_t, pid, unsigned int, len,
unsigned long *, user_mask_ptr);
Expand Down Expand Up @@ -718,6 +714,12 @@ safe_syscall6(int, sys_pselect6, int, nfds, fd_set *, readfds, fd_set *, writefd
fd_set *, exceptfds, const struct timespec *, timeout, void *, sig);
#endif

/* futex */
#if defined(TARGET_NR_futex) && defined(__NR_futex)
safe_syscall6(int, sys_futex, int *, uaddr, int, op, int, val,
const struct timespec *, timeout, int *, uaddr2, int, val3);
#endif

/* process syscalls */
safe_syscall4(int, waitid, idtype_t, idtype, id_t, id, siginfo_t *, infop, \
int, options)
Expand Down Expand Up @@ -5398,12 +5400,11 @@ static int do_futex(target_ulong uaddr, int op, int val, target_ulong timeout,
} else {
pts = NULL;
}
return get_errno(sys_futex(g2h(uaddr), op, tswap32(val),
pts, NULL, val3));
return safe_sys_futex(g2h(uaddr), op, tswap32(val), pts, NULL, val3);
case FUTEX_WAKE:
return get_errno(sys_futex(g2h(uaddr), op, val, NULL, NULL, 0));
return safe_sys_futex(g2h(uaddr), op, val, NULL, NULL, 0);
case FUTEX_FD:
return get_errno(sys_futex(g2h(uaddr), op, val, NULL, NULL, 0));
return safe_sys_futex(g2h(uaddr), op, val, NULL, NULL, 0);
case FUTEX_REQUEUE:
case FUTEX_CMP_REQUEUE:
case FUTEX_WAKE_OP:
Expand All @@ -5413,11 +5414,10 @@ static int do_futex(target_ulong uaddr, int op, int val, target_ulong timeout,
to satisfy the compiler. We do not need to tswap TIMEOUT
since it's not compared to guest memory. */
pts = (struct timespec *)(uintptr_t) timeout;
return get_errno(sys_futex(g2h(uaddr), op, val, pts,
g2h(uaddr2),
return safe_sys_futex(g2h(uaddr), op, val, pts, g2h(uaddr2),
(base_op == FUTEX_CMP_REQUEUE
? tswap32(val3)
: val3)));
: val3));
default:
return -TARGET_ENOSYS;
}
Expand Down Expand Up @@ -5885,7 +5885,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
ts = cpu->opaque;
if (ts->child_tidptr) {
put_user_u32(0, ts->child_tidptr);
sys_futex(g2h(ts->child_tidptr), FUTEX_WAKE, INT_MAX,
safe_sys_futex(g2h(ts->child_tidptr), FUTEX_WAKE, INT_MAX,
NULL, NULL, 0);
}
thread_cpu = NULL;
Expand Down

0 comments on commit 5fc23bc

Please sign in to comment.