Skip to content

Commit 921c7eb

Browse files
Mateusz NosekKAGA-KOKO
authored andcommitted
futex: Fix incorrect should_fail_futex() handling
If should_futex_fail() returns true in futex_wake_pi(), then the 'ret' variable is set to -EFAULT and then immediately overwritten. So the failure injection is non-functional. Fix it by actually leaving the function and returning -EFAULT. The Fixes tag is kinda blury because the initial commit which introduced failure injection was already sloppy, but the below mentioned commit broke it completely. [ tglx: Massaged changelog ] Fixes: 6b4f4bc ("locking/futex: Allow low-level atomic operations to return -EAGAIN") Signed-off-by: Mateusz Nosek <mateusznosek0@gmail.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/r/20200927000858.24219-1-mateusznosek0@gmail.com
1 parent f8e48a3 commit 921c7eb

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

kernel/futex.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1502,8 +1502,10 @@ static int wake_futex_pi(u32 __user *uaddr, u32 uval, struct futex_pi_state *pi_
15021502
*/
15031503
newval = FUTEX_WAITERS | task_pid_vnr(new_owner);
15041504

1505-
if (unlikely(should_fail_futex(true)))
1505+
if (unlikely(should_fail_futex(true))) {
15061506
ret = -EFAULT;
1507+
goto out_unlock;
1508+
}
15071509

15081510
ret = cmpxchg_futex_value_locked(&curval, uaddr, uval, newval);
15091511
if (!ret && (curval != uval)) {

0 commit comments

Comments
 (0)