linux-stable/kernel/trace
Tze-nan Wu 93f8b66403 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:50:13 +02:00
..
Kconfig tracing: Fix complicated dependency of CONFIG_TRACER_MAX_TRACE 2023-01-12 11:58:55 +01:00
Makefile tracing: Place trace_pid_list logic into abstract functions 2022-07-29 17:25:29 +02:00
blktrace.c trace/blktrace: fix memory leak with using debugfs_lookup() 2023-03-10 09:39:47 +01:00
bpf_trace.c bpf: Fix a possible task gone issue with bpf_send_signal[_thread]() helpers 2023-02-09 11:26:33 +01:00
bpf_trace.h
error_report-traces.c tracing: add error_report_end trace point 2021-02-26 09:41:02 -08:00
fgraph.c tracing: Fix various typos in comments 2021-03-23 14:08:18 -04:00
ftrace.c ftrace: Fix issue that 'direct->addr' not restored in modify_ftrace_direct() 2023-04-13 16:48:24 +02:00
ftrace_internal.h
kprobe_event_gen_test.c tracing: Fix wrong return in kprobe_event_gen_test.c 2023-04-05 11:24:54 +02:00
pid_list.c tracing: Place trace_pid_list logic into abstract functions 2022-07-29 17:25:29 +02:00
pid_list.h tracing: Place trace_pid_list logic into abstract functions 2022-07-29 17:25:29 +02:00
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:50:13 +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-26 09:24:43 +01:00
trace.c tracing: Fix permissions for the buffer_percent file 2023-05-11 23:00:18 +09:00
trace.h tracing: Make sure trace_printk() can output as soon as it can be used 2023-02-01 08:27:23 +01:00
trace_benchmark.c
trace_benchmark.h
trace_boot.c tracing: Initialize integer variable to prevent garbage return value 2022-06-09 10:23:21 +02:00
trace_branch.c
trace_clock.c tracing: Do no increment trace_clock_global() by one 2021-06-18 09:10:00 -04:00
trace_dynevent.c tracing: Free buffers when a used dynamic event is removed 2022-12-08 11:28:43 +01:00
trace_dynevent.h tracing: Add DYNAMIC flag for dynamic events 2021-08-18 18:10:32 -04:00
trace_entries.h trace: Add timerlat tracer 2021-06-25 19:57:24 -04:00
trace_eprobe.c tracing: Fix race where eprobes can be called before the event 2023-01-12 11:58:54 +01:00
trace_event_perf.c tracing/perf: Fix double put of trace event when init fails 2022-08-25 11:39:57 +02:00
trace_events.c tracing: Free buffers when a used dynamic event is removed 2022-12-08 11:28:43 +01:00
trace_events_filter.c tracing: Add ustring operation to filtering string pointers 2022-03-08 19:12:33 +01:00
trace_events_filter_test.h
trace_events_hist.c tracing: Check field value in hist_field_name() 2023-03-22 13:31:33 +01:00
trace_events_inject.c
trace_events_synth.c tracing: Fix issue of missing one synthetic field 2023-01-12 11:59:03 +01:00
trace_events_trigger.c tracing: Fix to check event_mutex is held while accessing trigger list 2022-09-15 11:30:02 +02:00
trace_export.c
trace_functions.c tracing: Add "func_no_repeats" option for function tracing 2021-04-15 14:50:02 -04:00
trace_functions_graph.c tracing: Disable "other" permission bits in the tracefs files 2021-11-18 19:16:15 +01:00
trace_hwlat.c trace/hwlat: Do not start per-cpu thread if it is already running 2023-03-30 12:47:43 +02:00
trace_irqsoff.c
trace_kdb.c kdb: Rename members of struct kdbtab_t 2021-07-27 17:05:06 +01:00
trace_kprobe.c tracing: Move duplicate code of trace_kprobe/eprobe.c into header 2022-10-26 12:34:31 +02:00
trace_kprobe_selftest.c
trace_kprobe_selftest.h
trace_mmiotrace.c
trace_nop.c
trace_osnoise.c tracing/osnoise: Fix duration type 2022-12-08 11:28:43 +01:00
trace_output.c tracing: Make sure trace_printk() can output as soon as it can be used 2023-02-01 08:27:23 +01:00
trace_output.h
trace_preemptirq.c tracing: hold caller_addr to hardirq_{enable,disable}_ip 2022-09-20 12:39:43 +02:00
trace_printk.c tracing: Disable "other" permission bits in the tracefs files 2021-11-18 19:16:15 +01:00
trace_probe.c tracing/probes: Handle system names with hyphens 2023-01-12 11:58:55 +01:00
trace_probe.h tracing: Add a probe that attaches to trace events 2021-08-20 14:18:40 -04:00
trace_probe_kernel.h tracing: Add "(fault)" name injection to kernel probes 2022-10-26 12:34:32 +02:00
trace_probe_tmpl.h tracing/probes: Have process_fetch_insn() take a void * instead of pt_regs 2021-08-19 09:09:03 -04:00
trace_recursion_record.c tracing: Disable "other" permission bits in the tracefs files 2021-11-18 19:16:15 +01:00
trace_sched_switch.c
trace_sched_wakeup.c tracing: Change variable type as bool for clean-up 2021-06-30 09:19:14 -04:00
trace_selftest.c tracing: Fix various typos in comments 2021-03-23 14:08:18 -04:00
trace_selftest_dynamic.c
trace_seq.c tracing: Fix various typos in comments 2021-03-23 14:08:18 -04:00
trace_stack.c tracing: Disable "other" permission bits in the tracefs files 2021-11-18 19:16:15 +01:00
trace_stat.c tracing: Disable "other" permission bits in the tracefs files 2021-11-18 19:16:15 +01:00
trace_stat.h
trace_synth.h tracing: synth events: increase max fields count 2021-09-08 15:29:16 -04:00
trace_syscalls.c tracing: Make tp_printk work on syscall tracepoints 2022-06-14 18:36:14 +02:00
trace_uprobe.c tracing/uprobes: Check the return value of kstrdup() for tu->filename 2022-03-08 19:12:38 +01:00
tracing_map.c tracing: Fix a kmemleak false positive in tracing_map 2021-12-17 10:30:16 +01:00
tracing_map.h