From: sashiko-bot@kernel.org
To: "Henry Martin" <bsdhenrymartin@gmail.com>
Cc: linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH] tracing: Fix use-after-free on field name/type of dynamic probe events
Date: Mon, 24 Aug 2026 07:27:34 +0000 [thread overview]
Message-ID: <20260824072735.2BE431F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260824071011.3507735-1-bsdhenrymartin@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [Medium] The commit message claims that fields of static trace events reference their kernel or module rodata string literals directly without allocation, but module strings are unconditionally duplicated.
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but if a user_event's destruction fails because the trace event is busy, its fields are irreversibly destroyed, leaving the active event in a corrupted state.
--
--- Patch [1]: [PATCH] tracing: Fix use-after-free on field name/type of dynamic probe events ---
commit cf6ec74d4b06c238fc3f0cc0f2463ea2e1435590
Author: Henry Martin <bsdhenrymartin@gmail.com>
tracing: Fix use-after-free on field name/type of dynamic probe events
This commit modifies dynamic event trace field registration to duplicate
field name and type strings using kstrdup_const(). This ensures the field
owns its strings and prevents use-after-free bugs when primary probes are
deleted but event calls remain active.
> diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
> index 0356cae0cf74e..13d7675bc5132 100644
> --- a/kernel/trace/trace_events.c
> +++ b/kernel/trace/trace_events.c
> @@ -122,8 +122,18 @@ static int __trace_define_field(struct list_head *head, const char *type,
> if (!field)
> return -ENOMEM;
>
> - field->name = name;
> - field->type = type;
> + field->name = kstrdup_const(name, GFP_TRACE);
> + if (!field->name) {
> + kmem_cache_free(field_cachep, field);
> + return -ENOMEM;
> + }
> +
> + field->type = kstrdup_const(type, GFP_TRACE);
[Severity: Medium]
The commit message states that fields of static trace events reference their
kernel or module rodata string literals directly, as kstrdup_const() only
touches allocated memory.
Does kstrdup_const() actually handle module rodata this way? Looking at
kstrdup_const(), it delegates to is_kernel_rodata(), which only checks core
kernel boundaries.
Won't this cause module trace events to unconditionally duplicate their name
and type strings instead of referencing the module rodata?
> + if (!field->type) {
> + kfree_const(field->name);
> + kmem_cache_free(field_cachep, field);
> + return -ENOMEM;
> + }
>
> if (filter_type == FILTER_OTHER)
[ ... ]
While reviewing the string lifecycle in trace events, a related preexisting
issue in user events was identified:
kernel/trace/trace_events_user.c:destroy_user_event() {
...
/* Must destroy fields before call removal */
user_event_destroy_fields(user);
ret = user_event_set_call_visible(user, false);
if (ret)
return ret;
...
}
[Severity: High]
This isn't a bug introduced by this patch, but if a user_event's destruction
fails because the trace event is busy (user_event_set_call_visible() returns
-EBUSY), the event's fields are already irreversibly destroyed.
Will this leave the active event in a corrupted state, where any subsequent
interactions with this event operate on an empty field list?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260824071011.3507735-1-bsdhenrymartin@gmail.com?part=1
next prev parent reply other threads:[~2026-08-24 7:27 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-24 7:10 [PATCH] tracing: Fix use-after-free on field name/type of dynamic probe events Henry Martin
2026-08-24 7:27 ` sashiko-bot [this message]
2026-08-24 18:43 ` Steven Rostedt
2026-08-25 11:12 ` [PATCH v3] tracing/probes: Fix use-after-free on field name/type of multi-probe events Henry Martin
2026-08-25 11:37 ` sashiko-bot
2026-08-25 14:22 ` Steven Rostedt
2026-08-26 3:00 ` [PATCH v4] tracing/probes: Fix use-after-free on field name/type of events with multiple probes Henry Martin
2026-09-02 1:05 ` Masami Hiramatsu
2026-08-26 3:11 ` [PATCH v3] tracing/probes: Fix use-after-free on field name/type of multi-probe events henry martin
2026-08-25 13:51 ` Steven Rostedt
[not found] ` <CAEnQdOo0qHQK5veJp0Ybf3Hm3Gn2iUicL9Xj_bTNZKhoMfFOTw@mail.gmail.com>
2026-08-25 13:38 ` [PATCH] tracing: Fix use-after-free on field name/type of dynamic probe events 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=20260824072735.2BE431F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bsdhenrymartin@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.