Skip to content

Commit e09c060

Browse files
dmantipovgregkh
authored andcommitted
ring-buffer: Fix buffer locking in ring_buffer_subbuf_order_set()
commit 40ee2af 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: [email protected] Cc: Masami Hiramatsu <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Cc: Tzvetomir Stoyanov <[email protected]> Link: https://lore.kernel.org/[email protected] Reported-by: [email protected] 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 <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent b8df8cb commit e09c060

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
@@ -6754,7 +6754,7 @@ int ring_buffer_subbuf_order_set(struct trace_buffer *buffer, int order)
67546754
old_size = buffer->subbuf_size;
67556755

67566756
/* prevent another thread from changing buffer sizes */
6757-
mutex_lock(&buffer->mutex);
6757+
guard(mutex)(&buffer->mutex);
67586758
atomic_inc(&buffer->record_disabled);
67596759

67606760
/* Make sure all commits have finished */
@@ -6859,7 +6859,6 @@ int ring_buffer_subbuf_order_set(struct trace_buffer *buffer, int order)
68596859
}
68606860

68616861
atomic_dec(&buffer->record_disabled);
6862-
mutex_unlock(&buffer->mutex);
68636862

68646863
return 0;
68656864

@@ -6868,7 +6867,6 @@ int ring_buffer_subbuf_order_set(struct trace_buffer *buffer, int order)
68686867
buffer->subbuf_size = old_size;
68696868

68706869
atomic_dec(&buffer->record_disabled);
6871-
mutex_unlock(&buffer->mutex);
68726870

68736871
for_each_buffer_cpu(buffer, cpu) {
68746872
cpu_buffer = buffer->buffers[cpu];

0 commit comments

Comments
 (0)