The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v2 0/2] futex/requeue: Fix requeue PI races
@ 2026-07-22  8:51 Yao Kai
  2026-07-22  8:51 ` [PATCH v2 1/2] futex/requeue: Fix rtmutex schedule preparation for requeue PI Yao Kai
  2026-07-22  8:51 ` [PATCH v2 2/2] futex/requeue: Prevent rcuwait use-after-free during " Yao Kai
  0 siblings, 2 replies; 5+ messages in thread
From: Yao Kai @ 2026-07-22  8:51 UTC (permalink / raw)
  To: linux-kernel
  Cc: tglx, mingo, peterz, dvhart, dave, andrealmeid, bigeasy,
	liuyongqiang13

Hi,

This series fixes two independent issues in the requeue PI wait path.

Patch 1 restores rtmutex scheduling preparation when the temporary
removal of futex_q during requeue causes futex_do_wait() to skip
schedule(), while the proxy waiter still has to block on the target
rtmutex.

Patch 2 prevents the requeue side from accessing the waiter's
stack-based futex_q after publishing Q_REQUEUE_PI_LOCKED. The saved-task
wakeup in requeue_pi_wake_futex() also covers a waiter blocked in the
rcuwait synchronization path.

Changes since v1:
  - Replace the scheduler helper split in patch 1 with
    rt_mutex_pre_schedule()/rt_mutex_post_schedule() directly around
    rt_mutex_wait_proxy_lock().
  - Expand patch 2's comment and changelog to explain why the saved-task
    wakeup covers rcuwait without losing a wakeup.

Thanks to Sebastian for the review and for suggesting the simpler fix
for patch 1.

v1:
  https://lore.kernel.org/r/20260717084922.4153317-1-yaokai34@huawei.com

Testing:
  - Build-tested with non-RT and PREEMPT_RT configurations.
  - The original rt_mutex_schedule() warning reproducer no longer
    triggers the warning.
  - The original PREEMPT_RT KASAN reproducer no longer reports an
    invalid access.
  - The futex requeue PI selftests and stress tests pass.

Yao

Yao Kai (2):
  futex/requeue: Fix rtmutex schedule preparation for requeue PI
  futex/requeue: Prevent rcuwait use-after-free during requeue PI

 kernel/futex/requeue.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-08-05  8:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-22  8:51 [PATCH v2 0/2] futex/requeue: Fix requeue PI races Yao Kai
2026-07-22  8:51 ` [PATCH v2 1/2] futex/requeue: Fix rtmutex schedule preparation for requeue PI Yao Kai
2026-08-04 12:21   ` Peter Zijlstra
2026-08-05  8:00     ` Yao Kai
2026-07-22  8:51 ` [PATCH v2 2/2] futex/requeue: Prevent rcuwait use-after-free during " Yao Kai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox