mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Yao Kai <yaokai34@huawei.com>
Cc: linux-kernel@vger.kernel.org, tglx@kernel.org, mingo@redhat.com,
	peterz@infradead.org, dvhart@infradead.org, dave@stgolabs.net,
	andrealmeid@igalia.com, liuyongqiang13@huawei.com
Subject: Re: [PATCH 2/2] futex/requeue: Prevent rcuwait use-after-free during requeue PI
Date: Tue, 21 Jul 2026 09:19:14 +0200	[thread overview]
Message-ID: <20260721071914.48_P-BjT@linutronix.de> (raw)
In-Reply-To: <c8d2128a-cb6d-4817-99e7-01dc380b579c@huawei.com>

On 2026-07-21 10:19:57 [+0800], Yao Kai wrote:
> > 
> > You will miss to wake T1 if T2 skips the wake, as suggested. Or do I
> > miss something?
> > 
> 
>    T1                                         T2
>  futex_requeue_pi_wakeup_sync()
>     old = Q_REQUEUE_PI_IN_PROGRESS
>     new = Q_REQUEUE_PI_WAIT
>     cmpxchg()
>                                              requeue_pi_wake_futex()
>                                                task = READ_ONCE(q->task)
>                                                  futex_requeue_pi_complete()
>                                                    old = Q_REQUEUE_PI_WAIT
>                                                    new = Q_REQUEUE_PI_LOCKED
>                                                    cmpxchg()
>     if (old == Q_REQUEUE_PI_IN_PROGRESS)
>      rcuwait_wait_event()
>                                                    rcuwait_wake_up(&q->requeue_wait);
>                                                wake_up_state(task, TASK_NORMAL)
>     <leave>
> 
> Only requeue_pi_wake_futex() can publish Q_REQUEUE_PI_LOCKED. After it calls
> futex_requeue_pi_complete(), it will call wake_up_state(task, TASK_NORMAL)
> to wake up T1 sleeping on rcuwait_wait_event().

That one is intended for the futex_do_wait() but it seems that the outer
wake_up_state() would save the day.
It would deserve a comment and explanation at the least.

> Yao

Sebastian

      reply	other threads:[~2026-07-21  7:19 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-17  8:49 [PATCH 0/2] futex/requeue: Fix requeue PI races Yao Kai
2026-07-17  8:49 ` [PATCH 1/2] futex/requeue: Fix rtmutex schedule preparation for requeue PI Yao Kai
2026-07-17  8:55   ` Sebastian Andrzej Siewior
2026-07-20  2:40     ` Yao Kai
2026-07-20 14:58       ` Sebastian Andrzej Siewior
2026-07-21  1:51         ` Yao Kai
2026-07-21  7:23           ` Sebastian Andrzej Siewior
2026-07-21  9:02             ` Yao Kai
2026-07-21  9:45               ` Sebastian Andrzej Siewior
2026-07-17  8:49 ` [PATCH 2/2] futex/requeue: Prevent rcuwait use-after-free during " Yao Kai
2026-07-17  9:38   ` Sebastian Andrzej Siewior
2026-07-20  2:50     ` Yao Kai
2026-07-20 14:55       ` Sebastian Andrzej Siewior
2026-07-21  2:19         ` Yao Kai
2026-07-21  7:19           ` Sebastian Andrzej Siewior [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260721071914.48_P-BjT@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=andrealmeid@igalia.com \
    --cc=dave@stgolabs.net \
    --cc=dvhart@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liuyongqiang13@huawei.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@kernel.org \
    --cc=yaokai34@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome