This is a note to let you know that I've just added the patch titled ring-buffer: Have rb_time_cmpxchg() set the msb counter too to the 6.6-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: ring-buffer-have-rb_time_cmpxchg-set-the-msb-counter-too.patch and it can be found in the queue-6.6 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 0aa0e5289cfe984a8a9fdd79ccf46ccf080151f7 Mon Sep 17 00:00:00 2001 From: "Steven Rostedt (Google)" <rostedt@xxxxxxxxxxx> Date: Fri, 15 Dec 2023 08:41:14 -0500 Subject: ring-buffer: Have rb_time_cmpxchg() set the msb counter too From: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx> commit 0aa0e5289cfe984a8a9fdd79ccf46ccf080151f7 upstream. The rb_time_cmpxchg() on 32-bit architectures requires setting three 32-bit words to represent the 64-bit timestamp, with some salt for synchronization. Those are: msb, top, and bottom The issue is, the rb_time_cmpxchg() did not properly salt the msb portion, and the msb that was written was stale. Link: https://lore.kernel.org/linux-trace-kernel/20231215084114.20899342@xxxxxxxxxxxxxxxxxxxx Cc: stable@xxxxxxxxxxxxxxx Cc: Masami Hiramatsu <mhiramat@xxxxxxxxxx> Cc: Mark Rutland <mark.rutland@xxxxxxx> Cc: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx> Fixes: f03f2abce4f39 ("ring-buffer: Have 32 bit time stamps use all 64 bits") Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- kernel/trace/ring_buffer.c | 2 ++ 1 file changed, 2 insertions(+) --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c @@ -722,10 +722,12 @@ static bool rb_time_cmpxchg(rb_time_t *t cnt2 = cnt + 1; rb_time_split(val, &top, &bottom, &msb); + msb = rb_time_val_cnt(msb, cnt); top = rb_time_val_cnt(top, cnt); bottom = rb_time_val_cnt(bottom, cnt); rb_time_split(set, &top2, &bottom2, &msb2); + msb2 = rb_time_val_cnt(msb2, cnt); top2 = rb_time_val_cnt(top2, cnt2); bottom2 = rb_time_val_cnt(bottom2, cnt2); Patches currently in stable-queue which might be from rostedt@xxxxxxxxxxx are queue-6.6/ring-buffer-do-not-update-before-stamp-when-switching-sub-buffers.patch queue-6.6/ring-buffer-have-saved-event-hold-the-entire-event.patch queue-6.6/eventfs-do-not-allow-null-parent-to-eventfs_start_cr.patch queue-6.6/ring-buffer-have-rb_time_cmpxchg-set-the-msb-counter-too.patch queue-6.6/ring-buffer-do-not-try-to-put-back-write_stamp.patch queue-6.6/ring-buffer-fix-memory-leak-of-free-page.patch queue-6.6/ring-buffer-fix-a-race-in-rb_time_cmpxchg-for-32-bit-archs.patch queue-6.6/tracing-update-snapshot-buffer-on-resize-if-it-is-allocated.patch queue-6.6/ring-buffer-fix-writing-to-the-buffer-with-max_data_size.patch