kernel/futex.c: fix incorrect 'should_fail_futex' handling
PATCH 1/1 kernel/futex.c: fix incorrect 'should_fail_futex' handling
From: Mateusz Nosek <[email protected]>
Previously if 'futex_should_fail' returned true, then only 'ret' variable was set, which was later overwritten without being read. The patch fixes the problem.
--- kernel/futex.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/futex.c +3 -1
@@ -1502,8 +1502,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)) {
Signature · 1 line
2.20.1
[tip: locking/urgent] futex: Fix incorrect should_fail_futex() handling
The following commit has been merged into the locking/urgent branch of tip:
The following commit has been merged into the locking/urgent branch of tip:
Commit-ID: 921c7ebd1337d1a46783d7e15a850e12aed2eaa0 Gitweb: https://git.kernel.org/tip/921c7ebd1337d1a46783d7e15a850e12aed2eaa0 Author: Mateusz Nosek <[email protected]> AuthorDate: Sun, 27 Sep 2020 02:08:58 +02:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Wed, 28 Oct 2020 15:48:51 +01:00
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 ]
--- kernel/futex.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/futex.c +3 -1
@@ -1502,8 +1502,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)) {