From: sashiko-bot@kernel.org
To: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>,
linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] tracing/eprobe: Handle trace_event_trigger_enable_disable() failure in enable_eprobe()
Date: Sun, 06 Dec 2026 12:40:16 +0000 [thread overview]
Message-ID: <sashiko-outbox-252418@kernel.org> (raw)
In-Reply-To: <20261206115150.61594-3-mhiramat@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] tracing/eprobe: enable_eprobe() leaks trigger refs before
rollback patch
--
commit 44a771e8b7821d8a28db42549bdfb945cfc5efb2
Author: Masami Hiramatsu (Google) <mhiramat@kernel.org>
tracing/eprobe: Handle trace_event_trigger_enable_disable() failure in enable_eprobe()
This commit checks the return value of trace_event_trigger_enable_disable()
in enable_eprobe() and unlinks and frees the trigger on failure.
> diff --git a/kernel/trace/trace_eprobe.c b/kernel/trace/trace_eprobe.c
> index f65393fb1c102..88ea0ca3083df 100644
> --- a/kernel/trace/trace_eprobe.c
> +++ b/kernel/trace/trace_eprobe.c
[ ... ]
> @@ -591,7 +592,18 @@ static int enable_eprobe(struct trace_eprobe *ep,
>
> list_add_tail_rcu(&trigger->list, &file->triggers);
>
> - trace_event_trigger_enable_disable(file, 1);
> + ret = trace_event_trigger_enable_disable(file, 1);
> + if (ret < 0) {
> + struct event_filter *filter = rcu_access_pointer(trigger->filter);
> +
> + list_del_rcu(&trigger->list);
> + tracepoint_synchronize_unregister();
> + if (filter)
> + free_event_filter(filter);
> + kfree(trigger->private_data);
> + kfree(trigger);
> + return ret;
> + }
[Severity: Medium]
Does unlinking the trigger here leak file->tm_ref, file->sm_ref, and
trace_buffered_event_ref at this commit?
At this point in the series, trace_event_trigger_enable_disable() and
__ftrace_event_enable_disable() do not yet roll back those counts or the
mode flags on registration failure. With the trigger removed, later
eprobe or trigger enables hit atomic_inc_return(&file->tm_ref) > 1 and
return 0 without registering the target event.
If the target event is later enabled directly and the instance is removed,
event_trace_del_tracer() sees empty file->triggers with sm_ref non-zero,
skips TRACE_REG_UNREGISTER, and frees trace_event_file while it is still
registered on the tracepoint, causing a use-after-free.
Although commit "tracing: Roll back soft-mode and trigger-mode refs on
register failure" fixes the leak later in the series, this breaks
bisectability and creates a stable-backport hazard because this commit
carries Cc: stable@vger.kernel.org independently.
The Expected output in the commit message (tp=0) is also inaccurate at
this commit because event_enable_read() appends "*" while sm_ref != 0.
To keep this commit self-contained, either call
trace_event_trigger_enable_disable(file, 0) in this error path and remove
it in commit "tracing: Roll back soft-mode and trigger-mode refs on
register failure", or fold this change into that commit.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261206115150.61594-1-mhiramat@kernel.org?part=2
next prev parent reply other threads:[~2026-12-06 12:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-06 12:22 [PATCH 0/3] tracing: Roll back event flags and soft/trigger-mode refs on register failure Masami Hiramatsu (Google)
2026-12-06 12:22 ` [PATCH 1/3] tracing: Clear RECORDED_CMD and RECORDED_TGID flags " Masami Hiramatsu (Google)
2026-12-06 12:22 ` [PATCH 2/3] tracing/eprobe: Handle trace_event_trigger_enable_disable() failure in enable_eprobe() Masami Hiramatsu (Google)
2026-12-06 12:40 ` sashiko-bot [this message]
2026-12-06 12:22 ` [PATCH 3/3] tracing: Roll back soft-mode and trigger-mode refs on register failure Masami Hiramatsu (Google)
2026-12-06 12:40 ` 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-252418@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mhiramat@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