linux/kernel/trace
Steven Rostedt (VMware) a0997a86f5 tracing: Check length before giving out the filter buffer
commit b220c049d5196dd94d992dd2dc8cba1a5e6123bf upstream.

When filters are used by trace events, a page is allocated on each CPU and
used to copy the trace event fields to this page before writing to the ring
buffer. The reason to use the filter and not write directly into the ring
buffer is because a filter may discard the event and there's more overhead
on discarding from the ring buffer than the extra copy.

The problem here is that there is no check against the size being allocated
when using this page. If an event asks for more than a page size while being
filtered, it will get only a page, leading to the caller writing more that
what was allocated.

Check the length of the request, and if it is more than PAGE_SIZE minus the
header default back to allocating from the ring buffer directly. The ring
buffer may reject the event if its too big anyway, but it wont overflow.

Link: https://lore.kernel.org/ath10k/1612839593-2308-1-git-send-email-wgong@codeaurora.org/

Cc: stable@vger.kernel.org
Fixes: 0fc1b09ff1 ("tracing: Use temp buffer when filtering events")
Reported-by: Wen Gong <wgong@codeaurora.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-02-17 10:35:14 +01:00
..
Kconfig tracing/kprobes: Do the notrace functions check without kprobes on ftrace 2021-01-19 18:26:12 +01:00
Makefile
blktrace.c blktrace: ensure our debugfs dir exists 2020-09-03 11:26:42 +02:00
bpf_trace.c bpf: Fix bpf_put_raw_tracepoint()'s use of __module_address() 2020-12-30 11:51:18 +01:00
fgraph.c fgraph: Initialize tracing_graph_pause at task creation 2021-02-10 09:25:29 +01:00
ftrace.c ftrace: Fix updating FTRACE_FL_TRAMP 2020-12-11 13:23:29 +01:00
ftrace_internal.h
power-traces.c
preemptirq_delay_test.c
ring_buffer.c tracing: Fix race in trace_open and buffer resize call 2021-01-30 13:54:10 +01:00
ring_buffer_benchmark.c
rpm-traces.c
trace.c tracing: Check length before giving out the filter buffer 2021-02-17 10:35:14 +01:00
trace.h ftrace: Handle tracing when switching between context 2020-11-10 12:37:28 +01:00
trace_benchmark.c
trace_benchmark.h
trace_branch.c
trace_clock.c
trace_dynevent.c
trace_dynevent.h
trace_entries.h tracing: Set kernel_stack's caller size properly 2020-10-01 13:17:29 +02:00
trace_event_perf.c
trace_events.c tracing: Do not count ftrace events in top level enable output 2021-02-17 10:35:14 +01:00
trace_events_filter.c
trace_events_filter_test.h
trace_events_hist.c tracing: fix double free 2020-10-01 13:18:23 +02:00
trace_events_trigger.c tracing: Fix event trigger to accept redundant spaces 2020-06-30 15:37:10 -04:00
trace_export.c
trace_functions.c
trace_functions_graph.c
trace_hwlat.c tracing: Remove WARN_ON in start_thread() 2020-12-08 10:40:28 +01:00
trace_irqsoff.c
trace_kdb.c
trace_kprobe.c tracing/kprobe: Fix to support kretprobe events on unloaded modules 2021-02-13 13:52:54 +01:00
trace_kprobe_selftest.c
trace_kprobe_selftest.h
trace_mmiotrace.c
trace_nop.c
trace_output.c tracing: Make the space reserved for the pid wider 2020-10-07 08:01:27 +02:00
trace_output.h
trace_preemptirq.c lockdep: fix order in trace_hardirqs_off_caller() 2020-10-01 13:18:14 +02:00
trace_printk.c
trace_probe.c tracing/probe: Fix memleak in fetch_op_data operations 2020-06-24 17:50:51 +02:00
trace_probe.h
trace_probe_tmpl.h
trace_sched_switch.c
trace_sched_wakeup.c
trace_selftest.c ftrace: Handle tracing when switching between context 2020-11-10 12:37:28 +01:00
trace_selftest_dynamic.c
trace_seq.c
trace_stack.c
trace_stat.c
trace_stat.h
trace_syscalls.c
trace_uprobe.c tracing/probe: Fix bpf_task_fd_query() for kprobes and uprobes 2020-06-24 17:50:43 +02:00
tracing_map.c
tracing_map.h