mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-16 17:57:38 -04:00
futex/requeue: Prevent NULL pointer dereference in remove_waiter() on self-deadlock
When FUTEX_CMP_REQUEUE_PI requeues a non-top waiter that already owns the
target PI futex, task_blocks_on_rt_mutex() returns -EDEADLK before setting
waiter->task.
The subsequent remove_waiter() in rt_mutex_start_proxy_lock() dereferences
the NULL waiter->task, causing a kernel crash.
Add a self-deadlock check for non-top waiters before calling
rt_mutex_start_proxy_lock(), analogous to the top-waiter check in
futex_lock_pi_atomic().
Fixes: 3bfdc63936 ("rtmutex: Use waiter::task instead of current in remove_waiter()")
Signed-off-by: Ji'an Zhou <eilaimemedsnaimel@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Cc: stable@vger.kernel.org
This commit is contained in:
committed by
Thomas Gleixner
parent
e43ffb69e0
commit
74e144274a
@@ -643,6 +643,12 @@ int futex_requeue(u32 __user *uaddr1, unsigned int flags1,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Self-deadlock: non-top waiter already owns the PI futex. */
|
||||||
|
if (rt_mutex_owner(&pi_state->pi_mutex) == this->task) {
|
||||||
|
ret = -EDEADLK;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
ret = rt_mutex_start_proxy_lock(&pi_state->pi_mutex,
|
ret = rt_mutex_start_proxy_lock(&pi_state->pi_mutex,
|
||||||
this->rt_waiter,
|
this->rt_waiter,
|
||||||
this->task);
|
this->task);
|
||||||
|
|||||||
Reference in New Issue
Block a user