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)
+ {
+ 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
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.. -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 >
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 >> >
On 210315 0031, Philippe Mathieu-Daudé wrote: > 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 :( True - though the existing code wouldn't work for that anyway. > > 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 > >> > >
Patchew URL: https://patchew.org/QEMU/20210314231015.29166-1-alxndr@bu.edu/ Hi, This series seems to have some coding style problems. See output below for more information: Type: series Message-id: 20210314231015.29166-1-alxndr@bu.edu Subject: [PATCH] fuzz: check machine, before PC-specific code === TEST SCRIPT BEGIN === #!/bin/bash git rev-parse base > /dev/null || exit 0 git config --local diff.renamelimit 0 git config --local diff.renames True git config --local diff.algorithm histogram ./scripts/checkpatch.pl --mailback base.. === TEST SCRIPT END === Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384 From https://github.com/patchew-project/qemu * [new tag] patchew/20210314231015.29166-1-alxndr@bu.edu -> patchew/20210314231015.29166-1-alxndr@bu.edu Switched to a new branch 'test' bb8e08d fuzz: check machine, before PC-specific code === OUTPUT BEGIN === ERROR: "foo* bar" should be "foo *bar" #25: FILE: tests/qtest/fuzz/generic_fuzz.c:787: + const char* machine_type; ERROR: space required before the open parenthesis '(' #37: FILE: tests/qtest/fuzz/generic_fuzz.c:832: + if(fuzzable_pci_devices->len && strstr(machine_type, "pc") == machine_type) total: 2 errors, 0 warnings, 23 lines checked Commit bb8e08d89398 (fuzz: check machine, before PC-specific code) has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS. === OUTPUT END === Test command exited with code: 1 The full log is available at http://patchew.org/logs/20210314231015.29166-1-alxndr@bu.edu/testing.checkpatch/?type=message. --- Email generated automatically by Patchew [https://patchew.org/]. Please send your feedback to patchew-devel@redhat.com
© 2016 - 2024 Red Hat, Inc.