From: Peter Zijlstra <peterz@infradead.org>
To: Haocheng Yu <yuhaocheng035@gmail.com>
Cc: acme@kernel.org, security@kernel.org,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
gregkh@linuxfoundation.org
Subject: Re: [PATCH] perf/core: Fix refcount bug and potential UAF in perf_mmap
Date: Mon, 2 Feb 2026 15:36:15 +0100 [thread overview]
Message-ID: <20260202143615.GC1395416@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20260202135859.GH1395266@noisy.programming.kicks-ass.net>
On Mon, Feb 02, 2026 at 02:58:59PM +0100, Peter Zijlstra wrote:
> On Mon, Feb 02, 2026 at 03:44:35PM +0800, Haocheng Yu wrote:
> > Syzkaller reported a refcount_t: addition on 0; use-after-free warning
> > in perf_mmap.
> >
> > The issue is caused by a race condition between mmap() and event
> > teardown. In perf_mmap(), the ring_buffer (rb) is accessed via
> > map_range() after the mmap_mutex is released. If another thread
> > closes the event or detaches the buffer during this window, the
> > reference count of rb can drop to zero, leading to a UAF or
> > refcount saturation when map_range() or subsequent logic attempts
> > to use it.
>
> So you're saying this is something like:
>
> Thread-1 Thread-2
>
> mmap(fd)
> close(fd) / ioctl(fd, IOC_SET_OUTPUT)
>
>
> I don't think close() is possible, because mmap() should have a
> reference on the struct file from fget(), no?
>
> That leaves the ioctl(), let me go have a peek.
I'm not seeing it; once perf_mmap_rb() completes, we should have
event->mmap_count != 0, and this the IOC_SET_OUTPUT will fail.
Please provide a better explanation.
next prev parent reply other threads:[~2026-02-02 14:36 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <2026020124-flashbulb-stumble-f24a@gregkh>
2026-02-01 11:34 ` [PATCH] perf/core: Fix refcount bug and potential UAF in perf_mmap Haocheng Yu
2026-02-01 11:49 ` Greg KH
2026-02-02 7:44 ` Haocheng Yu
2026-02-02 13:58 ` Peter Zijlstra
2026-02-02 14:36 ` Peter Zijlstra [this message]
2026-02-02 15:51 ` 余昊铖
2026-02-02 16:20 ` [PATCH v2] " yuhaocheng035
2026-02-06 9:06 ` Peter Zijlstra
2026-02-09 15:26 ` 余昊铖
2026-03-05 18:56 ` Ian Rogers
2026-03-06 9:35 ` yuhaocheng035
2026-03-06 9:36 ` Haocheng Yu
2026-03-06 19:04 ` Ian Rogers
2026-03-07 5:57 ` Haocheng Yu
2026-02-01 18:43 ` [PATCH] " kernel test robot
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=20260202143615.GC1395416@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=acme@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=security@kernel.org \
--cc=yuhaocheng035@gmail.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