Skip to content
/ linux Public

Commit e4e5026

Browse files
petrpavluSasha Levin
authored andcommitted
tracing: Fix checking of freed trace_event_file for hist files
[ Upstream commit f0a0da1 ] 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: 1bd13ed ("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>
1 parent ad058a4 commit e4e5026

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/trace/trace_events_hist.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5760,7 +5760,7 @@ static __poll_t event_hist_poll(struct file *file, struct poll_table_struct *wai
57605760

57615761
guard(mutex)(&event_mutex);
57625762

5763-
event_file = event_file_data(file);
5763+
event_file = event_file_file(file);
57645764
if (!event_file)
57655765
return EPOLLERR;
57665766

@@ -5798,7 +5798,7 @@ static int event_hist_open(struct inode *inode, struct file *file)
57985798

57995799
guard(mutex)(&event_mutex);
58005800

5801-
event_file = event_file_data(file);
5801+
event_file = event_file_file(file);
58025802
if (!event_file) {
58035803
ret = -ENODEV;
58045804
goto err;

0 commit comments

Comments
 (0)