All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Max Filippov <jcmvbkbc@gmail.com>
Cc: qemu-devel@nongnu.org, "Alex Bennée" <alex.bennee@linaro.org>,
	"Ilya Leoshkevich" <iii@linux.ibm.com>
Subject: Re: [PATCH] tests/tcg: fix buffer overflow in multiarch/linux/linux-sigrtminmax
Date: Thu, 09 Jul 2026 10:56:09 +0200	[thread overview]
Message-ID: <875x2oh786.fsf@pond.sub.org> (raw)
In-Reply-To: <20260708150541.2137546-1-jcmvbkbc@gmail.com> (Max Filippov's message of "Wed, 8 Jul 2026 08:05:41 -0700")

Max Filippov <jcmvbkbc@gmail.com> writes:

> Fix new_argv allocation size to be `(argc + 2) * sizeof(char *)` bytes,
> which matches the way it's used to store `argc + 2` pointers.
>
> This fixes the test for me, which otherwise fails on xtensa with the
> following message
>
>   linux-sigrtminmax.c: 59: main: Assertion `execve(new_argv[0], new_argv, environ) == 0' failed.'.
>
> Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
> ---
>  tests/tcg/multiarch/linux/linux-sigrtminmax.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tests/tcg/multiarch/linux/linux-sigrtminmax.c b/tests/tcg/multiarch/linux/linux-sigrtminmax.c
> index a7059aacd9cb..b5ea65f3d393 100644
> --- a/tests/tcg/multiarch/linux/linux-sigrtminmax.c
> +++ b/tests/tcg/multiarch/linux/linux-sigrtminmax.c
> @@ -39,7 +39,7 @@ int main(int argc, char **argv)
>      assert(qemu);
>  
>      if (!getenv("QEMU_RTSIG_MAP")) {
> -        char **new_argv = malloc((argc + 2) + sizeof(char *));
> +        char **new_argv = malloc((argc + 2) * sizeof(char *));

If you can switch to glib's malloc, then g_new(argc + 2, sizeof(char *))
is better.  Yes, @argc can't become big enough for the multiplication to
overflow, but g_new() removes the need for reasoning.

>          int tsig1, hsig1, count1, tsig2, hsig2, count2;
>          char rt_sigmap[64];



  parent reply	other threads:[~2026-07-09  8:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-08 15:05 [PATCH] tests/tcg: fix buffer overflow in multiarch/linux/linux-sigrtminmax Max Filippov
2026-07-08 15:40 ` Alex Bennée
2026-07-08 20:02 ` Richard Henderson
2026-07-08 20:45 ` Philippe Mathieu-Daudé
2026-07-09  8:37 ` Ilya Leoshkevich
2026-07-09  8:56 ` Markus Armbruster [this message]
2026-07-09  8:58   ` Daniel P. Berrangé
2026-07-09  9:09   ` Alex Bennée

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=875x2oh786.fsf@pond.sub.org \
    --to=armbru@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=iii@linux.ibm.com \
    --cc=jcmvbkbc@gmail.com \
    --cc=qemu-devel@nongnu.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.