Skip to content

Commit 600b18f

Browse files
committed
Merge tag 'trace-v5.16-3' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull tracing fixes from Steven Rostedt: "Two locking fixes: - Add mutex protection to ring_buffer_reset() - Fix deadlock in modify_ftrace_direct_multi()" * tag 'trace-v5.16-3' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: ftrace/direct: Fix lockup in modify_ftrace_direct_multi ring-buffer: Protect ring_buffer_reset() from reentrancy
2 parents f54ca91 + 2e6e905 commit 600b18f

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

kernel/trace/ftrace.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5602,10 +5602,11 @@ int modify_ftrace_direct_multi(struct ftrace_ops *ops, unsigned long addr)
56025602
}
56035603
}
56045604

5605+
mutex_unlock(&ftrace_lock);
5606+
56055607
/* Removing the tmp_ops will add the updated direct callers to the functions */
56065608
unregister_ftrace_function(&tmp_ops);
56075609

5608-
mutex_unlock(&ftrace_lock);
56095610
out_direct:
56105611
mutex_unlock(&direct_mutex);
56115612
return err;

kernel/trace/ring_buffer.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5228,6 +5228,9 @@ void ring_buffer_reset(struct trace_buffer *buffer)
52285228
struct ring_buffer_per_cpu *cpu_buffer;
52295229
int cpu;
52305230

5231+
/* prevent another thread from changing buffer sizes */
5232+
mutex_lock(&buffer->mutex);
5233+
52315234
for_each_buffer_cpu(buffer, cpu) {
52325235
cpu_buffer = buffer->buffers[cpu];
52335236

@@ -5246,6 +5249,8 @@ void ring_buffer_reset(struct trace_buffer *buffer)
52465249
atomic_dec(&cpu_buffer->record_disabled);
52475250
atomic_dec(&cpu_buffer->resize_disabled);
52485251
}
5252+
5253+
mutex_unlock(&buffer->mutex);
52495254
}
52505255
EXPORT_SYMBOL_GPL(ring_buffer_reset);
52515256

0 commit comments

Comments
 (0)