qemu-patch-raspberry4/tests/qtest/fuzz
Alexander Bulekov af16990a1b fuzz: fix sparse memory access in the DMA callback
The code mistakenly relied on address_space_translate to store the
length remaining until the next memory-region. We care about this
because when there is RAM or sparse-memory neighboring on an MMIO
region, we should only write up to the border, to prevent inadvertently
invoking MMIO handlers within the DMA callback.

However address_space_translate_internal only stores the length until
the end of the MemoryRegion if memory_region_is_ram(mr). Otherwise
the *len is left unmodified. This caused some false-positive issues,
where the fuzzer found a way to perform a nested MMIO write through a
DMA callback on an [address, length] that started within sparse memory
and spanned some device MMIO regions.

To fix this, write to sparse memory in small chunks of
memory_access_size (similar to the underlying address_space_write code),
which will prevent accidentally hitting MMIO handlers through large
writes.

Signed-off-by: Alexander Bulekov <alxndr@bu.edu>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
2021-09-01 07:33:13 -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: Make fork_fuzz.ld compatible with LLVM's LLD 2020-11-10 08:51:30 +01:00
fuzz.c tests/qtest/fuzz: Fix build failure 2021-05-26 14:49:46 +02:00
fuzz.h Clean up includes 2020-12-10 17:16:44 +01:00
generic_fuzz.c fuzz: fix sparse memory access in the DMA callback 2021-09-01 07:33:13 -04:00
generic_fuzz_configs.h fuzz: Avoid deprecated misuse of -drive if=sd 2021-03-19 15:18:43 +01:00
i440fx_fuzz.c meson: link emulators without Makefile.target 2020-08-21 06:30:40 -04:00
meson.build fuzz: add virtio-blk fuzz target 2020-11-10 08:51:30 +01:00
qos_fuzz.c Do not include exec/address-spaces.h if it's not really necessary 2021-05-02 17:24:51 +02:00
qos_fuzz.h Remove leading underscores from QEMU defines 2021-06-21 05:49:01 +02:00
qtest_wrappers.c meson: link emulators without Makefile.target 2020-08-21 06:30:40 -04:00
virtio_blk_fuzz.c fuzz: add virtio-blk fuzz target 2020-11-10 08:51:30 +01: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