All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4] tracing: ring-buffer: fix stale reader-page link
@ 2026-11-13  3:36 Haoli Zhang
  2026-11-13  3:51 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Haoli Zhang @ 2026-11-13  3:36 UTC (permalink / raw)
  To: rostedt, mhiramat
  Cc: mathieu.desnoyers, linux-trace-kernel, linux-kernel, 25031212117,
	byu, syzbot+37e1793bdb0061ea3a47, Haoli Zhang

Hi Steve,

Thanks for reviewing v3. I apologize for adding unnecessary NMI reader
coordination and skip handling. You noted the report is unrelated to NMI
reads. The lockless NMI path is only a best-effort crash-dump path.
I have removed that complexity and dropped the Fixes tag.

The report shows rb_is_reader_page() dereferencing a freed page through
page->list.prev->next. During shrink, reader_page is detached from the
ring list and can retain a previous link to a page being removed. Redirect
that link to the surviving tail page while identifying pages to remove,
before any removed page is freed.

This change does not add work to the normal writer fast path or alter NMI
reader behavior.

Reported-by: syzbot+37e1793bdb0061ea3a47@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=37e1793bdb0061ea3a47
Co-developed-by: Jinning Zhang <25031212117@stu.xidian.edu.cn>
Signed-off-by: Jinning Zhang <25031212117@stu.xidian.edu.cn>
Co-developed-by: Bin Yu <byu@xidian.edu.cn>
Signed-off-by: Bin Yu <byu@xidian.edu.cn>
Signed-off-by: Haoli Zhang <26031212468@stu.xidian.edu.cn>

---
 v4:
 - Drop NMI reader coordination and skip handling.

 kernel/trace/ring_buffer.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -3106,6 +3106,16 @@
 	for (nr_removed = 0; nr_removed < nr_pages; nr_removed++) {
 		to_remove = rb_list_head(to_remove)->next;
 		head_bit |= (unsigned long)to_remove & RB_PAGE_HEAD;
+
+		/*
+		 * The reader page is detached from the ring buffer list, so its
+		 * previous pointer can still refer to a page being removed.
+		 * rb_is_reader_page() follows this pointer, so redirect it to the
+		 * surviving tail page before the removed page is freed.
+		 */
+		if (rb_list_head(cpu_buffer->reader_page->list.prev) ==
+		    rb_list_head(to_remove))
+			cpu_buffer->reader_page->list.prev = tail_page;
 	}
 	/* Read iterators need to reset themselves when some pages removed */
 	cpu_buffer->pages_removed += nr_removed;
-- 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-13  3:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-13  3:36 [PATCH v4] tracing: ring-buffer: fix stale reader-page link Haoli Zhang
2026-11-13  3:51 ` sashiko-bot

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.