Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tracing: Fix checking of freed trace_event_file for hist files

The event_hist_open() and event_hist_poll() functions currently retrieve
a trace_event_file pointer from a file struct by invoking
event_file_data(), which simply returns file->f_inode->i_private. The
functions then check if the pointer is NULL to determine whether the event
is still valid. This approach is flawed because i_private is assigned when
an eventfs inode is allocated and remains set throughout its lifetime.
Instead, the code should call event_file_file(), which checks for
EVENT_FILE_FL_FREED. Using the incorrect access function may result in the
code potentially opening a hist file for an event that is being removed or
becoming stuck while polling on this file.

Correct the access method to event_file_file() in both functions.

Cc: stable@vger.kernel.org
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Tom Zanussi <zanussi@kernel.org>
Link: https://patch.msgid.link/20260219162737.314231-2-petr.pavlu@suse.com
Fixes: 1bd13edbbed6 ("tracing/hist: Add poll(POLLIN) support on hist file")
Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

authored by

Petr Pavlu and committed by
Steven Rostedt (Google)
f0a0da1f f4ff9f64

+2 -2
+2 -2
kernel/trace/trace_events_hist.c
··· 5784 5784 5785 5785 guard(mutex)(&event_mutex); 5786 5786 5787 - event_file = event_file_data(file); 5787 + event_file = event_file_file(file); 5788 5788 if (!event_file) 5789 5789 return EPOLLERR; 5790 5790 ··· 5822 5822 5823 5823 guard(mutex)(&event_mutex); 5824 5824 5825 - event_file = event_file_data(file); 5825 + event_file = event_file_file(file); 5826 5826 if (!event_file) { 5827 5827 ret = -ENODEV; 5828 5828 goto err;