Compare
0fa993581aaa58a34ae3dcebebe0fbf593fcb441..89bab1dba8a0167ef0d819e0f55b6bafa038e87f
ring-buffer: Fix false warning in ring_buffer_map_get_reader()
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>
Krystian Kaniewski <krystianmkaniewski@gmail.com> · 2026-09-24 08:49 UTC · committed by Steven Rostedt
1 file changed,
+1
−5
modified kernel/trace/ring_buffer.c
| @@ -7998,12 +7998,8 @@ consume: | |||
| 7998 | 7998 | goto out; | |
| 7999 | 7999 | } | |
| 8000 | 8000 | ||
| 8001 | - | /* Did the reader catch up with the writer? */ | |
| 8002 | - | if (cpu_buffer->reader_page == cpu_buffer->commit_page) | |
| 8003 | - | goto out; | |
| 8004 | - | ||
| 8005 | 8001 | reader = rb_get_reader_page(cpu_buffer); | |
| 8006 | - | if (WARN_ON(!reader)) | |
| 8002 | + | if (!reader) | |
| 8007 | 8003 | goto out; | |
| 8008 | 8004 | ||
| 8009 | 8005 | /* Check if any events were dropped */ | |