qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] fuzz: check machine, before PC-specific code


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH] fuzz: check machine, before PC-specific code
Date: Mon, 15 Mar 2021 00:31:40 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0

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 via email to

[Prev in Thread] Current Thread [Next in Thread]