From: Steven Rostedt <rostedt@goodmis.org>
To: sashiko-bot@kernel.org
Cc: sashiko-reviews@lists.linux.dev, linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH] tracing: Take trace_array reference when opening options file
Date: Tue, 1 Sep 2026 19:13:39 -0400 [thread overview]
Message-ID: <20260901191339.25a5a060@robin> (raw)
In-Reply-To: <20260901205421.5832E1F000E9@smtp.kernel.org>
On Tue, 01 Sep 2026 20:54:20 +0000
sashiko-bot@kernel.org wrote:
> [Severity: High]
> Does this raw memory address comparison account for reallocation of the
> trace_array struct?
>
> If a trace instance is deleted, its trace_array is freed. If a new instance
> is subsequently created, it could be allocated at the exact same memory
> address. Could a user holding an O_PATH file descriptor to a core options
> file of the deleted instance reopen it and manipulate the tracer flags of
> the newly allocated instance?
Yes, and we don't care ;-)
If the admin is deleting and creating trace instances and opening
option files at the same time, it's their own fault if the wrong trace
instance option gets changed.
>
> > + return __trace_array_get(tr);
>
> [Severity: Low]
> Will this compile successfully? It appears __trace_array_get() is an
> undeclared function, which might cause a build failure.
Really?
Then what's this: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/kernel/trace/trace.c#n614
?
>
> > + }
> > + return -ENODEV;
> > +}
>
> [ ... ]
>
> > static const struct file_operations trace_options_core_fops = {
> > - .open = tracing_open_generic,
> > - .read = trace_options_core_read,
> > - .write = trace_options_core_write,
> > - .llseek = generic_file_llseek,
> > + .open = trace_options_open,
> > + .read = trace_options_core_read,
> > + .write = trace_options_core_write,
> > + .llseek = generic_file_llseek,
> > + .release = trace_options_release,
> > };
>
> [Severity: Critical]
> This is a pre-existing issue, but does this same Use-After-Free
> vulnerability also exist for tracer-specific options and other
> per-instance files?
>
> While this patch addresses core option files by replacing
> tracing_open_generic with trace_options_open, files like
> tracing_max_latency and tracer-specific options still appear to use
> tracing_open_generic, which doesn't take a reference to the
> trace_array.
>
> For example, if a user opens a per-instance tracing_max_latency file,
> keeps the descriptor open, and the instance is removed, could a
> subsequent write dereference the freed memory?
>
> kernel/trace/trace.c:tracing_max_lat_write() {
> ...
> return tracing_nsecs_write(filp->private_data, ubuf, cnt, ppos);
> }
>
> Where tracing_nsecs_write would perform an unlocked write to the
> freed pointer?
Possibly, but this one was a bit more complex than those others will be
to fix.
-- Steve
next prev parent reply other threads:[~2026-09-01 23:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 20:36 [PATCH] tracing: Take trace_array reference when opening options file Steven Rostedt
2026-09-01 20:54 ` sashiko-bot
2026-09-01 23:13 ` Steven Rostedt [this message]
2026-09-02 0:32 ` Steven Rostedt
2026-09-02 10:36 ` kernel test robot
2026-09-02 13:47 ` Steven Rostedt
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=20260901191339.25a5a060@robin \
--to=rostedt@goodmis.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=sashiko-bot@kernel.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