linux/kernel/trace
Zheng Yejian d5a8218963 tracing: Fix memory leak of iter->temp when reading trace_pipe
kmemleak reports:
  unreferenced object 0xffff88814d14e200 (size 256):
    comm "cat", pid 336, jiffies 4294871818 (age 779.490s)
    hex dump (first 32 bytes):
      04 00 01 03 00 00 00 00 08 00 00 00 00 00 00 00  ................
      0c d8 c8 9b ff ff ff ff 04 5a ca 9b ff ff ff ff  .........Z......
    backtrace:
      [<ffffffff9bdff18f>] __kmalloc+0x4f/0x140
      [<ffffffff9bc9238b>] trace_find_next_entry+0xbb/0x1d0
      [<ffffffff9bc9caef>] trace_print_lat_context+0xaf/0x4e0
      [<ffffffff9bc94490>] print_trace_line+0x3e0/0x950
      [<ffffffff9bc95499>] tracing_read_pipe+0x2d9/0x5a0
      [<ffffffff9bf03a43>] vfs_read+0x143/0x520
      [<ffffffff9bf04c2d>] ksys_read+0xbd/0x160
      [<ffffffff9d0f0edf>] do_syscall_64+0x3f/0x90
      [<ffffffff9d2000aa>] entry_SYSCALL_64_after_hwframe+0x6e/0xd8

when reading file 'trace_pipe', 'iter->temp' is allocated or relocated
in trace_find_next_entry() but not freed before 'trace_pipe' is closed.

To fix it, free 'iter->temp' in tracing_release_pipe().

Link: https://lore.kernel.org/linux-trace-kernel/20230713141435.1133021-1-zhengyejian1@huawei.com

Cc: stable@vger.kernel.org
Fixes: ff895103a8 ("tracing: Save off entry when peeking at next entry")
Signed-off-by: Zheng Yejian <zhengyejian1@huawei.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
2023-07-13 10:48:36 -04:00
..
rv tracing/tools: Updates for 6.4 2023-04-28 16:11:26 -07:00
blktrace.c
bpf_trace.c Probes updates for v6.5: 2023-06-30 10:44:53 -07:00
bpf_trace.h
error_report-traces.c
fgraph.c tracing: arm64: Avoid missing-prototype warnings 2023-07-12 12:06:04 -04:00
fprobe.c tracing/probes: Add fprobe events for tracing function entry and exit. 2023-06-06 21:39:55 +09:00
ftrace_internal.h tracing: arm64: Avoid missing-prototype warnings 2023-07-12 12:06:04 -04:00
ftrace.c ftrace: Fix possible warning on checking all pages used in ftrace_process_locs() 2023-07-12 17:47:37 -04:00
Kconfig Probes updates for v6.5: 2023-06-30 10:44:53 -07:00
kprobe_event_gen_test.c
Makefile tracing/probes: Add fprobe events for tracing function entry and exit. 2023-06-06 21:39:55 +09:00
pid_list.c
pid_list.h
power-traces.c
preemptirq_delay_test.c
rethook.c fprobe: Pass return address to the handlers 2023-06-06 21:39:55 +09:00
ring_buffer_benchmark.c
ring_buffer.c ring-buffer: Fix deadloop issue on reading trace_pipe 2023-07-12 12:15:26 -04:00
rpm-traces.c
synth_event_gen_test.c
trace_benchmark.c
trace_benchmark.h
trace_boot.c tracing/boot: Test strscpy() against less than zero for error 2023-07-05 10:30:49 -04:00
trace_branch.c
trace_clock.c
trace_dynevent.c
trace_dynevent.h
trace_entries.h function_graph: Support recording and printing the return value of function 2023-06-20 18:38:37 -04:00
trace_eprobe.c tracing/probes: Move event parameter fetching code to common parser 2023-06-06 21:39:56 +09:00
trace_event_perf.c
trace_events_filter_test.h
trace_events_filter.c
trace_events_hist.c tracing/histograms: Add histograms to hist_vars if they have referenced variables 2023-07-12 19:08:56 -04:00
trace_events_inject.c tracing: Replace all non-returning strlcpy with strscpy 2023-05-26 13:52:19 -07:00
trace_events_synth.c
trace_events_trigger.c
trace_events_user.c tracing/user_events: Fix struct arg size match check 2023-07-10 21:38:13 -04:00
trace_events.c hardening updates for v6.5-rc1 2023-06-27 21:24:18 -07:00
trace_export.c
trace_fprobe.c tracing/probes: Add $arg* meta argument for all function args 2023-06-06 21:39:56 +09:00
trace_functions_graph.c function_graph: Support recording and printing the return value of function 2023-06-20 18:38:37 -04:00
trace_functions.c
trace_hwlat.c
trace_irqsoff.c
trace_kdb.c
trace_kprobe_selftest.c tracing: arm64: Avoid missing-prototype warnings 2023-07-12 12:06:04 -04:00
trace_kprobe_selftest.h
trace_kprobe.c Probes updates for v6.5: 2023-06-30 10:44:53 -07:00
trace_mmiotrace.c
trace_nop.c
trace_osnoise.c tracing/timerlat: Add user-space interface 2023-06-22 10:39:56 -04:00
trace_output.c Tracing updates for 6.5: 2023-06-30 10:33:17 -07:00
trace_output.h
trace_preemptirq.c
trace_printk.c
trace_probe_kernel.h
trace_probe_tmpl.h
trace_probe.c Probes updates for v6.5: 2023-06-30 10:44:53 -07:00
trace_probe.h tracing/probes: Add BTF retval type support 2023-06-06 21:39:56 +09:00
trace_recursion_record.c
trace_sched_switch.c
trace_sched_wakeup.c
trace_selftest_dynamic.c
trace_selftest.c tracing: Have function_graph selftest call cond_resched() 2023-05-28 21:15:46 -04:00
trace_seq.c
trace_stack.c
trace_stat.c
trace_stat.h
trace_synth.h
trace_syscalls.c
trace_uprobe.c tracing/probes: Move event parameter fetching code to common parser 2023-06-06 21:39:56 +09:00
trace.c tracing: Fix memory leak of iter->temp when reading trace_pipe 2023-07-13 10:48:36 -04:00
trace.h Probes updates for v6.5: 2023-06-30 10:44:53 -07:00
tracing_map.c
tracing_map.h