linux-stable/kernel/trace
Tze-nan Wu 6f60aae72c ring-buffer: Ensure proper resetting of atomic variables in ring_buffer_reset_online_cpus
[ Upstream commit 7c339fb4d8 ]

In ring_buffer_reset_online_cpus, the buffer_size_kb write operation
may permanently fail if the cpu_online_mask changes between two
for_each_online_buffer_cpu loops. The number of increases and decreases
on both cpu_buffer->resize_disabled and cpu_buffer->record_disabled may be
inconsistent, causing some CPUs to have non-zero values for these atomic
variables after the function returns.

This issue can be reproduced by "echo 0 > trace" while hotplugging cpu.
After reproducing success, we can find out buffer_size_kb will not be
functional anymore.

To prevent leaving 'resize_disabled' and 'record_disabled' non-zero after
ring_buffer_reset_online_cpus returns, we ensure that each atomic variable
has been set up before atomic_sub() to it.

Link: https://lore.kernel.org/linux-trace-kernel/20230426062027.17451-1-Tze-nan.Wu@mediatek.com

Cc: stable@vger.kernel.org
Cc: <mhiramat@kernel.org>
Cc: npiggin@gmail.com
Fixes: b23d7a5f4a ("ring-buffer: speed up buffer resets by avoiding synchronize_rcu for each CPU")
Reviewed-by: Cheng-Jui Wang <cheng-jui.wang@mediatek.com>
Signed-off-by: Tze-nan Wu <Tze-nan.Wu@mediatek.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-05-17 11:48:09 +02:00
..
blktrace.c blktrace: Fix output non-blktrace event when blk_classic option enabled 2023-01-14 10:15:41 +01:00
bpf_trace.c bpf: Fix a possible task gone issue with bpf_send_signal[_thread]() helpers 2023-02-15 17:22:10 +01:00
bpf_trace.h
fgraph.c fgraph: Initialize tracing_graph_pause at task creation 2021-02-10 09:29:16 +01:00
ftrace.c ftrace: Fix issue that 'direct->addr' not restored in modify_ftrace_direct() 2023-04-20 12:10:23 +02:00
ftrace_internal.h
Kconfig tracing/kprobes: Do the notrace functions check without kprobes on ftrace 2021-01-19 18:27:19 +01:00
kprobe_event_gen_test.c tracing: Fix wrong return in kprobe_event_gen_test.c 2023-04-05 11:23:46 +02:00
Makefile
power-traces.c
preemptirq_delay_test.c
ring_buffer.c ring-buffer: Ensure proper resetting of atomic variables in ring_buffer_reset_online_cpus 2023-05-17 11:48:09 +02:00
ring_buffer_benchmark.c
rpm-traces.c
synth_event_gen_test.c tracing: Fix memory leak in test_gen_synth_cmd() and test_empty_synth_event() 2022-11-25 17:45:49 +01:00
trace.c tracing: Free error logs of tracing instances 2023-04-20 12:10:23 +02:00
trace.h tracing: Make sure trace_printk() can output as soon as it can be used 2023-02-01 08:23:22 +01:00
trace_benchmark.c
trace_benchmark.h
trace_boot.c tracing/boot: Fix a hist trigger dependency for boot time tracing 2021-09-22 12:28:03 +02:00
trace_branch.c
trace_clock.c tracing: Do no increment trace_clock_global() by one 2021-06-23 14:42:50 +02:00
trace_dynevent.c tracing: Free buffers when a used dynamic event is removed 2022-12-08 11:23:58 +01:00
trace_dynevent.h
trace_entries.h
trace_event_perf.c
trace_events.c tracing: Free buffers when a used dynamic event is removed 2022-12-08 11:23:58 +01:00
trace_events_filter.c tracing: Add ustring operation to filtering string pointers 2022-03-08 19:09:31 +01:00
trace_events_filter_test.h
trace_events_hist.c tracing: Check field value in hist_field_name() 2023-03-22 13:30:03 +01:00
trace_events_inject.c
trace_events_synth.c tracing: Fix wild-memory-access in register_synth_event() 2022-11-25 17:45:49 +01:00
trace_events_trigger.c tracing: Dump stacktrace trigger to the corresponding instance 2022-04-27 13:53:46 +02:00
trace_export.c
trace_functions.c tracing: Have all levels of checks prevent recursion 2021-10-27 09:56:56 +02:00
trace_functions_graph.c
trace_hwlat.c
trace_irqsoff.c tracing: Use pause-on-trace with the latency tracers 2021-02-10 09:29:16 +01:00
trace_kdb.c
trace_kprobe.c tracing: Fix return value of __setup handlers 2022-03-08 19:09:38 +01:00
trace_kprobe_selftest.c
trace_kprobe_selftest.h
trace_mmiotrace.c
trace_nop.c
trace_output.c tracing: Make sure trace_printk() can output as soon as it can be used 2023-02-01 08:23:22 +01:00
trace_output.h
trace_preemptirq.c tracing: hold caller_addr to hardirq_{enable,disable}_ip 2022-09-23 14:16:58 +02:00
trace_printk.c
trace_probe.c tracing/probes: Have kprobes and uprobes use $COMM too 2022-08-25 11:38:23 +02:00
trace_probe.h tracing/probes: Reject events which have the same name of existing one 2021-09-22 12:28:00 +02:00
trace_probe_tmpl.h
trace_sched_switch.c
trace_sched_wakeup.c
trace_selftest.c tracing: Disable ftrace selftests when any tracer is running 2020-12-30 11:54:28 +01:00
trace_selftest_dynamic.c
trace_seq.c
trace_stack.c
trace_stat.c
trace_stat.h
trace_synth.h tracing: Synthetic event field_pos is an index not a boolean 2021-07-28 14:35:45 +02:00
trace_syscalls.c
trace_uprobe.c tracing/uprobe: Fix uprobe_perf_open probes iteration 2021-12-01 09:19:01 +01:00
tracing_map.c tracing: Fix a kmemleak false positive in tracing_map 2021-12-17 10:14:40 +01:00
tracing_map.h