linux-imx/kernel/trace
Steven Rostedt b4fdabffae tracing/timerlat: Add interface_lock around clearing of kthread in stop_kthread()
commit 5bfbcd1ee5 upstream.

The timerlat interface will get and put the task that is part of the
"kthread" field of the osn_var to keep it around until all references are
released. But here's a race in the "stop_kthread()" code that will call
put_task_struct() on the kthread if it is not a kernel thread. This can
race with the releasing of the references to that task struct and the
put_task_struct() can be called twice when it should have been called just
once.

Take the interface_lock() in stop_kthread() to synchronize this change.
But to do so, the function stop_per_cpu_kthreads() needs to change the
loop from for_each_online_cpu() to for_each_possible_cpu() and remove the
cpu_read_lock(), as the interface_lock can not be taken while the cpu
locks are held. The only side effect of this change is that it may do some
extra work, as the per_cpu variables of the offline CPUs would not be set
anyway, and would simply be skipped in the loop.

Remove unneeded "return;" in stop_kthread().

Cc: stable@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Tomas Glozar <tglozar@redhat.com>
Cc: John Kacur <jkacur@redhat.com>
Cc: "Luis Claudio R. Goncalves" <lgoncalv@redhat.com>
Link: https://lore.kernel.org/20240905113359.2b934242@gandalf.local.home
Fixes: e88ed227f6 ("tracing/timerlat: Add user-space interface")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-09-12 11:11:27 +02:00
..
rv rv: Update rv_en(dis)able_monitor doc to match kernel-doc 2024-06-12 11:12:49 +02:00
blktrace.c
bpf_trace.c bpf: fix multi-uprobe PID filtering logic 2024-06-21 14:38:22 +02: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-17 10:22:42 +09:00
ftrace_internal.h
ftrace.c kprobe/ftrace: bail out if ftrace was killed 2024-06-27 13:49:03 +02:00
Kconfig tracing: Build event generation tests only as modules 2024-06-27 13:49:05 +02:00
kprobe_event_gen_test.c
Makefile tracing/probes: Move finding func-proto API and getting func-param API to trace_btf 2023-08-23 09:39:45 +09:00
pid_list.c trace/pid_list: Change gfp flags in pid_list_fill_irq() 2024-08-03 08:54:17 +02:00
pid_list.h
power-traces.c
preemptirq_delay_test.c tracing: Add MODULE_DESCRIPTION() to preemptirq_delay_test 2024-06-27 13:49:14 +02:00
rethook.c rethook: Use __rcu pointer for rethook::handler 2023-12-13 18:45:19 +01:00
ring_buffer_benchmark.c
ring_buffer.c ring-buffer: Fix a race between readers and resize checks 2024-06-12 11:11:19 +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:42:45 +00:00
trace_benchmark.c
trace_benchmark.h
trace_boot.c
trace_branch.c
trace_btf.c tracing/probes: Fix to search structure fields correctly 2024-02-23 09:25:05 +01:00
trace_btf.h tracing/probes: Add a function to search a member of a struct/union 2023-08-23 09:40:16 +09:00
trace_clock.c
trace_dynevent.c
trace_dynevent.h
trace_entries.h
trace_eprobe.c tracing/probes: Support BTF argument on module functions 2023-08-23 09:39:15 +09:00
trace_event_perf.c
trace_events_filter_test.h
trace_events_filter.c tracing: Have trace_event_file have ref counters 2023-11-08 11:56:21 +01:00
trace_events_hist.c tracing: Have format file honor EVENT_FILE_FL_FREED 2024-09-04 13:28:22 +02:00
trace_events_inject.c tracing: Have format file honor EVENT_FILE_FL_FREED 2024-09-04 13:28:22 +02:00
trace_events_synth.c tracing/synthetic: Fix trace_string() return value 2024-02-23 09:25:05 +01:00
trace_events_trigger.c tracing: Have format file honor EVENT_FILE_FL_FREED 2024-09-04 13:28:22 +02:00
trace_events_user.c tracing/user_events: Fix non-spaced field matching 2024-06-12 11:12:11 +02:00
trace_events.c tracing: Have format file honor EVENT_FILE_FL_FREED 2024-09-04 13:28:22 +02:00
trace_export.c
trace_fprobe.c tracing: fprobe-event: Fix to check tracepoint event and return 2023-11-28 17:20:13 +00:00
trace_functions_graph.c
trace_functions.c
trace_hwlat.c tracing: Remove extra space at the end of hwlat_detector/mode 2023-09-01 21:00:00 -04:00
trace_irqsoff.c tracing: Fix memleak due to race between current_tracer and trace 2023-08-17 13:49:37 -04:00
trace_kdb.c
trace_kprobe_selftest.c
trace_kprobe_selftest.h
trace_kprobe.c tracing/kprobes: Fix the order of argument descriptions 2023-11-20 11:59:38 +01:00
trace_mmiotrace.c
trace_nop.c
trace_osnoise.c tracing/timerlat: Add interface_lock around clearing of kthread in stop_kthread() 2024-09-12 11:11:27 +02:00
trace_output.c tracing: Add size check when printing trace_marker output 2024-01-20 11:51:43 +01:00
trace_output.h
trace_preemptirq.c
trace_printk.c
trace_probe_kernel.h
trace_probe_tmpl.h
trace_probe.c tracing/probes: fix error check in parse_btf_field() 2024-06-12 11:12:51 +02:00
trace_probe.h tracing/probes: Fix to show a parse error for bad type for $comm 2024-02-23 09:25:05 +01:00
trace_recursion_record.c
trace_sched_switch.c
trace_sched_wakeup.c tracing: Fix memleak due to race between current_tracer and trace 2023-08-17 13:49:37 -04: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: bpf: use struct trace_entry in struct syscall_tp_t 2023-08-01 10:53:28 -07:00
trace_uprobe.c Probes updates for v6.6: 2023-09-02 11:10:50 -07:00
trace.c tracing: Avoid possible softlockup in tracing_iter_reset() 2024-09-12 11:11:27 +02:00
trace.h tracing: Have format file honor EVENT_FILE_FL_FREED 2024-09-04 13:28:22 +02:00
tracing_map.c tracing: Fix overflow in get_free_elt() 2024-08-14 13:58:58 +02:00
tracing_map.h