From: sashiko-bot@kernel.org
To: "Steven Rostedt" <rostedt@goodmis.org>
Cc: linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH] tracing: Have show_event_filters/triggers files take trace array ref
Date: Fri, 28 Aug 2026 13:58:57 +0000 [thread overview]
Message-ID: <20260828135858.2AC501F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260828094153.17b95037@gandalf.local.home>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [Critical] Use-after-free in trace_options_core_read and trace_options_core_write due to missing trace_array reference.
--
commit ea5806b528a93a9450975f8b2320a019a3fbc9c7
Author: Steven Rostedt <rostedt@goodmis.org>
tracing: Have show_event_filters/triggers files take trace array ref
This commit fixes a use-after-free issue when reading show_event_filters or
show_event_triggers files by ensuring their open operations take a reference
on the trace array. This prevents the trace array from being freed via rmdir
while a task is still reading the files.
Closes: https://lore.kernel.org/all/CA+0ovCjerKZJLwXScM9bF2ga2rLi4_XOpUfK41NDbENpeu98jA@mail.gmail.com/
> diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
> index 9f8f2d02276ca..e676601943362 100644
> --- a/kernel/trace/trace_events.c
> +++ b/kernel/trace/trace_events.c
[ ... ]
> @@ -2908,7 +2908,17 @@ ftrace_event_set_open(struct inode *inode, struct file *file)
> static int
> ftrace_event_show_filters_open(struct inode *inode, struct file *file)
> {
> - return ftrace_event_open(inode, file, &show_show_event_filters_seq_ops);
> + struct trace_array *tr = inode->i_private;
> + int ret;
> +
> + ret = tracing_check_open_get_tr(tr);
[Severity: Critical]
This isn't a bug introduced by this patch, but since we are fixing missing
trace array references, does a similar use-after-free exist for the trace
options files?
Looking at trace_options_core_fops in kernel/trace/trace.c, it registers
tracing_open_generic() as the open handler. That function passes NULL
to tracing_check_open_get_tr(), bypassing the trace_array_get() call:
kernel/trace/trace.c:tracing_open_generic() {
int ret;
ret = tracing_check_open_get_tr(NULL);
if (ret)
return ret;
filp->private_data = inode->i_private;
return 0;
}
Because no reference is taken on the trace array, could a user remove the
trace instance via rmdir while holding the options file open, and then
trigger a use-after-free when reading or writing?
For example, trace_options_core_read() retrieves the freed trace_array
via get_tr_index() and immediately dereferences it:
kernel/trace/trace.c:trace_options_core_read() {
...
get_tr_index(tr_index, &tr, &index);
if (tr->trace_flags & (1ULL << index))
...
}
> + if (ret)
> + return ret;
> +
> + ret = ftrace_event_open(inode, file, &show_show_event_filters_seq_ops);
> + if (ret < 0)
> + trace_array_put(tr);
> + return ret;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260828094153.17b95037@gandalf.local.home?part=1
next prev parent reply other threads:[~2026-08-28 13:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-28 13:41 [PATCH] tracing: Have show_event_filters/triggers files take trace array ref Steven Rostedt
2026-08-28 13:58 ` sashiko-bot [this message]
2026-08-29 8:21 ` Aaron Tomlin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260828135858.2AC501F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).