linux-yocto/kernel/trace
Steven Rostedt 7803b28c9a tracing: Add down_write(trace_event_sem) when adding trace event
commit b5e8acc14d upstream.

When a module is loaded, it adds trace events defined by the module. It
may also need to modify the modules trace printk formats to replace enum
names with their values.

If two modules are loaded at the same time, the adding of the event to the
ftrace_events list can corrupt the walking of the list in the code that is
modifying the printk format strings and crash the kernel.

The addition of the event should take the trace_event_sem for write while
it adds the new event.

Also add a lockdep_assert_held() on that semaphore in
__trace_add_event_dirs() as it iterates the list.

Cc: stable@vger.kernel.org
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Link: https://lore.kernel.org/20250718223158.799bfc0c@batman.local.home
Reported-by: Fusheng Huang(黄富生)  <Fusheng.Huang@luxshare-ict.com>
Closes: https://lore.kernel.org/all/20250717105007.46ccd18f@batman.local.home/
Fixes: 110bf2b764 ("tracing: add protection around module events unload")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-07-24 08:51:48 +02:00
..
rv rv: Update rv_en(dis)able_monitor doc to match kernel-doc 2024-06-12 11:03:52 +02:00
blktrace.c
bpf_trace.c bpf: Fix WARN() in get_bpf_raw_tp_regs 2025-06-27 11:07:11 +01:00
bpf_trace.h
error_report-traces.c
fgraph.c
fprobe.c fprobe: Fix to ensure the number of active retprobes is not zero 2023-10-25 12:03:12 +02:00
ftrace_internal.h
ftrace.c ftrace: Fix UAF when lookup kallsym after ftrace disabled 2025-06-27 11:07:30 +01:00
Kconfig tracing: Build event generation tests only as modules 2024-06-27 13:46:18 +02:00
kprobe_event_gen_test.c
Makefile
pid_list.c trace/pid_list: Change gfp flags in pid_list_fill_irq() 2024-08-03 08:49:34 +02:00
pid_list.h
power-traces.c
preemptirq_delay_test.c tracing: Add MODULE_DESCRIPTION() to preemptirq_delay_test 2024-06-27 13:46:23 +02:00
rethook.c rethook: Use __rcu pointer for rethook::handler 2023-12-13 18:39:17 +01:00
ring_buffer_benchmark.c
ring_buffer.c ring-buffer: Fix bytes_dropped calculation issue 2025-04-10 14:33:37 +02:00
rpm-traces.c
synth_event_gen_test.c tracing / synthetic: Disable events after testing in synth_event_gen_test_init() 2024-01-01 12:39:07 +00:00
trace_benchmark.c
trace_benchmark.h
trace_boot.c
trace_branch.c
trace_clock.c tracing: Use atomic64_inc_return() in trace_clock_counter() 2024-12-14 19:54:45 +01:00
trace_dynevent.c tracing: probes: Fix a possible race in trace_probe_log APIs 2025-05-22 14:09:59 +02:00
trace_dynevent.h tracing: probes: Fix a possible race in trace_probe_log APIs 2025-05-22 14:09:59 +02:00
trace_entries.h
trace_eprobe.c tracing/eprobe: Fix to release eprobe when failed to add dyn_event 2024-12-14 19:54:50 +01:00
trace_event_perf.c trace/trace_event_perf: remove duplicate samples on the first tracepoint event 2024-12-14 19:53:35 +01:00
trace_events_filter_test.h
trace_events_filter.c tracing: Fix filter string testing 2025-04-25 10:43:55 +02:00
trace_events_hist.c tracing: Rename event_trigger_alloc() to trigger_data_alloc() 2025-06-27 11:07:10 +01:00
trace_events_inject.c tracing: Have event inject files inc the trace array ref count 2023-09-23 11:11:11 +02:00
trace_events_synth.c tracing: Do not use PERF enums when perf is not defined 2025-04-10 14:33:43 +02:00
trace_events_trigger.c tracing: Fix error handling in event_trigger_parse() 2025-06-27 11:07:10 +01:00
trace_events_user.c
trace_events.c tracing: Add down_write(trace_event_sem) when adding trace event 2025-07-24 08:51:48 +02:00
trace_export.c
trace_functions_graph.c tracing: Fix use-after-free in print_graph_function_flags during tracer switching 2025-04-10 14:33:43 +02:00
trace_functions.c ftrace: Fix preemption accounting for stacktrace filter command 2025-05-22 14:10:05 +02:00
trace_hwlat.c tracing/hwlat: Fix a race during cpuhp processing 2024-10-17 15:22:02 +02:00
trace_irqsoff.c tracing: Fix use-after-free in print_graph_function_flags during tracer switching 2025-04-10 14:33:43 +02:00
trace_kdb.c
trace_kprobe_selftest.c
trace_kprobe_selftest.h
trace_kprobe.c tracing: probes: Fix a possible race in trace_probe_log APIs 2025-05-22 14:09:59 +02:00
trace_mmiotrace.c
trace_nop.c
trace_osnoise.c tracing/osnoise: Fix possible recursive locking for cpus_read_lock() 2025-04-10 14:33:43 +02:00
trace_output.c tracing: Remove precision vsnprintf() check from print event 2024-10-17 15:22:10 +02:00
trace_output.h
trace_preemptirq.c
trace_printk.c
trace_probe_kernel.h
trace_probe_tmpl.h
trace_probe.c tracing: probes: Fix a possible race in trace_probe_log APIs 2025-05-22 14:09:59 +02:00
trace_probe.h tracing/kprobes: Return EADDRNOTAVAIL when func matches several symbols 2023-10-25 12:03:16 +02:00
trace_recursion_record.c
trace_sched_switch.c
trace_sched_wakeup.c tracing: Fix use-after-free in print_graph_function_flags during tracer switching 2025-04-10 14:33:43 +02:00
trace_selftest_dynamic.c
trace_selftest.c
trace_seq.c
trace_stack.c
trace_stat.c
trace_stat.h
trace_synth.h
trace_syscalls.c tracing/ftrace: disable preemption in syscall probe 2024-12-14 19:54:45 +01:00
trace_uprobe.c tracing: probes: Fix a possible race in trace_probe_log APIs 2025-05-22 14:09:59 +02:00
trace.c tracing: Fix compilation warning on arm32 2025-06-27 11:07:04 +01:00
trace.h tracing: Rename event_trigger_alloc() to trigger_data_alloc() 2025-06-27 11:07:10 +01:00
tracing_map.c tracing: Fix cmp_entries_dup() to respect sort() comparison rules 2024-12-14 19:54:32 +01:00
tracing_map.h