[tip: locking/urgent] futex/requeue: Revert "Prevent NULL pointer dereference in remove_waiter() on self-deadlock""

From: tip-bot2 for Sebastian Andrzej Siewior

Date: Thu Jul 02 2026 - 16:19:21 EST


The following commit has been merged into the locking/urgent branch of tip:

Commit-ID: 39def6d250d370298f86c116f4ac60093cefadaa
Gitweb: https://git.kernel.org/tip/39def6d250d370298f86c116f4ac60093cefadaa
Author: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
AuthorDate: Wed, 01 Jul 2026 15:11:50 +02:00
Committer: Thomas Gleixner <tglx@xxxxxxxxxx>
CommitterDate: Thu, 02 Jul 2026 22:14:08 +02:00

futex/requeue: Revert "Prevent NULL pointer dereference in remove_waiter() on self-deadlock""

The commit cited below should not have been merged. It attemted to fix an
existing problem ansd thereby introduced new problems by keeping the
pi_state in state Q_REQUEUE_PI_IN_PROGRESS and leaking it.

Based on the commit description the intention was to handle the case
when task_blocks_on_rt_mutex() returns -EDEADLK and the following
remove_waiter() dereferences the NULL pointer in waiter->task.

That is already handled by Davidlohr in commit 40a25d59e85b3
("locking/rtmutex: Skip remove_waiter() when waiter is not enqueued") and
requires no further acting.

Revert the commit breaking the "waiter == owner" case again.

Fixes: 74e144274af39 ("futex/requeue: Prevent NULL pointer dereference in remove_waiter() on self-deadlock")
Reported-by: Michael Bommarito <michael.bommarito@xxxxxxxxx>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxx>
Cc: stable@xxxxxxxxxxxxxxx
Link: https://patch.msgid.link/20260701131150.0Ijhq4Dw@xxxxxxxxxxxxx
Closes: https://lore.kernel.org/all/20260629020049.2082397-1-michael.bommarito@xxxxxxxxx
---
kernel/futex/requeue.c | 6 ------
1 file changed, 6 deletions(-)

diff --git a/kernel/futex/requeue.c b/kernel/futex/requeue.c
index 7384672..79823ad 100644
--- a/kernel/futex/requeue.c
+++ b/kernel/futex/requeue.c
@@ -645,12 +645,6 @@ retry_private:
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,
this->rt_waiter,
this->task);