]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
tracing: Fix checking of freed trace_event_file for hist files
authorPetr Pavlu <petr.pavlu@suse.com>
Thu, 19 Feb 2026 16:27:01 +0000 (17:27 +0100)
committerSasha Levin <sashal@kernel.org>
Wed, 4 Mar 2026 12:21:35 +0000 (07:21 -0500)
commitd4e45ca6db6786f40a72daf7a44bf54dcc237f31
treedeb01622787cd688ca4eeb1e57e33943e8bddf02
parentc71ea5a712339de402569f00d5af3f010ce786dc
tracing: Fix checking of freed trace_event_file for hist files

[ Upstream commit f0a0da1f907e8488826d91c465f7967a56a95aca ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/trace/trace_events_hist.c