Skip to content

Commit 5f2a8a7

Browse files
dmantipovsmb49
authored andcommitted
ring-buffer: Fix buffer locking in ring_buffer_subbuf_order_set()
BugLink: https://bugs.launchpad.net/bugs/2119603 commit 40ee2afafc1d9fe3aa44a6fbe440d78a5c96a72e upstream. Enlarge the critical section in ring_buffer_subbuf_order_set() to ensure that error handling takes place with per-buffer mutex held, thus preventing list corruption and other concurrency-related issues. Cc: stable@vger.kernel.org Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Cc: Tzvetomir Stoyanov <tz.stoyanov@gmail.com> Link: https://lore.kernel.org/20250606112242.1510605-1-dmantipov@yandex.ru Reported-by: syzbot+05d673e83ec640f0ced9@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=05d673e83ec640f0ced9 Fixes: f9b94da ("ring-buffer: Set new size of the ring buffer sub page") Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> CVE-2025-38101 Signed-off-by: Manuel Diewald <manuel.diewald@canonical.com> Signed-off-by: Mehmet Basaran <mehmet.basaran@canonical.com>
1 parent 35841b6 commit 5f2a8a7

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

kernel/trace/ring_buffer.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6716,7 +6716,7 @@ int ring_buffer_subbuf_order_set(struct trace_buffer *buffer, int order)
67166716
old_size = buffer->subbuf_size;
67176717

67186718
/* prevent another thread from changing buffer sizes */
6719-
mutex_lock(&buffer->mutex);
6719+
guard(mutex)(&buffer->mutex);
67206720
atomic_inc(&buffer->record_disabled);
67216721

67226722
/* Make sure all commits have finished */
@@ -6821,7 +6821,6 @@ int ring_buffer_subbuf_order_set(struct trace_buffer *buffer, int order)
68216821
}
68226822

68236823
atomic_dec(&buffer->record_disabled);
6824-
mutex_unlock(&buffer->mutex);
68256824

68266825
return 0;
68276826

@@ -6830,7 +6829,6 @@ int ring_buffer_subbuf_order_set(struct trace_buffer *buffer, int order)
68306829
buffer->subbuf_size = old_size;
68316830

68326831
atomic_dec(&buffer->record_disabled);
6833-
mutex_unlock(&buffer->mutex);
68346832

68356833
for_each_buffer_cpu(buffer, cpu) {
68366834
cpu_buffer = buffer->buffers[cpu];

0 commit comments

Comments
 (0)