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/ (local)