Linux Trace Kernel
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Li Qiang <liqiang01@kylinos.cn>
Cc: mhiramat@kernel.org, linux-trace-kernel@vger.kernel.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH 4/4] tracing/inject: Prevent overflow growing string fields
Date: Wed, 22 Jul 2026 15:51:39 -0400	[thread overview]
Message-ID: <20260722155139.1449664a@gandalf.local.home> (raw)
In-Reply-To: <20260722061040.112747-5-liqiang01@kylinos.cn>

On Wed, 22 Jul 2026 14:10:40 +0800
Li Qiang <liqiang01@kylinos.cn> wrote:

> parse_entry() appends dynamic string data by adding its length to the
> current entry size. An oversized input can overflow this signed addition,
> cause krealloc() to receive too small a length, and then write beyond it.
> 
> Reject a string length that cannot be added to entry_size before growing
> the allocation.
> 
> Fixes: 6c3edaf9fd6a ("tracing: Introduce trace event injection")
> Cc: stable@vger.kernel.org
> Signed-off-by: Li Qiang <liqiang01@kylinos.cn>
> ---
>  kernel/trace/trace_events_inject.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/kernel/trace/trace_events_inject.c b/kernel/trace/trace_events_inject.c
> index b8b141c00d5c..5c551def44f6 100644
> --- a/kernel/trace/trace_events_inject.c
> +++ b/kernel/trace/trace_events_inject.c
> @@ -243,6 +243,9 @@ static int parse_entry(char *str, struct trace_event_call *call, void **pentry)
>  				int str_loc = entry_size & 0xffff;
>  				u32 *str_item;
>  
> +				if (str_len > INT_MAX - entry_size)
> +					return -E2BIG;

This is just wrong in so many ways that it shows that you don't understand
the code.

-- Steve

> +
>  				entry_size += str_len;
>  				*pentry = krealloc(entry, entry_size, GFP_KERNEL);
>  				if (!*pentry) {


      reply	other threads:[~2026-07-22 19:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-22  6:10 [PATCH 0/4] tracing: fix histogram and injection buffer overflows Li Qiang
2026-07-22  6:10 ` [PATCH 1/4] tracing/hist: Prevent overflow in histogram expression strings Li Qiang
2026-07-22 16:32   ` Steven Rostedt
2026-07-22  6:10 ` [PATCH 2/4] tracing/user_events: Validate explicit struct field sizes Li Qiang
2026-07-22 16:33   ` Steven Rostedt
2026-07-22 17:27     ` Beau Belgrave
2026-07-22  6:10 ` [PATCH 3/4] tracing/inject: Validate entry allocation size Li Qiang
2026-07-22 19:45   ` Steven Rostedt
2026-07-22  6:10 ` [PATCH 4/4] tracing/inject: Prevent overflow growing string fields Li Qiang
2026-07-22 19:51   ` Steven Rostedt [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=20260722155139.1449664a@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=liqiang01@kylinos.cn \
    --cc=mhiramat@kernel.org \
    --cc=stable@vger.kernel.org \
    /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