All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Fernando Fernandez Mancera <ffmancera@riseup.net>
Cc: linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH] tracing/probes: fix traceprobe out-of-bounds argument allocation
Date: Sun, 25 Aug 2024 16:41:32 +0900	[thread overview]
Message-ID: <20240825164132.024faee7897e0ac126d8c58e@kernel.org> (raw)
In-Reply-To: <20240813172546.3151-1-ffmancera@riseup.net>

Hi,

On Tue, 13 Aug 2024 13:25:40 -0400
Fernando Fernandez Mancera <ffmancera@riseup.net> wrote:

> When initializing trace_probes::nr_args, make sure the maximum number of
> probe arguments is honored. Oherwise, we can hit a NULL pointer
> dereferences in multiple situations like on traceprobe_set_print_fmt().
> 
> Link: https://bugzilla.redhat.com/2303876

Sorry for replying later. I'm not sure why but I did not found this in my mbox...

Anyway, trace_probe_init() should return -E2BIG in this case because
it is actuall wrong value.

Can you update your patch?

Thank you,


> 
> Fixes: 035ba76014c0 ("tracing/probes: cleanup: Set trace_probe::nr_args at trace_probe_init")
> Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
> ---
>  kernel/trace/trace_probe.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
> index 39877c80d6cb..f577b5e71026 100644
> --- a/kernel/trace/trace_probe.c
> +++ b/kernel/trace/trace_probe.c
> @@ -2043,10 +2043,14 @@ int trace_probe_init(struct trace_probe *tp, const char *event,
>  		goto error;
>  	}
>  
> -	tp->nr_args = nargs;
> +	if (nargs > MAX_TRACE_ARGS)
> +		tp->nr_args = MAX_TRACE_ARGS;
> +	else
> +		tp->nr_args = nargs;
> +
>  	/* Make sure pointers in args[] are NULL */
>  	if (nargs)
> -		memset(tp->args, 0, sizeof(tp->args[0]) * nargs);
> +		memset(tp->args, 0, sizeof(tp->args[0]) * tp->nr_args);
>  
>  	return 0;
>  


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

  reply	other threads:[~2024-08-25  7:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-13 17:25 [PATCH] tracing/probes: fix traceprobe out-of-bounds argument allocation Fernando Fernandez Mancera
2024-08-25  7:41 ` Masami Hiramatsu [this message]
2024-08-25 17:06   ` Fernando F. Mancera
2024-08-25 23:56     ` Masami Hiramatsu
2024-08-26 14:58       ` Fernando F. Mancera
2024-09-04 22:19       ` Fernando F. Mancera
2024-10-22  5:40         ` Masami Hiramatsu
2024-10-22 13:47           ` Masami Hiramatsu
2024-10-23  8:48           ` Fernando F. Mancera

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=20240825164132.024faee7897e0ac126d8c58e@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=ffmancera@riseup.net \
    --cc=linux-trace-kernel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.