mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Yang Zi <2959243019@qq.com>
Cc: boqun@kernel.org, longman@redhat.com, mingo@redhat.com,
	will@kernel.org, linux-kernel@vger.kernel.org,
	Paul McKenney <paulmck@kernel.org>
Subject: Re: [PATCH] locking/mutex: Restore RCU read-side protection for optimistic spinning
Date: Tue, 25 Aug 2026 11:22:47 +0200	[thread overview]
Message-ID: <20260825092247.GE4120091@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <tencent_1D6028A737D259C04C4B2A45368C57A79806@qq.com>

On Tue, Aug 25, 2026 at 05:13:30PM +0800, Yang Zi wrote:
> The optimistic spinning paths in kernel/locking/mutex.c dereference the
> current lock owner's task_struct (via owner_on_cpu() -> owner->on_cpu and
> task_cpu(owner)) without any lifetime protection on the owner pointer.
> 
> __mutex_owner() (kernel/locking/mutex.h) returns a bare task_struct
> pointer that is read directly from lock->owner. mutex_spin_on_owner() and
> mutex_can_spin_on_owner() then dereference it inside "while
> (__mutex_owner(lock) == owner)" / immediately after the owner load, while
> relying only on preempt_disable().
> 
> Since commit 6c2787f2a20c ("locking: Remove rcu_read_{,un}lock() for
> preempt_{dis,en}able()"), the code has assumed that preempt_disable() is
> equivalent to an RCU read-side critical section and therefore that the
> owner's task_struct "won't go away during the spinning period". That
> assumption does not hold on PREEMPT_LAZY kernels: preempt_disable() there
> no longer actually disables preemption, so the RCU callback that frees a
> just-exited owner's task_struct (put_task_struct_rcu_user() ->
> call_rcu(), run in rcu_do_batch()) can fire and free the object while a
> spinner still holds the stale pointer, leading to a slab use-after-free
> read of owner->on_cpu.

This doesn't make sense, rcu_preempt was subsumed (again) into regular
rcu proper (along with rcu_bh). Any preempt disable region will prohibit
the GP from advancing.

  reply	other threads:[~2026-08-25  9:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-25  9:13 Yang Zi
2026-08-25  9:22 ` Peter Zijlstra [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-08-25  9:20 Yang Zi
2026-08-25  9:11 Yang Zi

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=20260825092247.GE4120091@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=2959243019@qq.com \
    --cc=boqun@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mingo@redhat.com \
    --cc=paulmck@kernel.org \
    --cc=will@kernel.org \
    /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

all inboxes | Powered by JetHome®