mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 04:34:03 +02:00
ring-buffer: Fix subbuf resize race with ring_buffer_alloc_read_page()
ring_buffer_alloc_read_page() is racy with ring_buffer_subbuf_order_set,
it can allocate a reader page with an outdated order. This isn't a big
issue, the user can still re-allocate a new reader page and try again.
However, what is more problematic is if the value of subbuf_order
changes in the middle of ring_buffer_alloc_read_page(). In that case,
bpage->order might not match the actual allocated memory.
Use bpage->order for the allocation to prevent this race.
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260813131152.3589632-6-vdonnefort@google.com
Fixes: bce761d757 ("ring-buffer: Read and write to ring buffers with custom sub buffer size")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
This commit is contained in:
parent
8a5f636378
commit
e743527c5b
|
|
@ -7018,7 +7018,7 @@ ring_buffer_alloc_read_page(struct trace_buffer *buffer, int cpu)
|
|||
if (bpage->data) {
|
||||
rb_init_data_page(bpage->data);
|
||||
} else {
|
||||
bpage->data = alloc_cpu_data(cpu, cpu_buffer->buffer->subbuf_order);
|
||||
bpage->data = alloc_cpu_data(cpu, bpage->order);
|
||||
if (!bpage->data) {
|
||||
kfree(bpage);
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user