aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/qtest/fuzz/fork_fuzz.c41
-rw-r--r--tests/qtest/fuzz/fork_fuzz.h23
-rw-r--r--tests/qtest/fuzz/fork_fuzz.ld56
-rw-r--r--tests/qtest/fuzz/fuzz.c6
-rw-r--r--tests/qtest/fuzz/fuzz.h2
-rw-r--r--tests/qtest/fuzz/generic_fuzz.c119
-rw-r--r--tests/qtest/fuzz/i440fx_fuzz.c27
-rw-r--r--tests/qtest/fuzz/meson.build6
-rw-r--r--tests/qtest/fuzz/virtio_blk_fuzz.c51
-rw-r--r--tests/qtest/fuzz/virtio_net_fuzz.c54
-rw-r--r--tests/qtest/fuzz/virtio_scsi_fuzz.c51
11 files changed, 57 insertions, 379 deletions
diff --git a/tests/qtest/fuzz/fork_fuzz.c b/tests/qtest/fuzz/fork_fuzz.c
deleted file mode 100644
index 6ffb2a7..0000000
--- a/tests/qtest/fuzz/fork_fuzz.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Fork-based fuzzing helpers
- *
- * Copyright Red Hat Inc., 2019
- *
- * Authors:
- * Alexander Bulekov <alxndr@bu.edu>
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- *
- */
-
-#include "qemu/osdep.h"
-#include "fork_fuzz.h"
-
-
-void counter_shm_init(void)
-{
- /* Copy what's in the counter region to a temporary buffer.. */
- void *copy = malloc(&__FUZZ_COUNTERS_END - &__FUZZ_COUNTERS_START);
- memcpy(copy,
- &__FUZZ_COUNTERS_START,
- &__FUZZ_COUNTERS_END - &__FUZZ_COUNTERS_START);
-
- /* Map a shared region over the counter region */
- if (mmap(&__FUZZ_COUNTERS_START,
- &__FUZZ_COUNTERS_END - &__FUZZ_COUNTERS_START,
- PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED | MAP_ANONYMOUS,
- 0, 0) == MAP_FAILED) {
- perror("Error: ");
- exit(1);
- }
-
- /* Copy the original data back to the counter-region */
- memcpy(&__FUZZ_COUNTERS_START, copy,
- &__FUZZ_COUNTERS_END - &__FUZZ_COUNTERS_START);
- free(copy);
-}
-
-
diff --git a/tests/qtest/fuzz/fork_fuzz.h b/tests/qtest/fuzz/fork_fuzz.h
deleted file mode 100644
index 9ecb8b5..0000000
--- a/tests/qtest/fuzz/fork_fuzz.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Fork-based fuzzing helpers
- *
- * Copyright Red Hat Inc., 2019
- *
- * Authors:
- * Alexander Bulekov <alxndr@bu.edu>
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- *
- */
-
-#ifndef FORK_FUZZ_H
-#define FORK_FUZZ_H
-
-extern uint8_t __FUZZ_COUNTERS_START;
-extern uint8_t __FUZZ_COUNTERS_END;
-
-void counter_shm_init(void);
-
-#endif
-
diff --git a/tests/qtest/fuzz/fork_fuzz.ld b/tests/qtest/fuzz/fork_fuzz.ld
deleted file mode 100644
index cfb88b7..0000000
--- a/tests/qtest/fuzz/fork_fuzz.ld
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * We adjust linker script modification to place all of the stuff that needs to
- * persist across fuzzing runs into a contiguous section of memory. Then, it is
- * easy to re-map the counter-related memory as shared.
- */
-
-SECTIONS
-{
- .data.fuzz_start : ALIGN(4K)
- {
- __FUZZ_COUNTERS_START = .;
- __start___sancov_cntrs = .;
- *(_*sancov_cntrs);
- __stop___sancov_cntrs = .;
-
- /* Lowest stack counter */
- *(__sancov_lowest_stack);
- }
-}
-INSERT AFTER .data;
-
-SECTIONS
-{
- .data.fuzz_ordered :
- {
- /*
- * Coverage counters. They're not necessary for fuzzing, but are useful
- * for analyzing the fuzzing performance
- */
- __start___llvm_prf_cnts = .;
- *(*llvm_prf_cnts);
- __stop___llvm_prf_cnts = .;
-
- /* Internal Libfuzzer TracePC object which contains the ValueProfileMap */
- FuzzerTracePC*(.bss*);
- /*
- * In case the above line fails, explicitly specify the (mangled) name of
- * the object we care about
- */
- *(.bss._ZN6fuzzer3TPCE);
- }
-}
-INSERT AFTER .data.fuzz_start;
-
-SECTIONS
-{
- .data.fuzz_end : ALIGN(4K)
- {
- __FUZZ_COUNTERS_END = .;
- }
-}
-/*
- * Don't overwrite the SECTIONS in the default linker script. Instead insert the
- * above into the default script
- */
-INSERT AFTER .data.fuzz_ordered;
diff --git a/tests/qtest/fuzz/fuzz.c b/tests/qtest/fuzz/fuzz.c
index eb75205..3bedb81 100644
--- a/tests/qtest/fuzz/fuzz.c
+++ b/tests/qtest/fuzz/fuzz.c
@@ -51,6 +51,12 @@ void flush_events(QTestState *s)
}
}
+void fuzz_reset(QTestState *s)
+{
+ qemu_system_reset(SHUTDOWN_CAUSE_GUEST_RESET);
+ main_loop_wait(true);
+}
+
static QTestState *qtest_setup(void)
{
qtest_server_set_send_handler(&qtest_client_inproc_recv, &fuzz_qts);
diff --git a/tests/qtest/fuzz/fuzz.h b/tests/qtest/fuzz/fuzz.h
index 327c1c5..21d1362 100644
--- a/tests/qtest/fuzz/fuzz.h
+++ b/tests/qtest/fuzz/fuzz.h
@@ -103,7 +103,7 @@ typedef struct FuzzTarget {
} FuzzTarget;
void flush_events(QTestState *);
-void reboot(QTestState *);
+void fuzz_reset(QTestState *);
/* Use the QTest ASCII protocol or call address_space API directly?*/
void fuzz_qtest_set_serialize(bool option);
diff --git a/tests/qtest/fuzz/generic_fuzz.c b/tests/qtest/fuzz/generic_fuzz.c
index 7326f68..c525d22 100644
--- a/tests/qtest/fuzz/generic_fuzz.c
+++ b/tests/qtest/fuzz/generic_fuzz.c
@@ -18,7 +18,6 @@
#include "tests/qtest/libqtest.h"
#include "tests/qtest/libqos/pci-pc.h"
#include "fuzz.h"
-#include "fork_fuzz.h"
#include "string.h"
#include "exec/memory.h"
#include "exec/ramblock.h"
@@ -29,6 +28,8 @@
#include "generic_fuzz_configs.h"
#include "hw/mem/sparse-mem.h"
+static void pci_enum(gpointer pcidev, gpointer bus);
+
/*
* SEPARATOR is used to separate "operations" in the fuzz input
*/
@@ -47,10 +48,10 @@ enum cmds {
OP_CLOCK_STEP,
};
-#define DEFAULT_TIMEOUT_US 100000
#define USEC_IN_SEC 1000000000
#define MAX_DMA_FILL_SIZE 0x10000
+#define MAX_TOTAL_DMA_SIZE 0x10000000
#define PCI_HOST_BRIDGE_CFG 0xcf8
#define PCI_HOST_BRIDGE_DATA 0xcfc
@@ -60,9 +61,8 @@ typedef struct {
ram_addr_t size; /* The number of bytes until the end of the I/O region */
} address_range;
-static useconds_t timeout = DEFAULT_TIMEOUT_US;
-
static bool qtest_log_enabled;
+size_t dma_bytes_written;
MemoryRegion *sparse_mem_mr;
@@ -196,6 +196,7 @@ void fuzz_dma_read_cb(size_t addr, size_t len, MemoryRegion *mr)
*/
if (dma_patterns->len == 0
|| len == 0
+ || dma_bytes_written + len > MAX_TOTAL_DMA_SIZE
|| (mr != current_machine->ram && mr != sparse_mem_mr)) {
return;
}
@@ -268,6 +269,7 @@ void fuzz_dma_read_cb(size_t addr, size_t len, MemoryRegion *mr)
fflush(stderr);
}
qtest_memwrite(qts_global, addr, buf, l);
+ dma_bytes_written += l;
}
len -= l;
buf += l;
@@ -589,30 +591,6 @@ static void op_disable_pci(QTestState *s, const unsigned char *data, size_t len)
pci_disabled = true;
}
-static void handle_timeout(int sig)
-{
- if (qtest_log_enabled) {
- fprintf(stderr, "[Timeout]\n");
- fflush(stderr);
- }
-
- /*
- * If there is a crash, libfuzzer/ASAN forks a child to run an
- * "llvm-symbolizer" process for printing out a pretty stacktrace. It
- * communicates with this child using a pipe. If we timeout+Exit, while
- * libfuzzer is still communicating with the llvm-symbolizer child, we will
- * be left with an orphan llvm-symbolizer process. Sometimes, this appears
- * to lead to a deadlock in the forkserver. Use waitpid to check if there
- * are any waitable children. If so, exit out of the signal-handler, and
- * let libfuzzer finish communicating with the child, and exit, on its own.
- */
- if (waitpid(-1, NULL, WNOHANG) == 0) {
- return;
- }
-
- _Exit(0);
-}
-
/*
* Here, we interpret random bytes from the fuzzer, as a sequence of commands.
* Some commands can be variable-width, so we use a separator, SEPARATOR, to
@@ -669,64 +647,33 @@ static void generic_fuzz(QTestState *s, const unsigned char *Data, size_t Size)
size_t cmd_len;
uint8_t op;
- if (fork() == 0) {
- struct sigaction sact;
- struct itimerval timer;
- sigset_t set;
- /*
- * Sometimes the fuzzer will find inputs that take quite a long time to
- * process. Often times, these inputs do not result in new coverage.
- * Even if these inputs might be interesting, they can slow down the
- * fuzzer, overall. Set a timeout for each command to avoid hurting
- * performance, too much
- */
- if (timeout) {
-
- sigemptyset(&sact.sa_mask);
- sact.sa_flags = SA_NODEFER;
- sact.sa_handler = handle_timeout;
- sigaction(SIGALRM, &sact, NULL);
+ op_clear_dma_patterns(s, NULL, 0);
+ pci_disabled = false;
+ dma_bytes_written = 0;
- sigemptyset(&set);
- sigaddset(&set, SIGALRM);
- pthread_sigmask(SIG_UNBLOCK, &set, NULL);
-
- memset(&timer, 0, sizeof(timer));
- timer.it_value.tv_sec = timeout / USEC_IN_SEC;
- timer.it_value.tv_usec = timeout % USEC_IN_SEC;
- }
-
- op_clear_dma_patterns(s, NULL, 0);
- pci_disabled = false;
-
- while (cmd && Size) {
- /* Reset the timeout, each time we run a new command */
- if (timeout) {
- setitimer(ITIMER_REAL, &timer, NULL);
- }
+ QPCIBus *pcibus = qpci_new_pc(s, NULL);
+ g_ptr_array_foreach(fuzzable_pci_devices, pci_enum, pcibus);
+ qpci_free_pc(pcibus);
- /* Get the length until the next command or end of input */
- nextcmd = memmem(cmd, Size, SEPARATOR, strlen(SEPARATOR));
- cmd_len = nextcmd ? nextcmd - cmd : Size;
+ while (cmd && Size) {
+ /* Get the length until the next command or end of input */
+ nextcmd = memmem(cmd, Size, SEPARATOR, strlen(SEPARATOR));
+ cmd_len = nextcmd ? nextcmd - cmd : Size;
- if (cmd_len > 0) {
- /* Interpret the first byte of the command as an opcode */
- op = *cmd % (sizeof(ops) / sizeof((ops)[0]));
- ops[op](s, cmd + 1, cmd_len - 1);
+ if (cmd_len > 0) {
+ /* Interpret the first byte of the command as an opcode */
+ op = *cmd % (sizeof(ops) / sizeof((ops)[0]));
+ ops[op](s, cmd + 1, cmd_len - 1);
- /* Run the main loop */
- flush_events(s);
- }
- /* Advance to the next command */
- cmd = nextcmd ? nextcmd + sizeof(SEPARATOR) - 1 : nextcmd;
- Size = Size - (cmd_len + sizeof(SEPARATOR) - 1);
- g_array_set_size(dma_regions, 0);
+ /* Run the main loop */
+ flush_events(s);
}
- _Exit(0);
- } else {
- flush_events(s);
- wait(0);
+ /* Advance to the next command */
+ cmd = nextcmd ? nextcmd + sizeof(SEPARATOR) - 1 : nextcmd;
+ Size = Size - (cmd_len + sizeof(SEPARATOR) - 1);
+ g_array_set_size(dma_regions, 0);
}
+ fuzz_reset(s);
}
static void usage(void)
@@ -738,8 +685,6 @@ static void usage(void)
printf("Optionally: QEMU_AVOID_DOUBLE_FETCH= "
"Try to avoid racy DMA double fetch bugs? %d by default\n",
avoid_double_fetches);
- printf("Optionally: QEMU_FUZZ_TIMEOUT= Specify a custom timeout (us). "
- "0 to disable. %d by default\n", timeout);
exit(0);
}
@@ -825,7 +770,6 @@ static void generic_pre_fuzz(QTestState *s)
{
GHashTableIter iter;
MemoryRegion *mr;
- QPCIBus *pcibus;
char **result;
GString *name_pattern;
@@ -838,9 +782,6 @@ static void generic_pre_fuzz(QTestState *s)
if (getenv("QEMU_AVOID_DOUBLE_FETCH")) {
avoid_double_fetches = 1;
}
- if (getenv("QEMU_FUZZ_TIMEOUT")) {
- timeout = g_ascii_strtoll(getenv("QEMU_FUZZ_TIMEOUT"), NULL, 0);
- }
qts_global = s;
/*
@@ -883,12 +824,6 @@ static void generic_pre_fuzz(QTestState *s)
printf("No fuzzable memory regions found...\n");
exit(1);
}
-
- pcibus = qpci_new_pc(s, NULL);
- g_ptr_array_foreach(fuzzable_pci_devices, pci_enum, pcibus);
- qpci_free_pc(pcibus);
-
- counter_shm_init();
}
/*
diff --git a/tests/qtest/fuzz/i440fx_fuzz.c b/tests/qtest/fuzz/i440fx_fuzz.c
index b17fc72..155fe01 100644
--- a/tests/qtest/fuzz/i440fx_fuzz.c
+++ b/tests/qtest/fuzz/i440fx_fuzz.c
@@ -18,7 +18,6 @@
#include "tests/qtest/libqos/pci-pc.h"
#include "fuzz.h"
#include "qos_fuzz.h"
-#include "fork_fuzz.h"
#define I440FX_PCI_HOST_BRIDGE_CFG 0xcf8
@@ -89,6 +88,7 @@ static void i440fx_fuzz_qtest(QTestState *s,
size_t Size)
{
ioport_fuzz_qtest(s, Data, Size);
+ fuzz_reset(s);
}
static void pciconfig_fuzz_qos(QTestState *s, QPCIBus *bus,
@@ -145,17 +145,6 @@ static void i440fx_fuzz_qos(QTestState *s,
pciconfig_fuzz_qos(s, bus, Data, Size);
}
-static void i440fx_fuzz_qos_fork(QTestState *s,
- const unsigned char *Data, size_t Size) {
- if (fork() == 0) {
- i440fx_fuzz_qos(s, Data, Size);
- _Exit(0);
- } else {
- flush_events(s);
- wait(NULL);
- }
-}
-
static const char *i440fx_qtest_argv = TARGET_NAME " -machine accel=qtest"
" -m 0 -display none";
static GString *i440fx_argv(FuzzTarget *t)
@@ -163,10 +152,6 @@ static GString *i440fx_argv(FuzzTarget *t)
return g_string_new(i440fx_qtest_argv);
}
-static void fork_init(void)
-{
- counter_shm_init();
-}
static void register_pci_fuzz_targets(void)
{
@@ -178,16 +163,6 @@ static void register_pci_fuzz_targets(void)
.get_init_cmdline = i440fx_argv,
.fuzz = i440fx_fuzz_qtest});
- /* Uses libqos and forks to prevent state leakage */
- fuzz_add_qos_target(&(FuzzTarget){
- .name = "i440fx-qos-fork-fuzz",
- .description = "Fuzz the i440fx using raw qtest commands and "
- "rebooting after each run",
- .pre_vm_init = &fork_init,
- .fuzz = i440fx_fuzz_qos_fork,},
- "i440FX-pcihost",
- &(QOSGraphTestOptions){}
- );
/*
* Uses libqos. Doesn't do anything to reset state. Note that if we were to
diff --git a/tests/qtest/fuzz/meson.build b/tests/qtest/fuzz/meson.build
index 189901d..4d10b47 100644
--- a/tests/qtest/fuzz/meson.build
+++ b/tests/qtest/fuzz/meson.build
@@ -2,7 +2,7 @@ if not get_option('fuzzing')
subdir_done()
endif
-specific_fuzz_ss.add(files('fuzz.c', 'fork_fuzz.c', 'qos_fuzz.c',
+specific_fuzz_ss.add(files('fuzz.c', 'qos_fuzz.c',
'qtest_wrappers.c'), qos)
# Targets
@@ -12,7 +12,7 @@ specific_fuzz_ss.add(when: 'CONFIG_VIRTIO_SCSI', if_true: files('virtio_scsi_fuz
specific_fuzz_ss.add(when: 'CONFIG_VIRTIO_BLK', if_true: files('virtio_blk_fuzz.c'))
specific_fuzz_ss.add(files('generic_fuzz.c'))
-fork_fuzz = declare_dependency(
+fuzz_ld = declare_dependency(
link_args: fuzz_exe_ldflags +
['-Wl,-wrap,qtest_inb',
'-Wl,-wrap,qtest_inw',
@@ -35,4 +35,4 @@ fork_fuzz = declare_dependency(
'-Wl,-wrap,qtest_memset']
)
-specific_fuzz_ss.add(fork_fuzz)
+specific_fuzz_ss.add(fuzz_ld)
diff --git a/tests/qtest/fuzz/virtio_blk_fuzz.c b/tests/qtest/fuzz/virtio_blk_fuzz.c
index a9fb9ec..651fd4f 100644
--- a/tests/qtest/fuzz/virtio_blk_fuzz.c
+++ b/tests/qtest/fuzz/virtio_blk_fuzz.c
@@ -19,7 +19,6 @@
#include "standard-headers/linux/virtio_pci.h"
#include "standard-headers/linux/virtio_blk.h"
#include "fuzz.h"
-#include "fork_fuzz.h"
#include "qos_fuzz.h"
#define TEST_IMAGE_SIZE (64 * 1024 * 1024)
@@ -128,48 +127,24 @@ static void virtio_blk_fuzz(QTestState *s, QVirtioBlkQueues* queues,
}
}
-static void virtio_blk_fork_fuzz(QTestState *s,
- const unsigned char *Data, size_t Size)
-{
- QVirtioBlk *blk = fuzz_qos_obj;
- static QVirtioBlkQueues *queues;
- if (!queues) {
- queues = qvirtio_blk_init(blk->vdev, 0);
- }
- if (fork() == 0) {
- virtio_blk_fuzz(s, queues, Data, Size);
- flush_events(s);
- _Exit(0);
- } else {
- flush_events(s);
- wait(NULL);
- }
-}
-
static void virtio_blk_with_flag_fuzz(QTestState *s,
const unsigned char *Data, size_t Size)
{
QVirtioBlk *blk = fuzz_qos_obj;
static QVirtioBlkQueues *queues;
- if (fork() == 0) {
- if (Size >= sizeof(uint64_t)) {
- queues = qvirtio_blk_init(blk->vdev, *(uint64_t *)Data);
- virtio_blk_fuzz(s, queues,
- Data + sizeof(uint64_t), Size - sizeof(uint64_t));
- flush_events(s);
- }
- _Exit(0);
- } else {
+ if (Size >= sizeof(uint64_t)) {
+ queues = qvirtio_blk_init(blk->vdev, *(uint64_t *)Data);
+ virtio_blk_fuzz(s, queues,
+ Data + sizeof(uint64_t), Size - sizeof(uint64_t));
flush_events(s);
- wait(NULL);
}
+ fuzz_reset(s);
}
static void virtio_blk_pre_fuzz(QTestState *s)
{
qos_init_path(s);
- counter_shm_init();
}
static void drive_destroy(void *path)
@@ -209,21 +184,9 @@ static void *virtio_blk_test_setup(GString *cmd_line, void *arg)
static void register_virtio_blk_fuzz_targets(void)
{
fuzz_add_qos_target(&(FuzzTarget){
- .name = "virtio-blk-fuzz",
- .description = "Fuzz the virtio-blk virtual queues, forking "
- "for each fuzz run",
- .pre_vm_init = &counter_shm_init,
- .pre_fuzz = &virtio_blk_pre_fuzz,
- .fuzz = virtio_blk_fork_fuzz,},
- "virtio-blk",
- &(QOSGraphTestOptions){.before = virtio_blk_test_setup}
- );
-
- fuzz_add_qos_target(&(FuzzTarget){
.name = "virtio-blk-flags-fuzz",
- .description = "Fuzz the virtio-blk virtual queues, forking "
- "for each fuzz run (also fuzzes the virtio flags)",
- .pre_vm_init = &counter_shm_init,
+ .description = "Fuzz the virtio-blk virtual queues. "
+ "Also fuzzes the virtio flags)",
.pre_fuzz = &virtio_blk_pre_fuzz,
.fuzz = virtio_blk_with_flag_fuzz,},
"virtio-blk",
diff --git a/tests/qtest/fuzz/virtio_net_fuzz.c b/tests/qtest/fuzz/virtio_net_fuzz.c
index c2c15f0..e239875 100644
--- a/tests/qtest/fuzz/virtio_net_fuzz.c
+++ b/tests/qtest/fuzz/virtio_net_fuzz.c
@@ -16,7 +16,6 @@
#include "tests/qtest/libqtest.h"
#include "tests/qtest/libqos/virtio-net.h"
#include "fuzz.h"
-#include "fork_fuzz.h"
#include "qos_fuzz.h"
@@ -115,36 +114,18 @@ static void virtio_net_fuzz_multi(QTestState *s,
}
}
-static void virtio_net_fork_fuzz(QTestState *s,
- const unsigned char *Data, size_t Size)
-{
- if (fork() == 0) {
- virtio_net_fuzz_multi(s, Data, Size, false);
- flush_events(s);
- _Exit(0);
- } else {
- flush_events(s);
- wait(NULL);
- }
-}
-static void virtio_net_fork_fuzz_check_used(QTestState *s,
+static void virtio_net_fuzz_check_used(QTestState *s,
const unsigned char *Data, size_t Size)
{
- if (fork() == 0) {
- virtio_net_fuzz_multi(s, Data, Size, true);
- flush_events(s);
- _Exit(0);
- } else {
- flush_events(s);
- wait(NULL);
- }
+ virtio_net_fuzz_multi(s, Data, Size, true);
+ flush_events(s);
+ fuzz_reset(s);
}
static void virtio_net_pre_fuzz(QTestState *s)
{
qos_init_path(s);
- counter_shm_init();
}
static void *virtio_net_test_setup_socket(GString *cmd_line, void *arg)
@@ -158,23 +139,8 @@ static void *virtio_net_test_setup_socket(GString *cmd_line, void *arg)
return arg;
}
-static void *virtio_net_test_setup_user(GString *cmd_line, void *arg)
-{
- g_string_append_printf(cmd_line, " -netdev user,id=hs0 ");
- return arg;
-}
-
static void register_virtio_net_fuzz_targets(void)
{
- fuzz_add_qos_target(&(FuzzTarget){
- .name = "virtio-net-socket",
- .description = "Fuzz the virtio-net virtual queues. Fuzz incoming "
- "traffic using the socket backend",
- .pre_fuzz = &virtio_net_pre_fuzz,
- .fuzz = virtio_net_fork_fuzz,},
- "virtio-net",
- &(QOSGraphTestOptions){.before = virtio_net_test_setup_socket}
- );
fuzz_add_qos_target(&(FuzzTarget){
.name = "virtio-net-socket-check-used",
@@ -182,20 +148,10 @@ static void register_virtio_net_fuzz_targets(void)
"descriptors to be used. Timeout may indicate improperly handled "
"input",
.pre_fuzz = &virtio_net_pre_fuzz,
- .fuzz = virtio_net_fork_fuzz_check_used,},
+ .fuzz = virtio_net_fuzz_check_used,},
"virtio-net",
&(QOSGraphTestOptions){.before = virtio_net_test_setup_socket}
);
- fuzz_add_qos_target(&(FuzzTarget){
- .name = "virtio-net-slirp",
- .description = "Fuzz the virtio-net virtual queues with the slirp "
- " backend. Warning: May result in network traffic emitted from the "
- " process. Run in an isolated network environment.",
- .pre_fuzz = &virtio_net_pre_fuzz,
- .fuzz = virtio_net_fork_fuzz,},
- "virtio-net",
- &(QOSGraphTestOptions){.before = virtio_net_test_setup_user}
- );
}
fuzz_target_init(register_virtio_net_fuzz_targets);
diff --git a/tests/qtest/fuzz/virtio_scsi_fuzz.c b/tests/qtest/fuzz/virtio_scsi_fuzz.c
index b3220ef..b6268ef 100644
--- a/tests/qtest/fuzz/virtio_scsi_fuzz.c
+++ b/tests/qtest/fuzz/virtio_scsi_fuzz.c
@@ -20,7 +20,6 @@
#include "standard-headers/linux/virtio_pci.h"
#include "standard-headers/linux/virtio_scsi.h"
#include "fuzz.h"
-#include "fork_fuzz.h"
#include "qos_fuzz.h"
#define PCI_SLOT 0x02
@@ -132,48 +131,24 @@ static void virtio_scsi_fuzz(QTestState *s, QVirtioSCSIQueues* queues,
}
}
-static void virtio_scsi_fork_fuzz(QTestState *s,
- const unsigned char *Data, size_t Size)
-{
- QVirtioSCSI *scsi = fuzz_qos_obj;
- static QVirtioSCSIQueues *queues;
- if (!queues) {
- queues = qvirtio_scsi_init(scsi->vdev, 0);
- }
- if (fork() == 0) {
- virtio_scsi_fuzz(s, queues, Data, Size);
- flush_events(s);
- _Exit(0);
- } else {
- flush_events(s);
- wait(NULL);
- }
-}
-
static void virtio_scsi_with_flag_fuzz(QTestState *s,
const unsigned char *Data, size_t Size)
{
QVirtioSCSI *scsi = fuzz_qos_obj;
static QVirtioSCSIQueues *queues;
- if (fork() == 0) {
- if (Size >= sizeof(uint64_t)) {
- queues = qvirtio_scsi_init(scsi->vdev, *(uint64_t *)Data);
- virtio_scsi_fuzz(s, queues,
- Data + sizeof(uint64_t), Size - sizeof(uint64_t));
- flush_events(s);
- }
- _Exit(0);
- } else {
+ if (Size >= sizeof(uint64_t)) {
+ queues = qvirtio_scsi_init(scsi->vdev, *(uint64_t *)Data);
+ virtio_scsi_fuzz(s, queues,
+ Data + sizeof(uint64_t), Size - sizeof(uint64_t));
flush_events(s);
- wait(NULL);
}
+ fuzz_reset(s);
}
static void virtio_scsi_pre_fuzz(QTestState *s)
{
qos_init_path(s);
- counter_shm_init();
}
static void *virtio_scsi_test_setup(GString *cmd_line, void *arg)
@@ -190,21 +165,9 @@ static void *virtio_scsi_test_setup(GString *cmd_line, void *arg)
static void register_virtio_scsi_fuzz_targets(void)
{
fuzz_add_qos_target(&(FuzzTarget){
- .name = "virtio-scsi-fuzz",
- .description = "Fuzz the virtio-scsi virtual queues, forking "
- "for each fuzz run",
- .pre_vm_init = &counter_shm_init,
- .pre_fuzz = &virtio_scsi_pre_fuzz,
- .fuzz = virtio_scsi_fork_fuzz,},
- "virtio-scsi",
- &(QOSGraphTestOptions){.before = virtio_scsi_test_setup}
- );
-
- fuzz_add_qos_target(&(FuzzTarget){
.name = "virtio-scsi-flags-fuzz",
- .description = "Fuzz the virtio-scsi virtual queues, forking "
- "for each fuzz run (also fuzzes the virtio flags)",
- .pre_vm_init = &counter_shm_init,
+ .description = "Fuzz the virtio-scsi virtual queues. "
+ "Also fuzzes the virtio flags",
.pre_fuzz = &virtio_scsi_pre_fuzz,
.fuzz = virtio_scsi_with_flag_fuzz,},
"virtio-scsi",