Linux Trace Kernel
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Cc: linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH v3 1/3] tracing: Hold file reference in splice buffer_ref
Date: Fri, 04 Dec 2026 06:19:46 +0000	[thread overview]
Message-ID: <sashiko-outbox-249204@kernel.org> (raw)
In-Reply-To: <179636441309.1289712.3872630578310009929.stgit@mhiramat.c.googlers.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] tracing: Fixes trailer cites wrong commit for
  ring_buffer_free_read_page() UAF
--

commit d437840eacea8fdaf6388c3810c823a11b795543
Author: Masami Hiramatsu (Google) <mhiramat@kernel.org>

> tracing: Hold file reference in splice buffer_ref
>
> tracing_buffers_splice_read() stores a raw pointer to
> iter->array_buffer->buffer in each struct buffer_ref attached to the pipe
> buffers, and buffer_ref_release() later dereferences ref->buffer in
> ring_buffer_free_read_page() when the pipe drains or closes.
>
> However, struct buffer_ref does not hold a reference to the source file
> (and thus the owning struct trace_array). If the trace_pipe_raw file
> descriptor is closed while spliced pages are still sitting in the pipe
> and the trace instance is then destroyed (via manual rmdir or backup
> instance autoremove), ring_buffer_free_read_page() dereferences the freed
> trace_buffer, causing a use-after-free.
>
> Store a get_file(file) reference in struct buffer_ref for each spliced
> page and release it via fput() in buffer_ref_release() after
> ring_buffer_free_read_page(). Holding the file reference keeps the
> trace_array (including tr->trace_ref, so tracer switches and instance
> removal return -EBUSY until the pipe drains) and its ring buffer alive
> without taking trace_types_lock on the splice data path.
>
> Fixes: 0c8916c34203 ("tracing: Add rmdir to remove multibuffer instances")
> Cc: stable@vger.kernel.org
> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>

[Severity: Low]
Should the Fixes tag cite 73a757e63114 ("ring-buffer: Return reader page
back into existing ring buffer") instead of 0c8916c34203 ("tracing: Add
rmdir to remove multibuffer instances")?

When instance rmdir was added, ring_buffer_free_read_page() only called
free_page() and ignored the buffer pointer.  The buffer->buffers[cpu]
dereference that causes the use-after-free was introduced when reader page
caching was added.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/179636440238.1289712.8372580891085333773.stgit@mhiramat.c.googlers.com?part=1

  reply	other threads:[~2026-12-04  6:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04  6:06 [PATCH v3 0/3] tracing: Fix readonly backup instance blocking reads and autoremove races Masami Hiramatsu (Google)
2026-12-04  6:06 ` [PATCH v3 1/3] tracing: Hold file reference in splice buffer_ref Masami Hiramatsu (Google)
2026-12-04  6:19   ` sashiko-bot [this message]
2026-12-04  6:07 ` [PATCH v3 2/3] tracing: Return EOF on empty readonly instances Masami Hiramatsu (Google)
2026-12-04  6:07 ` [PATCH v3 3/3] tracing: Fix deadlock and UAF when rmdir races with backup autoremove Masami Hiramatsu (Google)

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=sashiko-outbox-249204@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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