qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: "Alex Bennée" <alex.bennee@linaro.org>, qemu-devel@nongnu.org
Subject: Re: [PATCH v1 1/7] elf-ops: bail out if we have no function symbols
Date: Fri, 27 Mar 2020 12:10:56 +0100	[thread overview]
Message-ID: <e988e64d-3056-feec-099e-9bad9b40626d@redhat.com> (raw)
In-Reply-To: <0aa311c7-ae89-6dc2-d1ef-514a75bd0c6e@redhat.com>

On 3/27/20 11:53 AM, Philippe Mathieu-Daudé wrote:
> On 3/27/20 10:49 AM, Alex Bennée wrote:
>> It's perfectly possible to have no function symbols in your elf file
>> and if we do the undefined behaviour sanitizer rightly complains about
>> us passing NULL to qsort. Check nsyms before we go ahead.
>>
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> ---
>>   include/hw/elf_ops.h | 7 ++++++-
>>   1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/include/hw/elf_ops.h b/include/hw/elf_ops.h
>> index a1411bfcab6..b5d4074d1e3 100644
>> --- a/include/hw/elf_ops.h
>> +++ b/include/hw/elf_ops.h
>> @@ -170,8 +170,13 @@ static int glue(load_symbols, SZ)(struct elfhdr 
>> *ehdr, int fd, int must_swab,
>>           }
>>           i++;
>>       }
>> -    syms = g_realloc(syms, nsyms * sizeof(*syms));

Something was bugging me why looking at this line, now I remembered: 
another patch from 2 years ago :)

https://www.mail-archive.com/qemu-devel@nongnu.org/msg528713.html

Is this the same emitted warning? It seems.

   $ qemu-system-xtensa -M kc705 -m 128M -semihosting -nographic 
-monitor null -kernel Image.elf
   include/hw/elf_ops.h:179:5: runtime error: null pointer passed as 
argument 1, which is declared to never be null

If so, can you add it to the commit description?

Thanks!

>> +    /* check we have symbols left */
>> +    if (nsyms == 0) {
>> +        goto fail;
>> +    }
>> +
>> +    syms = g_realloc(syms, nsyms * sizeof(*syms));
>>       qsort(syms, nsyms, sizeof(*syms), glue(symcmp, SZ));
>>       for (i = 0; i < nsyms - 1; i++) {
>>           if (syms[i].st_size == 0) {
>>
> 
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>



  reply	other threads:[~2020-03-27 11:11 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-27  9:49 [PATCH for 5.0 v1 0/7] A selection of sanitiser fixes Alex Bennée
2020-03-27  9:49 ` [PATCH v1 1/7] elf-ops: bail out if we have no function symbols Alex Bennée
2020-03-27 10:53   ` Philippe Mathieu-Daudé
2020-03-27 11:10     ` Philippe Mathieu-Daudé [this message]
2020-03-27 11:45   ` Peter Maydell
2020-03-27 22:09   ` Richard Henderson
2020-03-27  9:49 ` [PATCH v1 2/7] linux-user: protect fcntl64 with an #ifdef Alex Bennée
2020-03-27 10:40   ` Laurent Vivier
2020-03-27 22:10   ` Richard Henderson
2020-03-27  9:49 ` [PATCH v1 3/7] tests/tcg: remove extraneous pasting macros Alex Bennée
2020-03-27 10:54   ` Philippe Mathieu-Daudé
2020-03-27 22:11   ` Richard Henderson
2020-03-27  9:49 ` [PATCH v1 4/7] linux-user: more debug for init_guest_space Alex Bennée
2020-03-27 10:50   ` Laurent Vivier
2020-03-27  9:49 ` [PATCH v1 5/7] fpu/softfloat: avoid undefined behaviour when normalising empty sigs Alex Bennée
2020-03-27 10:09   ` Peter Maydell
2020-03-27 22:27     ` Richard Henderson
2020-03-27 22:33       ` Peter Maydell
2020-03-27 10:13   ` Aleksandar Markovic
2020-03-27 10:31     ` Alex Bennée
2020-03-27  9:49 ` [PATCH v1 6/7] target/xtensa: add FIXME for translation memory leak Alex Bennée
2020-03-27  9:49 ` [PATCH v1 7/7] gdbstub: fix compiler complaining Alex Bennée
2020-03-27 10:56   ` Philippe Mathieu-Daudé
2020-03-27 10:53 ` [PATCH for 5.0 v1 0/7] A selection of sanitiser fixes no-reply

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=e988e64d-3056-feec-099e-9bad9b40626d@redhat.com \
    --to=philmd@redhat.com \
    --cc=alex.bennee@linaro.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).