Commit

3f23cae09a4677a3f7c163a68388512cb231ff22

ring-buffer: Do not show buffer_meta for CPUs without a buffer

The per_cpu/cpuN/buffer_meta files are created for every possible CPU,
but buffer->buffers[cpu] is only allocated once that CPU comes online.
Reading the file of a CPU that never came online dereferences a NULL
cpu_buffer in rbm_start().

Fail the open with -ENODEV when the CPU has no buffer, as the other
per CPU ring buffer interfaces do.

Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260914133506.4865-3-devnexen@gmail.com
Fixes: 950032ffcee7 ("ring-buffer: Add output of ring buffer meta page")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://lore.kernel.org/all/20260913134906.6E8A01F000FF@smtp.kernel.org/
Signed-off-by: David Carlier <devnexen@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

David Carlier <devnexen@gmail.com> · 2026-09-14 13:35 UTC · committed by Steven Rostedt

Browse files
1 file changed, +3 −0
modified kernel/trace/ring_buffer.c
@@ -2380,6 +2380,9 @@ int ring_buffer_meta_seq_init(struct file *file, struct trace_buffer *buffer, in
2380 2380 struct seq_file *m;
2381 2381 int ret;
2382 2382
2383 + if (!cpumask_test_cpu(cpu, buffer->cpumask))
2384 + return -ENODEV;
2385 +
2383 2386 ret = seq_open(file, &rb_meta_seq_ops);
2384 2387 if (ret)
2385 2388 return ret;