From: sashiko-bot@kernel.org
To: "Haoran Wang" <haoranwangsec@gmail.com>
Cc: linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH] tracing: reject trace events with an empty TP_STRUCT__entry
Date: Fri, 16 Oct 2026 07:08:57 +0000 [thread overview]
Message-ID: <sashiko-outbox-173902@kernel.org> (raw)
In-Reply-To: <6ad1cad5.856c1b21.18f9b7.a2c3@mx.google.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] tracing: user_events broken by fields_array[0].type check
--
commit e8b9d44518a8f72216cba6b41f5a36c08fdcef3c
Author: Haoran Wang <haoranwangsec@gmail.com>
tracing: reject trace events with an empty TP_STRUCT__entry
This patch adds a check in event_init() to reject trace events that have
an empty TP_STRUCT__entry by returning -EINVAL if the first element of
fields_array has a NULL type.
> diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
> index 30c0ddf90887f..9f79fbdf40a20 100644
> --- a/kernel/trace/trace_events.c
> +++ b/kernel/trace/trace_events.c
> @@ -3406,6 +3406,10 @@ static int event_init(struct trace_event_call *call)
> if (WARN_ON(!name))
> return -EINVAL;
>
> + if (call->class->fields_array &&
> + !call->class->fields_array[0].type)
> + return -EINVAL;
[Severity: High]
Does this inadvertently break the user_events subsystem?
In kernel/trace/trace_events_user.c, user_events are assigned a statically
initialized dummy array:
kernel/trace/trace_events_user.c:
static struct trace_event_fields user_event_fields_array[1];
Because this array is size 1 and zero-initialized, its first element's type
field is implicitly NULL. When user_events are registered from userspace via
the ABI, __register_event() calls event_init(), which will evaluate this new
check to true and unconditionally return -EINVAL.
Can we find another way to handle empty TP_STRUCT__entry events that won't
cause a feature regression for user_events?
> +
> if (call->class->raw_init) {
> ret = call->class->raw_init(call);
> if (ret < 0 && ret != -ENOSYS)
--
Sashiko AI review · https://sashiko.dev/#/patchset/6ad1cad5.856c1b21.18f9b7.a2c3@mx.google.com?part=1
next prev parent reply other threads:[~2026-10-16 7:08 UTC|newest]
Thread overview: 4+ 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 [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=sashiko-outbox-173902@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=haoranwangsec@gmail.com \
--cc=linux-trace-kernel@vger.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