From: Jeff Layton <jlayton@kernel.org>
To: Al Viro <viro@zeniv.linux.org.uk>, Jann Horn <jannh@google.com>
Cc: Thomas Gleixner <tglx@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>, Will Deacon <will@kernel.org>,
Boqun Feng <boqun@kernel.org>, Waiman Long <longman@redhat.com>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Clark Williams <clrkwllms@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
syzbot <syzbot+000c800a02097aaa10ed@syzkaller.appspotmail.com>,
Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
kernel list <linux-kernel@vger.kernel.org>,
syzkaller-bugs <syzkaller-bugs@googlegroups.com>
Subject: Re: rt_spin_unlock order of operations [was: Re: [syzbot] [fs?] KASAN: slab-use-after-free Read in shrink_dcache_tree]
Date: Sat, 20 Jun 2026 20:46:56 -0400 [thread overview]
Message-ID: <ccc5702c1fb88957f14d713826a77a541e859d20.camel@kernel.org> (raw)
In-Reply-To: <20260618205953.GZ2636677@ZenIV>
On Thu, 2026-06-18 at 21:59 +0100, Al Viro wrote:
> On Thu, Jun 18, 2026 at 08:44:32PM +0200, Jann Horn wrote:
> > I think this is more of a bug in RT spinlocks than a VFS bug, though
> > it's a bit murky.
> >
> > rt_spin_unlock() looks like this:
> >
> > void __sched rt_spin_unlock(spinlock_t *lock) __releases(RCU)
> > {
> > spin_release(&lock->dep_map, _RET_IP_);
> > migrate_enable();
> > rcu_read_unlock();
> >
> > if (unlikely(!rt_mutex_cmpxchg_release(&lock->lock, current, NULL)))
> > rt_mutex_slowunlock(&lock->lock);
> > }
> >
> > Note how the RCU read-side critical section and the protection against
> > migration end *before* the lock is actually released, which means this
> > can UAF if the RCU read-side critical section implied by the spinlock
> > is the only thing keeping the lock alive. While non-RT spinlocks do
> > this the other way around (do_raw_spin_unlock() before
> > preempt_enable()):
> >
> > static inline void __raw_spin_unlock(raw_spinlock_t *lock)
> > __releases(lock)
> > {
> > spin_release(&lock->dep_map, _RET_IP_);
> > do_raw_spin_unlock(lock);
> > preempt_enable();
> > }
> >
> > https://docs.kernel.org/next/RCU/whatisRCU.html guarantees that
> > spinlock APIs imply RCU, and
> > https://docs.kernel.org/locking/mutex-design.html says: "This is in
> > contrast with spin_unlock() [...], which APIs can be used to guarantee
> > that the memory is not touched by the lock implementation after
> > spin_unlock()/completion_done() releases the lock.".
> > Neither of these explicitly guarantees that the RCU read-side critical
> > section (and the protection against migration?) should still hold
> > while the lock is being dropped, but I think that would fit best with
> > the explicit guarantees?
>
> I'm trying to recall if PREEMPT_RT had been enabled in the last round of
> UAF in that area back in early April...
>
> As far as I'm concerned, we *do* need to keep RCU read-side critical area
> all the way until the end of spin_unlock(); it very well might be the
> only thing to prevent freeing the sucker under us.
Sorry for late reply, but I think it was not enabled in those kernels.
This was in the mail that I sent on April 10th:
# zgrep PREEMPT /proc/config.gz
CONFIG_PREEMPT_NONE_BUILD=y
CONFIG_ARCH_HAS_PREEMPT_LAZY=y
CONFIG_PREEMPT_NONE=y
# CONFIG_PREEMPT_VOLUNTARY is not set
# CONFIG_PREEMPT is not set
# CONFIG_PREEMPT_LAZY is not set
# CONFIG_PREEMPT_RT is not set
# CONFIG_PREEMPT_DYNAMIC is not set
CONFIG_HAVE_PREEMPT_DYNAMIC=y
CONFIG_HAVE_PREEMPT_DYNAMIC_CALL=y
CONFIG_PREEMPT_NOTIFIERS=y
# CONFIG_PREEMPTIRQ_DELAY_TEST is not set
--
Jeff Layton <jlayton@kernel.org>
prev parent reply other threads:[~2026-06-21 0:47 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-17 17:08 [syzbot] [fs?] KASAN: slab-use-after-free Read in shrink_dcache_tree syzbot
2026-06-18 18:44 ` rt_spin_unlock order of operations [was: Re: [syzbot] [fs?] KASAN: slab-use-after-free Read in shrink_dcache_tree] Jann Horn
2026-06-18 20:59 ` Al Viro
2026-06-18 21:03 ` Al Viro
2026-06-18 22:24 ` Thomas Gleixner
2026-06-19 1:36 ` Al Viro
2026-06-19 8:39 ` Sebastian Andrzej Siewior
2026-06-19 12:46 ` Thomas Gleixner
2026-06-19 12:52 ` [PATCH V2] locking/rt: Fix the incorrect RCU protection in rt_spin_unlock() Thomas Gleixner
2026-06-19 12:58 ` Sebastian Andrzej Siewior
2026-06-20 6:44 ` Al Viro
2026-06-20 21:45 ` Thomas Gleixner
2026-06-21 9:54 ` [tip: locking/urgent] " tip-bot2 for Thomas Gleixner
2026-06-21 0:46 ` Jeff Layton [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=ccc5702c1fb88957f14d713826a77a541e859d20.camel@kernel.org \
--to=jlayton@kernel.org \
--cc=bigeasy@linutronix.de \
--cc=boqun@kernel.org \
--cc=brauner@kernel.org \
--cc=clrkwllms@kernel.org \
--cc=jack@suse.cz \
--cc=jannh@google.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=syzbot+000c800a02097aaa10ed@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=tglx@kernel.org \
--cc=viro@zeniv.linux.org.uk \
--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