qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: Alexander Bulekov <alxndr@bu.edu>, qemu-devel@nongnu.org
Cc: "Laurent Vivier" <lvivier@redhat.com>,
	"Thomas Huth" <thuth@redhat.com>,
	darren.kenny@oracle.com, "Bandan Das" <bsd@redhat.com>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: Re: [PATCH] fuzz: check machine, before PC-specific code
Date: Mon, 15 Mar 2021 00:31:40 +0100	[thread overview]
Message-ID: <205d92e8-3a4d-ba81-ed84-c37ceec11b27@amsat.org> (raw)
In-Reply-To: <20210314231312.q7oykvk7ijoqj6oj@mozz.bu.edu>

On 3/15/21 12:13 AM, Alexander Bulekov wrote:
> On 210314 1910, Alexander Bulekov wrote:
>> We enumerate PCI devices on PC machines, but this breaks the fuzzer for
>> non-PC machines and architectures. Add checks to avoid this.
>>
>> Reported-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> Signed-off-by: Alexander Bulekov <alxndr@bu.edu>
>> ---
>>  tests/qtest/fuzz/generic_fuzz.c | 11 ++++++++---
>>  1 file changed, 8 insertions(+), 3 deletions(-)
>>
>> diff --git a/tests/qtest/fuzz/generic_fuzz.c b/tests/qtest/fuzz/generic_fuzz.c
>> index ee8c17a04c..d2b74028fe 100644
>> --- a/tests/qtest/fuzz/generic_fuzz.c
>> +++ b/tests/qtest/fuzz/generic_fuzz.c
>> @@ -784,6 +784,7 @@ static void generic_pre_fuzz(QTestState *s)
>>      MemoryRegion *mr;
>>      QPCIBus *pcibus;
>>      char **result;
>> +    const char* machine_type;
>>  
>>      if (!getenv("QEMU_FUZZ_OBJECTS")) {
>>          usage();
>> @@ -827,9 +828,13 @@ static void generic_pre_fuzz(QTestState *s)
>>          exit(1);
>>      }
>>  
>> -    pcibus = qpci_new_pc(s, NULL);
>> -    g_ptr_array_foreach(fuzzable_pci_devices, pci_enum, pcibus);
>> -    qpci_free_pc(pcibus);
>> +    machine_type = object_get_typename(qdev_get_machine());
>> +    if(fuzzable_pci_devices->len && strstr(machine_type, "pc") == machine_type)
>                                   Should at least be "pc-" --^
> Maybe there's a more cannonical way to do this..

This doesn't scale with tests/qtest/libqos/pci-spapr.h :(

Maybe use the QOSOps structures?

> -Alex
> 
>> +    {
>> +        pcibus = qpci_new_pc(s, NULL);
>> +        g_ptr_array_foreach(fuzzable_pci_devices, pci_enum, pcibus);
>> +        qpci_free_pc(pcibus);
>> +    }
>>  
>>      counter_shm_init();
>>  }
>> -- 
>> 2.27.0
>>
> 


  reply	other threads:[~2021-03-14 23:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-14 23:10 [PATCH] fuzz: check machine, before PC-specific code Alexander Bulekov
2021-03-14 23:13 ` Alexander Bulekov
2021-03-14 23:31   ` Philippe Mathieu-Daudé [this message]
2021-03-15  1:53     ` Alexander Bulekov
2021-03-14 23:15 ` 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=205d92e8-3a4d-ba81-ed84-c37ceec11b27@amsat.org \
    --to=f4bug@amsat.org \
    --cc=alxndr@bu.edu \
    --cc=bsd@redhat.com \
    --cc=darren.kenny@oracle.com \
    --cc=lvivier@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=thuth@redhat.com \
    /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).