Commit 600b18f8 authored by Linus Torvalds's avatar Linus Torvalds

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
parents f54ca91f 2e6e9058
...@@ -5602,10 +5602,11 @@ int modify_ftrace_direct_multi(struct ftrace_ops *ops, unsigned long addr) ...@@ -5602,10 +5602,11 @@ int modify_ftrace_direct_multi(struct ftrace_ops *ops, unsigned long addr)
} }
} }
mutex_unlock(&ftrace_lock);
/* Removing the tmp_ops will add the updated direct callers to the functions */ /* Removing the tmp_ops will add the updated direct callers to the functions */
unregister_ftrace_function(&tmp_ops); unregister_ftrace_function(&tmp_ops);
mutex_unlock(&ftrace_lock);
out_direct: out_direct:
mutex_unlock(&direct_mutex); mutex_unlock(&direct_mutex);
return err; return err;
......
...@@ -5228,6 +5228,9 @@ void ring_buffer_reset(struct trace_buffer *buffer) ...@@ -5228,6 +5228,9 @@ void ring_buffer_reset(struct trace_buffer *buffer)
struct ring_buffer_per_cpu *cpu_buffer; struct ring_buffer_per_cpu *cpu_buffer;
int cpu; int cpu;
/* prevent another thread from changing buffer sizes */
mutex_lock(&buffer->mutex);
for_each_buffer_cpu(buffer, cpu) { for_each_buffer_cpu(buffer, cpu) {
cpu_buffer = buffer->buffers[cpu]; cpu_buffer = buffer->buffers[cpu];
...@@ -5246,6 +5249,8 @@ void ring_buffer_reset(struct trace_buffer *buffer) ...@@ -5246,6 +5249,8 @@ void ring_buffer_reset(struct trace_buffer *buffer)
atomic_dec(&cpu_buffer->record_disabled); atomic_dec(&cpu_buffer->record_disabled);
atomic_dec(&cpu_buffer->resize_disabled); atomic_dec(&cpu_buffer->resize_disabled);
} }
mutex_unlock(&buffer->mutex);
} }
EXPORT_SYMBOL_GPL(ring_buffer_reset); EXPORT_SYMBOL_GPL(ring_buffer_reset);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment