linux-stable/kernel/trace
Steven Rostedt (Google) 3a70b1c932 tracing: Use .flush() call to wake up readers
commit e5d7c19165 upstream.

The .release() function does not get called until all readers of a file
descriptor are finished.

If a thread is blocked on reading a file descriptor in ring_buffer_wait(),
and another thread closes the file descriptor, it will not wake up the
other thread as ring_buffer_wake_waiters() is called by .release(), and
that will not get called until the .read() is finished.

The issue originally showed up in trace-cmd, but the readers are actually
other processes with their own file descriptors. So calling close() would wake
up the other tasks because they are blocked on another descriptor then the
one that was closed(). But there's other wake ups that solve that issue.

When a thread is blocked on a read, it can still hang even when another
thread closed its descriptor.

This is what the .flush() callback is for. Have the .flush() wake up the
readers.

Link: https://lore.kernel.org/linux-trace-kernel/20240308202432.107909457@goodmis.org

Cc: stable@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linke li <lilinke99@qq.com>
Cc: Rabin Vincent <rabin@rab.in>
Fixes: f3ddb74ad0 ("tracing: Wake up ring buffer waiters on closing of the file")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-04-03 15:19:40 +02:00
..
rv
blktrace.c trace/blktrace: fix memory leak with using debugfs_lookup() 2023-03-10 09:33:46 +01:00
bpf_trace.c bpf: Remove trace_printk_lock 2024-02-23 09:12:51 +01:00
bpf_trace.h
error_report-traces.c
fgraph.c
fprobe.c fprobe: Fix to ensure the number of active retprobes is not zero 2023-10-25 12:03:12 +02:00
ftrace.c ftrace: Fix possible warning on checking all pages used in ftrace_process_locs() 2023-07-23 13:49:44 +02:00
ftrace_internal.h
Kconfig tracing: Fix complicated dependency of CONFIG_TRACER_MAX_TRACE 2023-01-07 11:11:48 +01:00
kprobe_event_gen_test.c tracing: Fix wrong return in kprobe_event_gen_test.c 2023-04-06 12:10:41 +02:00
Makefile
pid_list.c
pid_list.h
power-traces.c
preemptirq_delay_test.c
rethook.c rethook: Use __rcu pointer for rethook::handler 2023-12-13 18:39:17 +01:00
ring_buffer.c ring-buffer: Use wait_event_interruptible() in ring_buffer_wait() 2024-04-03 15:19:35 +02:00
ring_buffer_benchmark.c
rpm-traces.c
synth_event_gen_test.c tracing / synthetic: Disable events after testing in synth_event_gen_test_init() 2024-01-01 12:39:07 +00:00
trace.c tracing: Use .flush() call to wake up readers 2024-04-03 15:19:40 +02:00
trace.h tracing: Fix uaf issue when open the hist or hist_debug file 2024-01-20 11:50:07 +01:00
trace_benchmark.c
trace_benchmark.h
trace_boot.c
trace_branch.c
trace_clock.c
trace_dynevent.c
trace_dynevent.h
trace_entries.h
trace_eprobe.c kernel/trace: Fix cleanup logic of enable_trace_eprobe 2023-07-23 13:49:24 +02:00
trace_event_perf.c
trace_events.c tracing: Have trace_event_file have ref counters 2023-11-28 17:07:23 +00:00
trace_events_filter.c tracing: Have trace_event_file have ref counters 2023-11-28 17:07:23 +00:00
trace_events_filter_test.h
trace_events_hist.c tracing: Fix uaf issue when open the hist or hist_debug file 2024-01-20 11:50:07 +01:00
trace_events_inject.c tracing: Have event inject files inc the trace array ref count 2023-09-23 11:11:11 +02:00
trace_events_synth.c tracing: Have the user copy of synthetic event address use correct context 2023-11-28 17:07:13 +00:00
trace_events_trigger.c tracing/trigger: Fix to return error if failed to alloc snapshot 2024-02-23 09:12:32 +01:00
trace_events_user.c tracing/user_events: Fix struct arg size match check 2023-07-23 13:49:47 +02:00
trace_export.c tracing: Fix TASK_COMM_LEN in trace event format file 2023-02-14 19:11:54 +01:00
trace_functions.c
trace_functions_graph.c
trace_hwlat.c tracing: Remove extra space at the end of hwlat_detector/mode 2023-09-13 09:42:57 +02:00
trace_irqsoff.c tracing: Fix memleak due to race between current_tracer and trace 2023-08-30 16:11:00 +02:00
trace_kdb.c
trace_kprobe.c tracing/kprobes: Fix symbol counting logic by looking at modules as well 2024-01-05 15:18:40 +01:00
trace_kprobe_selftest.c
trace_kprobe_selftest.h
trace_mmiotrace.c
trace_nop.c
trace_osnoise.c tracing/timerlat: Always wakeup the timerlat thread 2023-06-09 10:34:24 +02:00
trace_output.c tracing: Add size check when printing trace_marker output 2024-01-20 11:50:07 +01:00
trace_output.h
trace_preemptirq.c
trace_printk.c
trace_probe.c Revert "tracing: Add "(fault)" name injection to kernel probes" 2023-08-03 10:23:55 +02:00
trace_probe.h tracing/kprobes: Return EADDRNOTAVAIL when func matches several symbols 2023-10-25 12:03:16 +02:00
trace_probe_kernel.h tracing/probes: Fix to record 0-length data_loc in fetch_store_string*() if fails 2023-08-03 10:23:55 +02:00
trace_probe_tmpl.h tracing/probes: Fix to record 0-length data_loc in fetch_store_string*() if fails 2023-08-03 10:23:55 +02:00
trace_recursion_record.c
trace_sched_switch.c
trace_sched_wakeup.c tracing: Fix memleak due to race between current_tracer and trace 2023-08-30 16:11:00 +02:00
trace_selftest.c
trace_selftest_dynamic.c
trace_seq.c
trace_stack.c
trace_stat.c
trace_stat.h
trace_synth.h tracing: Allow synthetic events to pass around stacktraces 2023-08-03 10:23:55 +02:00
trace_syscalls.c
trace_uprobe.c bpf: Clear the probe_addr for uprobe 2023-09-13 09:42:30 +02:00
tracing_map.c tracing: Ensure visibility when inserting an element into tracing_map 2024-01-31 16:17:04 -08:00
tracing_map.h