mirror_qemu/tests/qtest/fuzz
Alexander Bulekov fc69fa216c fuzz: Disable QEMU's SIG{INT,HUP,TERM} handlers
Prior to this patch, the only way I found to terminate the fuzzer was
either to:
 1. Explicitly specify the number of fuzzer runs with the -runs= flag
 2. SIGKILL the process with "pkill -9 qemu-fuzz-*" or similar

In addition to being annoying to deal with, SIGKILLing the process skips
over any exit handlers(e.g. registered with atexit()). This is bad,
since some fuzzers might create temporary files that should ideally be
removed on exit using an exit handler. The only way to achieve a clean
exit now is to specify -runs=N , but the desired "N" is tricky to
identify prior to fuzzing.

Why doesn't the process exit with standard SIGINT,SIGHUP,SIGTERM
signals? QEMU installs its own handlers for these signals in
os-posix.c:os_setup_signal_handling, which notify the main loop that an
exit was requested. The fuzzer, however, does not run qemu_main_loop,
which performs the main_loop_should_exit() check.  This means that the
fuzzer effectively ignores these signals. As we don't really care about
cleanly stopping the disposable fuzzer "VM", this patch uninstalls
QEMU's signal handlers. Thus, we can stop the fuzzer with
SIG{INT,HUP,TERM} and the fuzzing code can optionally use atexit() to
clean up temporary files/resources.

Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
Signed-off-by: Alexander Bulekov <alxndr@bu.edu>
Message-Id: <20201014142157.46028-1-alxndr@bu.edu>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2020-10-17 10:45:53 -04:00
..
fork_fuzz.c fuzz: do not use POSIX shm for coverage bitmap 2020-07-06 07:37:02 +02:00
fork_fuzz.h fuzz: support for fork-based fuzzing. 2020-02-22 08:26:48 +00:00
fork_fuzz.ld fuzz: add mangled object name to linker script 2020-06-05 09:54:48 +01:00
fuzz.c fuzz: Disable QEMU's SIG{INT,HUP,TERM} handlers 2020-10-17 10:45:53 -04:00
fuzz.h meson: convert tests/qtest to meson 2020-08-21 06:30:20 -04:00
i440fx_fuzz.c meson: link emulators without Makefile.target 2020-08-21 06:30:40 -04:00
meson.build fuzz: Add support for custom fuzzing library 2020-09-08 11:43:16 +02:00
qos_fuzz.c meson: convert tests/qtest to meson 2020-08-21 06:30:20 -04:00
qos_fuzz.h fuzz: add support for qos-assisted fuzz targets 2020-02-22 08:26:48 +00:00
qtest_wrappers.c meson: link emulators without Makefile.target 2020-08-21 06:30:40 -04:00
virtio_net_fuzz.c meson: link emulators without Makefile.target 2020-08-21 06:30:40 -04:00
virtio_scsi_fuzz.c meson: link emulators without Makefile.target 2020-08-21 06:30:40 -04:00