android_kernel_xiaomi_sm8450/kernel/trace
Tze-nan Wu eb223bf01e tracing: Fix overflow in get_free_elt()
commit bcf86c01ca4676316557dd482c8416ece8c2e143 upstream.

"tracing_map->next_elt" in get_free_elt() is at risk of overflowing.

Once it overflows, new elements can still be inserted into the tracing_map
even though the maximum number of elements (`max_elts`) has been reached.
Continuing to insert elements after the overflow could result in the
tracing_map containing "tracing_map->max_size" elements, leaving no empty
entries.
If any attempt is made to insert an element into a full tracing_map using
`__tracing_map_insert()`, it will cause an infinite loop with preemption
disabled, leading to a CPU hang problem.

Fix this by preventing any further increments to "tracing_map->next_elt"
once it reaches "tracing_map->max_elt".

Cc: stable@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Fixes: 08d43a5fa0 ("tracing: Add lock-free tracing_map")
Co-developed-by: Cheng-Jui Wang <cheng-jui.wang@mediatek.com>
Link: https://lore.kernel.org/20240805055922.6277-1-Tze-nan.Wu@mediatek.com
Signed-off-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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-08-19 05:41:20 +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: Clear the probe_addr for uprobe 2023-09-19 12:20:07 +02:00
bpf_trace.h bpf: Use dedicated bpf_trace_printk event instead of trace_printk() 2020-07-13 16:55:49 -07:00
fgraph.c fgraph: Initialize tracing_graph_pause at task creation 2021-02-10 09:29:16 +01:00
ftrace_internal.h x86/ftrace: Have ftrace trampolines turn read-only at the end of system boot up 2020-05-12 18:24:34 -04:00
ftrace.c ftrace: Fix possible warning on checking all pages used in ftrace_process_locs() 2023-07-27 08:44:44 +02:00
Kconfig tracing: Build event generation tests only as modules 2024-07-05 09:12:37 +02: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 Kbuild updates for v5.9 2020-08-09 14:10:26 -07:00
power-traces.c
preemptirq_delay_test.c tracing: Add MODULE_DESCRIPTION() to preemptirq_delay_test 2024-07-05 09:12:43 +02:00
ring_buffer_benchmark.c sched,tracing: Convert to sched_set_fifo() 2020-07-29 11:43:53 +02:00
ring_buffer.c ring-buffer: Fix a race between readers and resize checks 2024-06-16 13:31:59 +02:00
rpm-traces.c
synth_event_gen_test.c tracing / synthetic: Disable events after testing in synth_event_gen_test_init() 2024-01-05 15:12:28 +01:00
trace_benchmark.c trace: Use pr_warn instead of pr_warning 2019-10-18 15:01:57 +02:00
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 tracing: Make struct ring_buffer less ambiguous 2020-01-13 13:19:38 -05:00
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 tracing: Remove check_arg() callbacks from dynevent args 2020-02-01 13:09:23 -05:00
trace_entries.h tracing: Make ftrace packed events have align of 1 2020-06-16 21:21:02 -04:00
trace_event_perf.c tracing: Show size of requested perf buffer 2024-05-02 16:23:43 +02:00
trace_events_filter_test.h
trace_events_filter.c tracing: Have trace_event_file have ref counters 2023-11-28 16:55:02 +00:00
trace_events_hist.c tracing/histograms: Return an error if we fail to add histogram to hist_vars list 2023-07-27 08:44:43 +02:00
trace_events_inject.c tracing: Have event inject files inc the trace array ref count 2023-10-10 21:53:25 +02:00
trace_events_synth.c tracing: Add tracing_reset_all_online_cpus_unlocked() function 2023-06-28 10:28:06 +02:00
trace_events_trigger.c Revert "tracing/trigger: Fix to return error if failed to alloc snapshot" 2024-05-02 16:23:36 +02:00
trace_events.c tracing: Have trace_event_file have ref counters 2023-11-28 16:55:02 +00:00
trace_export.c treewide: Convert macro and uses of __section(foo) to __section("foo") 2020-10-25 14:51:49 -07:00
trace_functions_graph.c tracing: make tracing_init_dentry() returns an integer instead of a d_entry pointer 2020-09-18 22:17:14 -04:00
trace_functions.c tracing: Have all levels of checks prevent recursion 2021-10-27 09:56:56 +02:00
trace_hwlat.c tracing: Remove WARN_ON in start_thread() 2020-11-30 21:43:07 -05:00
trace_irqsoff.c tracing: Fix memleak due to race between current_tracer and trace 2023-08-30 16:23:12 +02:00
trace_kdb.c tracing: Rename trace_buffer to array_buffer 2020-01-13 13:19:38 -05:00
trace_kprobe_selftest.c
trace_kprobe_selftest.h
trace_kprobe.c module: use RCU to synchronize find_module 2024-06-21 14:52:58 +02:00
trace_mmiotrace.c tracing: Make struct ring_buffer less ambiguous 2020-01-13 13:19:38 -05:00
trace_nop.c
trace_output.c tracing: Add size check when printing trace_marker output 2024-01-25 14:37:37 -08: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 Updates for tracing and bootconfig: 2020-10-15 15:51:28 -07:00
trace_probe_tmpl.h tracing/probes: Fix to update dynamic data counter if fetcharg uses it 2023-08-26 15:26:50 +02:00
trace_probe.c tracing/probes: Have kprobes and uprobes use $COMM too 2022-08-25 11:38:23 +02:00
trace_probe.h tracing/probe: trace_probe_primary_from_call(): checked list_first_entry 2023-06-09 10:30:16 +02:00
trace_sched_switch.c tracing: Fix sched switch start/stop refcount racy updates 2020-01-30 09:46:10 -05:00
trace_sched_wakeup.c tracing: Fix memleak due to race between current_tracer and trace 2023-08-30 16:23:12 +02:00
trace_selftest_dynamic.c
trace_selftest.c tracing: Disable ftrace selftests when any tracer is running 2020-12-30 11:54:28 +01:00
trace_seq.c tracing: Remove unused TRACE_SEQ_BUF_USED 2020-01-21 18:39:54 -05:00
trace_stack.c tracing: make tracing_init_dentry() returns an integer instead of a d_entry pointer 2020-09-18 22:17:14 -04:00
trace_stat.c tracing: make tracing_init_dentry() returns an integer instead of a d_entry pointer 2020-09-18 22:17:14 -04:00
trace_stat.h tracing: Use generic type for comparator function 2019-11-14 13:15:11 -05:00
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 Tracing updates: 2020-02-06 07:12:11 +00:00
trace_uprobe.c bpf: Clear the probe_addr for uprobe 2023-09-19 12:20:07 +02:00
trace.c tracing: Inform kmemleak of saved_cmdlines allocation 2024-02-23 08:42:30 +01:00
trace.h tracing: Have trace_event_file have ref counters 2023-11-28 16:55:02 +00:00
tracing_map.c tracing: Fix overflow in get_free_elt() 2024-08-19 05:41:20 +02:00
tracing_map.h