mirror of
https://github.com/torvalds/linux.git
synced 2026-09-12 12:34:02 +02:00
tracing: Fix retry exhaustion in simple ring buffer reader swap
simple_ring_buffer_swap_reader_page() starts with retry set to 8 and
post-decrements it only after a failed link replacement. On the final
attempt, a successful replacement leaves retry at zero, while a failed
replacement leaves it at -1.
The current !retry test reverses both outcomes. It returns an error after
a successful final replacement, leaving the link update complete but the
reader bookkeeping unfinished. After a failed final replacement, it
falls through and updates the head and reader pointers as though the
replacement succeeded, which can corrupt the ring.
Treat only a negative counter as exhaustion and return the documented
-EBUSY error.
Cc: stable@vger.kernel.org
Fixes: 34e5b958bd ("tracing: Introduce simple_ring_buffer")
Link: https://patch.msgid.link/20260825-kernel-patch-1-v2-1-bb3461807a32@gmail.com
Assisted-by: LLM sparse
Reviewed-by: Vincent Donnefort <vdonnefort@google.com>
Signed-off-by: Ivan Immanuel Shaji <ivanimmanuel1234@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
This commit is contained in:
parent
390f6bd858
commit
e0d3aed7b1
|
|
@ -160,8 +160,8 @@ int simple_ring_buffer_swap_reader_page(struct simple_rb_per_cpu *cpu_buffer)
|
|||
overrun = cpu_buffer->meta->overrun;
|
||||
} while (!simple_bpage_unset_head_link(last, reader, SIMPLE_RB_LINK_NORMAL) && retry--);
|
||||
|
||||
if (!retry)
|
||||
return -EINVAL;
|
||||
if (retry < 0)
|
||||
return -EBUSY;
|
||||
|
||||
cpu_buffer->head_page = simple_bpage_from_link(reader->link.next);
|
||||
cpu_buffer->head_page->link.prev = &reader->link;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user