From: Beau Belgrave <beaub@linux.microsoft.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Haoran Wang <haoranwangsec@gmail.com>,
mhiramat@kernel.org, linux-kernel@vger.kernel.org,
linux-trace-kernel@vger.kernel.org,
mathieu.desnoyers@efficios.com
Subject: Re: [PATCH] tracing: guard trace_event_get_offsets() against an empty fields list
Date: Mon, 26 Oct 2026 19:25:41 +0000 [thread overview]
Message-ID: <20261026192541.GA65-beaub@linux.microsoft.com> (raw)
In-Reply-To: <20261016105100.7a64aa51@gandalf.local.home>
On Fri, Oct 16, 2026 at 10:51:00AM -0400, Steven Rostedt wrote:
> On Fri, 16 Oct 2026 10:22:56 -0400
> Steven Rostedt <rostedt@goodmis.org> wrote:
>
> > On Fri, 16 Oct 2026 17:47:51 +0800
> > Haoran Wang <haoranwangsec@gmail.com> wrote:
> >
> > > From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
> > > From: Haoran Wang <haoranwangsec@gmail.com>
> > > Date: Fri, 16 Oct 2026 16:30:00 +0800
> > > Subject: [PATCH] tracing: guard trace_event_get_offsets() against an empty fields list
> > >
> > > trace_event_get_offsets() dereferences the first entry of the fields list
> > > returned by trace_get_fields() via list_first_entry(). list_first_entry()
> > > then returns the list head itself, and tail->offset + tail->size reads past
> > > it. The corrupted result is used as the BPF context-size bound in
> > > __perf_event_set_bpf_prog():
> > >
> > > int off = trace_event_get_offsets(event->tp_event);
> > > if (prog->aux->max_ctx_offset > off)
> > > return -EACCES;
> > >
> > > so a context-reading BPF program that ought to be rejected can instead be
> > > attached to a zero-field tracepoint (which still carries
> > > TRACE_EVENT_FL_TRACEPOINT) and read adjacent kernel memory when the
> > > tracepoint fires, bypassing the verifier's context-size confinement.
> > >
> > > This is reachable through user_events: a user can register an event with no
> > > fields (e.g. `echo u:my_event > dynamic_events`), which leaves user->fields
> > > empty while the event remains a BPF-attachable tracepoint,
> > > trace_get_fields() then routes through user_event_get_fields() to that
> > > empty list. The corrupted
> > > result after list_first_entry is then used as the BPF context-size bound in
> > > __perf_event_set_bpf_prog(), which lets context-reading BPF programs attach
> > > to a zero-field tracepoint when they should be rejected with -EACCES.
> > >
> >
> > Hmm, so user events can have empty events. :-/
>
> I meant "empty fields".
>
> >
> > Beau, Is that a thing?
>
There have been events in the past that are used simply to signal
something has happened and have no payload/fields. That is a valid
scenario from previous discussions with folks on our side, yes.
Thanks,
-Beau
> -- Steve
next prev parent reply other threads:[~2026-10-26 19:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-16 9:47 [PATCH] tracing: guard trace_event_get_offsets() against an empty fields list Haoran Wang
2026-10-16 14:22 ` Steven Rostedt
2026-10-16 14:51 ` Steven Rostedt
2026-10-26 19:25 ` Beau Belgrave [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-10-15 8:51 Haoran Wang
2026-10-15 9:14 ` sashiko-bot
2026-10-15 11:57 ` 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=20261026192541.GA65-beaub@linux.microsoft.com \
--to=beaub@linux.microsoft.com \
--cc=haoranwangsec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=rostedt@goodmis.org \
/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