Skip to content

Commit

Permalink
sh: fix futex FUTEX_OP_SET op on userspace addresses
Browse files Browse the repository at this point in the history
Commit 00b73d8 ("sh: add working futex atomic ops on userspace
addresses for smp") changed the futex_atomic_op_inuser function to
use a loop. In case of the FUTEX_OP_SET op with a userspace address
containing a value different of 0, this loop is an endless loop.

Fix that by loading the value of oldval from the userspace before doing
the cmpxchg op, also for the FUTEX_OP_SET case.

Signed-off-by: Aurelien Jarno <[email protected]>
Signed-off-by: Rich Felker <[email protected]>
  • Loading branch information
aurel32 authored and Rich Felker committed Apr 12, 2018
1 parent 0adb328 commit 9b7e30a
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions arch/sh/include/asm/futex.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ static inline int arch_futex_atomic_op_inuser(int op, u32 oparg, int *oval,
pagefault_disable();

do {
if (op == FUTEX_OP_SET)
ret = oldval = 0;
else
ret = get_user(oldval, uaddr);
ret = get_user(oldval, uaddr);

if (ret) break;

Expand Down

0 comments on commit 9b7e30a

Please sign in to comment.