From: Ren Wei <enjou1224z@gmail.com>
To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Cc: rostedt@goodmis.org, mhiramat@kernel.org,
mathieu.desnoyers@efficios.com, vega@nebusec.ai,
rakukuip@gmail.com, enjou1224z@gmail.com
Subject: [PATCH 1/1] tracing/uprobes: Reject unregistering enabled trace_uprobe to prevent UAF
Date: Wed, 29 Jul 2026 23:19:59 +0800 [thread overview]
Message-ID: <4ac73dd24e3123cdcdb3e938dc7bd74be66a3f77.1785227724.git.rakukuip@gmail.com> (raw)
In-Reply-To: <cover.1785227724.git.rakukuip@gmail.com>
From: Luxiao Xu <rakukuip@gmail.com>
When unregistering a trace_uprobe, if the probe has a sibling
(i.e. trace_probe_has_sibling() is true), unregister_trace_uprobe()
jumps directly to unreg, bypassing event busy checks and
unregister_uprobe_event().
However, if the trace_uprobe is currently enabled, freeing it without
disabling it allows uprobe callbacks (such as uprobe_dispatcher()) to
continue accessing the freed trace_uprobe structure. This leads to a
use-after-free (UAF) condition.
Fix this by checking trace_probe_is_enabled() at the entry of
unregister_trace_uprobe(). If the probe is enabled, return -EBUSY
immediately to prevent unregistering and freeing an active probe.
Fixes: 41af3cf587f4 ("tracing/uprobe: Add multi-probe per uprobe event support")
Cc: <stable@vger.kernel.org>
Reported-by: Vega <vega@nebusec.ai>
Assisted-by: Codex:gpt-5.4
Signed-off-by: Luxiao Xu <rakukuip@gmail.com>
Signed-off-by: Ren Wei <enjou1224z@gmail.com>
---
kernel/trace/trace_uprobe.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index c274346853d1..a514a82c4ae0 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -396,6 +396,9 @@ static int unregister_trace_uprobe(struct trace_uprobe *tu)
{
int ret;
+ if (trace_probe_is_enabled(&tu->tp))
+ return -EBUSY;
+
if (trace_probe_has_sibling(&tu->tp))
goto unreg;
--
2.43.0
prev parent reply other threads:[~2026-07-29 15:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-29 15:19 [PATCH 0/1] kernel/trace: Fix use-after-free in unregister_trace_uprobe() Ren Wei
2026-07-29 15:19 ` Ren Wei [this message]
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=4ac73dd24e3123cdcdb3e938dc7bd74be66a3f77.1785227724.git.rakukuip@gmail.com \
--to=enjou1224z@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=rakukuip@gmail.com \
--cc=rostedt@goodmis.org \
--cc=vega@nebusec.ai \
/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
all inboxes | Powered by JetHome®