Linux Trace Kernel
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Cc: linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH 11/12] tracing/probes: Validate command prefix in kprobe, uprobe, and eprobe
Date: Mon, 09 Nov 2026 00:47:27 +0000	[thread overview]
Message-ID: <sashiko-outbox-204257@kernel.org> (raw)
In-Reply-To: <179418418328.227715.10680131052179044845.stgit@devnote2>

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) <mhiramat@kernel.org>

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.

> 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?

kernel/trace/trace_uprobe.c:__trace_uprobe_create() {
	...
	if (!event) {
		char *tail;
		...
		tail = kstrdup(kbasename(filename), GFP_KERNEL);
		if (!tail)
			return -ENOMEM;
		...
		buf = kmalloc(MAX_EVENT_NAME_LEN, GFP_KERNEL);
		if (!buf)
			return -ENOMEM;
		...
		kfree(tail);
	}
	...
}

When event is NULL and allocating buf fails, __trace_uprobe_create() returns
-ENOMEM without freeing tail (which is not declared with __free(kfree)).

[1] https://sashiko.dev/#/bug/linux-160fa01f-1d70-4f17-984f-1bbf039dd3df

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/179418408457.227715.1485179201014819821.stgit@devnote2?part=11

  reply	other threads:[~2026-11-09  0:47 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-09  0:28 [PATCH 00/12] tracing/probes: Fix various bugs in dynamic probe events Masami Hiramatsu (Google)
2026-11-09  0:28 ` [PATCH 01/12] tracing/probes: Check enabled and busy state before unlinking sibling probes Masami Hiramatsu (Google)
2026-11-09  0:28 ` [PATCH 02/12] tracing/probes: Enable newly appended probe when target event is enabled Masami Hiramatsu (Google)
2026-11-09  0:28 ` [PATCH 03/12] tracing/probes: Fix BTF bitfield parsing and out-of-bounds buffer write Masami Hiramatsu (Google)
2026-11-09  0:45   ` sashiko-bot
2026-11-09  0:28 ` [PATCH 04/12] tracing/probes: Fix missing BTF kind checks in char pointer/array helpers Masami Hiramatsu (Google)
2026-11-09  0:28 ` [PATCH 05/12] tracing/eprobe: Fix 1-byte signed field fetch in get_event_field() Masami Hiramatsu (Google)
2026-11-09  0:28 ` [PATCH 06/12] tracing/eprobe: Disallow attaching eprobes to fprobe events Masami Hiramatsu (Google)
2026-11-09  0:29 ` [PATCH 07/12] tracing/probes: Fix user-space dereference string array store type Masami Hiramatsu (Google)
2026-11-09  0:29 ` [PATCH 08/12] tracing/probes: Reject array count on non-dereference string sources Masami Hiramatsu (Google)
2026-11-09  0:41   ` sashiko-bot
2026-11-09  0:29 ` [PATCH 09/12] tracing/probes: Allow symstr type for function entry arguments in return probes Masami Hiramatsu (Google)
2026-11-09  0:29 ` [PATCH 10/12] tracing/probes: Reject empty fetch expression for %pd and %pD Masami Hiramatsu (Google)
2026-11-09  0:29 ` [PATCH 11/12] tracing/probes: Validate command prefix in kprobe, uprobe, and eprobe Masami Hiramatsu (Google)
2026-11-09  0:47   ` sashiko-bot [this message]
2026-11-09  0:29 ` [PATCH 12/12] tracing/probes: Propagate error codes in eprobe and fprobe creation Masami Hiramatsu (Google)
2026-11-09  0:46   ` 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-204257@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