aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2021-07-06 16:36:54 +0200
committerSebastian Andrzej Siewior <bigeasy@linutronix.de>2021-08-16 10:41:48 +0200
commit7384201f9701c226cb1dd04cf76c12c33762bb30 (patch)
treecc37f8001a2e71cfb5a76ed39239f917daefff2d
parent5fc824e6e0d0596a5db2fa778857a0f7293ed27d (diff)
downloadlinux-rt-devel-7384201f9701c226cb1dd04cf76c12c33762bb30.tar.gz
futex: Validate waiter correctly in futex_proxy_trylock_atomic()
Notice: this object is not reachable from any branch.
The loop in futex_requeue() has a sanity check for the waiter which is missing in futex_proxy_trylock_atomic(). In theory the key2 check is sufficient, but futexes are cursed so add it for completeness and paranoia sake. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Notice: this object is not reachable from any branch.
-rw-r--r--kernel/futex.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/kernel/futex.c b/kernel/futex.c
index 21625cb3e865c..a1f27fd55a232 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -1879,6 +1879,13 @@ futex_proxy_trylock_atomic(u32 __user *pifutex, struct futex_hash_bucket *hb1,
if (!top_waiter)
return 0;
+ /*
+ * Ensure that this is a waiter sitting in futex_wait_requeue_pi()
+ * and waiting on the 'waitqueue' futex which is always !PI.
+ */
+ if (!top_waiter->rt_waiter || top_waiter->pi_state)
+ ret = -EINVAL;
+
/* Ensure we requeue to the expected futex. */
if (!match_futex(top_waiter->requeue_pi_key, key2))
return -EINVAL;