Skip to content

Commit cffcf52

Browse files
committed
Merge tag 'locking-urgent-2026-05-03' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull locking fix from Ingo Molnar: "Fix lockup in requeue-PI during signal/timeout wakeups, by Sebastian Andrzej Siewior" * tag 'locking-urgent-2026-05-03' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: futex: Prevent lockup in requeue-PI during signal/ timeout wakeup
2 parents c3cba36 + bc7304f commit cffcf52

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

kernel/futex/requeue.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,11 @@ futex_proxy_trylock_atomic(u32 __user *pifutex, struct futex_hash_bucket *hb1,
319319
return -EINVAL;
320320

321321
/* Ensure that this does not race against an early wakeup */
322-
if (!futex_requeue_pi_prepare(top_waiter, NULL))
322+
if (!futex_requeue_pi_prepare(top_waiter, NULL)) {
323+
plist_del(&top_waiter->list, &hb1->chain);
324+
futex_hb_waiters_dec(hb1);
323325
return -EAGAIN;
326+
}
324327

325328
/*
326329
* Try to take the lock for top_waiter and set the FUTEX_WAITERS bit
@@ -722,10 +725,12 @@ int handle_early_requeue_pi_wakeup(struct futex_hash_bucket *hb,
722725

723726
/*
724727
* We were woken prior to requeue by a timeout or a signal.
725-
* Unqueue the futex_q and determine which it was.
728+
* Conditionally unqueue the futex_q and determine which it was.
726729
*/
727-
plist_del(&q->list, &hb->chain);
728-
futex_hb_waiters_dec(hb);
730+
if (!plist_node_empty(&q->list)) {
731+
plist_del(&q->list, &hb->chain);
732+
futex_hb_waiters_dec(hb);
733+
}
729734

730735
/* Handle spurious wakeups gracefully */
731736
ret = -EWOULDBLOCK;

0 commit comments

Comments
 (0)