qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Liam Merwick <liam.merwick@oracle.com>
To: Max Reitz <mreitz@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v3 6/8] block: dump_qlist() may dereference a Null pointer
Date: Fri, 19 Oct 2018 21:34:56 +0100	[thread overview]
Message-ID: <07eb9a63-0247-ba8d-6528-d7e15293b48e@oracle.com> (raw)
In-Reply-To: <a4732da2-c0d2-c6d9-fac4-1969758b1ff9@redhat.com>



On 12/10/18 16:22, Max Reitz wrote:
> On 31.08.18 20:16, Liam Merwick wrote:
>> A NULL 'list' passed into function dump_qlist() isn't correctly
>> validated and can be passed to qlist_first() where it is dereferenced.
>>
>> Given that dump_qlist() is static, and callers already do the right
>> thing, just add an assert to catch future potential bugs.
>>
>> Signed-off-by: Liam Merwick <Liam.Merwick@oracle.com>
>> Reviewed-by: Eric Blake <eblake@redhat.com>
>> ---
>>   block/qapi.c | 2 ++
>>   1 file changed, 2 insertions(+)
> 
> I don't disagree, but I don't see why the program just wouldn't crash if
> someone passed a NULL pointer.  And I don't quite see why anyone would
> pass a NULL pointer.
> 
> Of course it's reasonable to just add an assert() to reinforce the
> contract; but we have so many functions that just take a pointer that
> they assume to be non-NULL and then immediately dereference it.  Nearly
> every blk_* function takes a BlockBackend that is always assumed to be
> non-NULL, for instance, and I don't really want to put assert()s into
> all of them.  Or another example: dump_qobject() and dump_qdict() do
> exactly the same -- if we added an assertion in dump_qlist(), we would
> actually have to add the very same assertions there, too.
> 
> So I don't really object this patch (because it's not wrong), but I
> don't think it's very useful.


I agree with all the above - however I kept the patch in the series 
given it was helping reduce the static analysis noise (hopefully making 
it easier to spot real issues)

Regards,
Liam


> 
> Max
> 
>> diff --git a/block/qapi.c b/block/qapi.c
>> index c66f949db839..e81be604217c 100644
>> --- a/block/qapi.c
>> +++ b/block/qapi.c
>> @@ -740,6 +740,8 @@ static void dump_qlist(fprintf_function func_fprintf, void *f, int indentation,
>>       const QListEntry *entry;
>>       int i = 0;
>>   
>> +    assert(list);
>> +
>>       for (entry = qlist_first(list); entry; entry = qlist_next(entry), i++) {
>>           QType type = qobject_type(entry->value);
>>           bool composite = (type == QTYPE_QDICT || type == QTYPE_QLIST);
>>
> 
> 

  reply	other threads:[~2018-10-19 20:34 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-31 18:16 [Qemu-devel] [PATCH v3 0/8] off-by-one and NULL pointer accesses detected by static analysis Liam Merwick
2018-08-31 18:16 ` [Qemu-devel] [PATCH v3 1/8] configure: Provide option to explicitly disable AVX2 Liam Merwick
2018-08-31 18:16 ` [Qemu-devel] [PATCH v3 2/8] job: Fix off-by-one assert checks for JobSTT and JobVerbTable Liam Merwick
2018-10-09 19:09   ` John Snow
2018-08-31 18:16 ` [Qemu-devel] [PATCH v3 3/8] block: Null pointer dereference in blk_root_get_parent_desc() Liam Merwick
2018-10-12 14:48   ` Max Reitz
2018-10-19 20:31     ` Liam Merwick
2018-08-31 18:16 ` [Qemu-devel] [PATCH v3 4/8] qemu-img: potential Null pointer deref in img_commit() Liam Merwick
2018-10-09 19:23   ` John Snow
2018-10-12 14:51   ` Max Reitz
2018-10-19 20:32     ` Liam Merwick
2018-08-31 18:16 ` [Qemu-devel] [PATCH v3 5/8] block: Fix potential Null pointer dereferences in vvfat.c Liam Merwick
2018-10-12 15:14   ` Max Reitz
2018-10-19 20:31     ` Liam Merwick
2018-08-31 18:16 ` [Qemu-devel] [PATCH v3 6/8] block: dump_qlist() may dereference a Null pointer Liam Merwick
2018-10-12 15:22   ` Max Reitz
2018-10-19 20:34     ` Liam Merwick [this message]
2018-08-31 18:16 ` [Qemu-devel] [PATCH v3 7/8] io: potential unnecessary check in qio_channel_command_new_spawn() Liam Merwick
2018-08-31 18:16 ` [Qemu-devel] [PATCH v3 8/8] qcow2: Read outside array bounds in qcow2_pre_write_overlap_check() Liam Merwick
2018-10-12 15:24   ` Max Reitz
2018-10-09 16:45 ` [Qemu-devel] [PATCH v3 0/8] off-by-one and NULL pointer accesses detected by static analysis Markus Armbruster

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=07eb9a63-0247-ba8d-6528-d7e15293b48e@oracle.com \
    --to=liam.merwick@oracle.com \
    --cc=mreitz@redhat.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 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).