All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Markus Armbruster <armbru@redhat.com>
Cc: Max Filippov <jcmvbkbc@gmail.com>,
	 qemu-devel@nongnu.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:09:46 +0100	[thread overview]
Message-ID: <877bn4ttph.fsf@draig.linaro.org> (raw)
In-Reply-To: <875x2oh786.fsf@pond.sub.org> (Markus Armbruster's message of "Thu, 09 Jul 2026 10:56:09 +0200")

Markus Armbruster <armbru@redhat.com> writes:

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

Not for TCG test cases - we are limited to plain old glibc.

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

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro


      parent reply	other threads:[~2026-07-09  9:10 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
2026-07-09  8:58   ` Daniel P. Berrangé
2026-07-09  9:09   ` Alex Bennée [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=877bn4ttph.fsf@draig.linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=armbru@redhat.com \
    --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.