Re: [PATCH 11/12] tracing/probes: Validate command prefix in kprobe, uprobe, and eprobe

From
Masami Hiramatsu (Google) <mhiramat@kernel.org>
Date
2026-11-12 01:24:23
Reply to
sashiko-bot@kernel.org, 2026-11-09
On Mon, 09 Nov 2026 00:47:27 +0000, sashiko-bot@kernel.org [off-list ref] wrote:
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Medium] tracing/uprobes: memory leak in __trace_uprobe_create() [1]
--

commit d4f1d831d5c45144f78113e0b3ef37e7d6dc9844
Author: Masami Hiramatsu (Google) [off-list ref]

tracing/probes: Validate command prefix in kprobe, uprobe, and eprobe

This commit validates trailing characters after the command prefix in
kprobe, uprobe, and eprobe creation, rejecting invalid characters with
BAD_MAXACT instead of silently ignoring them.
quoted
diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index 14ac52aebe346..3745eb07bd14e 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -616,9 +616,6 @@ static int __trace_uprobe_create(int argc, const char **argv)
 		return -E2BIG;
 	}
 
-	if (argv[0][1] == ':')
-		event = &argv[0][2];
-
 	if (!strchr(argv[1], '/'))
 		return -ECANCELED;
 
@@ -631,6 +628,15 @@ static int __trace_uprobe_create(int argc, const char **argv)
 	if (!arg || !isdigit(arg[1]))
 		return -ECANCELED;
 
+	if (argv[0][1] != '\0') {
+		if (argv[0][1] != ':') {
+			trace_probe_log_set_index(0);
+			trace_probe_log_err(1, BAD_MAXACT);
+			return -EINVAL;
+		}
+		event = &argv[0][2];
+	}
[Severity: Medium]
This problem wasn't introduced by this patch, but can __trace_uprobe_create()
leak tail [1] when generating a default event name?
Ah, indeed. I think we should add __free(kfree) to tail.
Let me add another fix for this issue.

Thanks,

-- 
Masami Hiramatsu (Google) [off-list ref]
Thread (20 messages) 20 messages, 2 authors, last reply 6d ago
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help