mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	stable@vger.kernel.org,
	syzbot+de3d7f9bcc9212f3fae1@syzkaller.appspotmail.com,
	Krystian Kaniewski <krystianmkaniewski@gmail.com>,
	Vincent Donnefort <vdonnefort@google.com>
Subject: [for-linus][PATCH 09/16] ring-buffer: Fix false warning in ring_buffer_map_get_reader()
Date: Thu, 15 Oct 2026 09:33:19 -0400	[thread overview]
Message-ID: <20261015133403.783087207@kernel.org> (raw)
In-Reply-To: <20261015133310.731003448@kernel.org>

From: Krystian Kaniewski <krystianmkaniewski@gmail.com>

The mmap reader can warn when it catches up with a writer that is still
committing events. rb_get_reader_page() returns NULL in this case, but
ring_buffer_map_get_reader() treats that result as an error.

The initial rb_per_cpu_empty() check filters out an empty buffer, but it
does not guarantee that the next reader page has committed data. Writers
do not take reader_lock and can advance commit_page before publishing the
committed length on the new page. rb_get_reader_page() can swap to that
page, catch up with the writer and return NULL.

Handle NULL through the existing no-data exit without warning. Remove the
caller's reader_page == commit_page check as well, since the reader-page
helper already handles that case. The existing metadata update and return
path remain in place.

Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260924084946.20104-1-krystianmkaniewski@gmail.com
Fixes: 117c39200d9d ("ring-buffer: Introducing ring-buffer mapping functions")
Assisted-by: Gemini:gemini-3.8-flash syzbot
Reported-by: syzbot+de3d7f9bcc9212f3fae1@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=de3d7f9bcc9212f3fae1
Link: https://syzkaller.appspot.com/ai_job?id=488adc18-a10e-42d2-a205-25327c38837f
Signed-off-by: Krystian Kaniewski <krystianmkaniewski@gmail.com>
Reviewed-by: Vincent Donnefort <vdonnefort@google.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/ring_buffer.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index ad3bc48e2670..e2b721d0707f 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -7998,12 +7998,8 @@ int ring_buffer_map_get_reader(struct trace_buffer *buffer, int cpu)
 		goto out;
 	}
 
-	/* Did the reader catch up with the writer? */
-	if (cpu_buffer->reader_page == cpu_buffer->commit_page)
-		goto out;
-
 	reader = rb_get_reader_page(cpu_buffer);
-	if (WARN_ON(!reader))
+	if (!reader)
 		goto out;
 
 	/* Check if any events were dropped */
-- 
2.53.0

  parent reply	other threads:[~2026-10-15 13:34 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-15 13:33 [for-linus][PATCH 00/16] tracing: Fixes for v7.3 Steven Rostedt
2026-10-15 13:33 ` [for-linus][PATCH 01/16] tracing: Fix NULL dereference when copying keys for a field variable Steven Rostedt
2026-10-15 13:33 ` [for-linus][PATCH 02/16] tracing: Take trace_types_lock when dropping the buffer_meta reference Steven Rostedt
2026-10-15 13:33 ` [for-linus][PATCH 03/16] ring-buffer: Do not show buffer_meta for CPUs without a buffer Steven Rostedt
2026-10-15 13:33 ` [for-linus][PATCH 04/16] tracing: Fix the shift out of bounds in the log2 histogram modifier Steven Rostedt
2026-10-15 13:33 ` [for-linus][PATCH 05/16] ring-buffer: Fix the sub-buffer array base in rb_meta_subbuf_idx() Steven Rostedt
2026-10-15 13:33 ` [for-linus][PATCH 06/16] tracing: Fix empty symbol names in simple_ring_buffer undef check Steven Rostedt
2026-10-15 13:33 ` [for-linus][PATCH 07/16] tracing: Fix simple_ring_buffer undef check on parisc Steven Rostedt
2026-10-15 13:33 ` [for-linus][PATCH 08/16] tracing: Fix simple_ring_buffer undef check on sparc64 Steven Rostedt
2026-10-15 13:33 ` Steven Rostedt [this message]
2026-10-15 13:33 ` [for-linus][PATCH 10/16] tracing: Fix ignored return value of resize_buffer_duplicate_size() Steven Rostedt
2026-10-15 13:33 ` [for-linus][PATCH 11/16] tracing: Fix hist trigger timestamps for buffered events Steven Rostedt
2026-10-15 13:33 ` [for-linus][PATCH 12/16] tracing: Do not initialize tracefs work if tracing is disabled Steven Rostedt
2026-10-15 13:33 ` [for-linus][PATCH 13/16] eventfs: Free the eventfs_inode after an rcu grace period too Steven Rostedt
2026-10-15 13:33 ` [for-linus][PATCH 14/16] ring-buffer: Skip si_mem_available() for persistent and remote buffers Steven Rostedt
2026-10-15 13:33 ` [for-linus][PATCH 15/16] ring-buffer: Use subbuf_order in available memory estimation Steven Rostedt
2026-10-15 13:33 ` [for-linus][PATCH 16/16] tracing/histograms: Reject non-stacktrace fields for synthetic stacktrace fields Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261015133403.783087207@kernel.org \
    --to=rostedt@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=krystianmkaniewski@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=syzbot+de3d7f9bcc9212f3fae1@syzkaller.appspotmail.com \
    --cc=vdonnefort@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®