From: Steven Rostedt <rostedt@goodmis.org>
To: Haoran Wang <haoranwangsec@gmail.com>
Cc: mhiramat@kernel.org, linux-kernel@vger.kernel.org,
linux-trace-kernel@vger.kernel.org,
mathieu.desnoyers@efficios.com
Subject: Re: [PATCH] tracing: reject trace events with an empty TP_STRUCT__entry
Date: Fri, 16 Oct 2026 10:13:56 -0400 [thread overview]
Message-ID: <20261016101356.6b9f2a82@gandalf.local.home> (raw)
In-Reply-To: <6ad1cad5.856c1b21.18f9b7.a2c3@mx.google.com>
On Fri, 16 Oct 2026 14:57:22 +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 15:10:00 +0800
> Subject: [PATCH] tracing: reject trace events with an empty TP_STRUCT__entry
>
> trace_event_get_offsets() unconditionally dereferences the first entry of
> an event class's fields list through list_first_entry(). A tracepoint
> that declares an empty TP_STRUCT__entry never populates that list. Its
> fields_array holds only the terminating sentinel, so list_first_entry()
> returns the list head itself and the following tail->offset + tail->size
> reads memory past struct trace_event_class. The corrupted result 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.
>
> Reject such events at registration to fix this bug. event_init() is the
> universal chokepoint invoked for both early-boot and module events, and
> its return is enforced by __register_event(), which refuses to add the call
> to ftrace_events. An event whose fields_array[0].type is NULL (the
> empty-TP_STRUCT__entry sentinel) is rejected with -EINVAL before
> trace_event_get_offsets() can be reached.
>
BTW, what bug are you trying to solve? Just some theoretical bug you found
from a static analyzer or AI?
-- Steve
next prev parent reply other threads:[~2026-10-16 14:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-16 6:57 [PATCH] tracing: reject trace events with an empty TP_STRUCT__entry Haoran Wang
2026-10-16 7:08 ` sashiko-bot
2026-10-16 14:13 ` Steven Rostedt [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-10-16 7:38 Haoran Wang
2026-10-16 7:56 ` sashiko-bot
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=20261016101356.6b9f2a82@gandalf.local.home \
--to=rostedt@goodmis.org \
--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 \
/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