From: Vincent Donnefort <vdonnefort@google.com>
To: Kyuwon Cho <kyuwoncho18@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [BUG] tracing: trace_pipe reads out of bounds when it races with the ring buffer mmap reader
Date: Tue, 17 Nov 2026 08:32:14 +0000 [thread overview]
Message-ID: <avwRDoDJF_oj1xWM@google.com> (raw)
In-Reply-To: <179485165154.2547186.6129837870360499372@gmail.com>
On Mon, Nov 16, 2026 at 09:56:31AM -0800, Kyuwon Cho wrote:
> Hi Steve, Masami, Vincent,
>
> While testing v7.4-rc3 with an LLM-guided test generator that we are
> developing as a research prototype, we found that reading a CPU's
> trace_pipe while another task consumes the same CPU buffer through the
> mmap interface (TRACE_MMAP_IOCTL_GET_READER) makes trace_pipe print
> entries that have already been overwritten. With KASAN this ends in an
> out-of-bounds read in the event output code:
>
> BUG: KASAN: use-after-free in string (lib/vsprintf.c:650 lib/vsprintf.c:732)
> Read of size 1 at addr ff11000011e2d8ed by task test/89
> Call Trace:
> <TASK>
> string (lib/vsprintf.c:650 lib/vsprintf.c:732)
> vsnprintf (lib/vsprintf.c:2948)
> seq_buf_vprintf (lib/seq_buf.c:74)
> trace_seq_vprintf (kernel/trace/trace_seq.c:175)
> trace_event_printf (kernel/trace/trace_output.c:360)
> trace_raw_output_workqueue_rescued (include/trace/events/workqueue.h:210)
> print_trace_line (kernel/trace/trace.c:3082 kernel/trace/trace.c:3248)
> tracing_read_pipe (kernel/trace/trace.c:5475)
> vfs_read (fs/read_write.c:552)
> ksys_read (fs/read_write.c:696)
> do_syscall_64 (arch/x86/entry/syscall_64.c:61 arch/x86/entry/syscall_64.c:89)
> entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121)
> </TASK>
> The buggy address belongs to the physical page:
> page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x11e2d
> page_type: f0(buddy)
>
> and the type check in trace_assign_type() fires as well:
>
> WARNING: kernel/trace/trace_output.c:1798 at trace_print_print+0xeb/0x130, CPU#1: test/89
> Call Trace:
> <TASK>
> print_trace_line (kernel/trace/trace.c:3082 kernel/trace/trace.c:3248)
> tracing_read_pipe (kernel/trace/trace.c:5475)
> vfs_read (fs/read_write.c:552)
> ksys_read (fs/read_write.c:696)
> do_syscall_64 (arch/x86/entry/syscall_64.c:61 arch/x86/entry/syscall_64.c:89)
> entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121)
> </TASK>
>
> The stale entry carries another event's type, so that event's output
> function decodes trace_marker data as its fields, including __data_loc
> offsets and lengths that point outside the ring buffer page. Other runs
> reported slab-out-of-bounds and global-out-of-bounds reads from the same
> path; the ring buffer pages themselves are not freed.
>
> tracing_buffers_ioctl() calls ring_buffer_map_get_reader() without
> trace_access_lock():
>
> if (cmd == TRACE_MMAP_IOCTL_GET_READER) {
> ...
> return ring_buffer_map_get_reader(iter->array_buffer->buffer,
> iter->cpu_file);
> }
Indeed, that's an omission from when we brought this support.
I have just sent a fix [1].
Thanks for the report.
--
Vincent
[1] https://lore.kernel.org/all/20261117082932.3441173-1-vdonnefort@google.com/
prev parent reply other threads:[~2026-11-17 8:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 17:56 [BUG] tracing: trace_pipe reads out of bounds when it races with the ring buffer mmap reader Kyuwon Cho
2026-11-17 8:32 ` Vincent Donnefort [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=avwRDoDJF_oj1xWM@google.com \
--to=vdonnefort@google.com \
--cc=kyuwoncho18@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=rostedt@goodmis.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.