summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorMateusz Nosek <mateusznosek0@gmail.com>2020-09-27 02:08:58 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-11-05 11:43:13 +0100
commit2db7590371520735366639647352b44c0eeda11f (patch)
tree0d06e71b546ceb94a37b3685beb051a5af19b5a6 /kernel
parent87d9ac94c7e77fb44d275912f467376cc115c840 (diff)
futex: Fix incorrect should_fail_futex() handling
[ Upstream commit 921c7ebd1337d1a46783d7e15a850e12aed2eaa0 ] 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: 6b4f4bc9cb22 ("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 Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/futex.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/kernel/futex.c b/kernel/futex.c
index 5660c02b01b0..17fba7a986e0 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -1594,8 +1594,10 @@ static int wake_futex_pi(u32 __user *uaddr, u32 uval, struct futex_pi_state *pi_
*/
newval = FUTEX_WAITERS | task_pid_vnr(new_owner);
- if (unlikely(should_fail_futex(true)))
+ if (unlikely(should_fail_futex(true))) {
ret = -EFAULT;
+ goto out_unlock;
+ }
ret = cmpxchg_futex_value_locked(&curval, uaddr, uval, newval);
if (!ret && (curval != uval)) {