Re: [PATCH v3 1/7] memory: associate DMA accesses with the initiator Device

2022-11-15 Thread Alexander Bulekov
On 221115 1119, Peter Xu wrote: > On Fri, Oct 28, 2022 at 03:16:42PM -0400, Alexander Bulekov wrote: > > +/* Do not allow more than one simultanous access to a device's IO > > Regions */ > > +if (mr->owner && > > +!mr->ram_dev

Re: [RFC 0/3] add snapshot/restore fuzzing device

2022-07-23 Thread Alexander Bulekov
On 220722 2210, Claudio Fontana wrote: > Hi Richard, > > On 7/22/22 21:20, Richard Liu wrote: > > This RFC adds a virtual device for snapshot/restores within QEMU. I am > > working > > on this as a part of QEMU Google Summer of Code 2022. Fast snapshot/restores > > within QEMU is helpful for code

Re: qemu fuzz crash in virtio_net_queue_reset()

2024-03-21 Thread Alexander Bulekov
On 240320 0024, Vladimir Sementsov-Ogievskiy wrote: > Hi all! > > From fuzzing I've got a fuzz-data, which produces the following crash: > > qemu-fuzz-x86_64: ../hw/net/virtio-net.c:134: void > flush_or_purge_queued_packets(NetClientState *): Assertion > `!virtio_net_get_subqueue(nc)->async_tx.

Re: qemu fuzz crash in virtio_net_queue_reset()

2024-03-21 Thread Alexander Bulekov
On 240321 2208, Vladimir Sementsov-Ogievskiy wrote: > On 21.03.24 18:01, Alexander Bulekov wrote: > > On 240320 0024, Vladimir Sementsov-Ogievskiy wrote: > > > Hi all! > > > > > > From fuzzing I've got a fuzz-data, which produces the following crash:

[PATCH v10 00/22] Add virtual device fuzzing support

2020-02-19 Thread Alexander Bulekov
check-patch Alexander Bulekov (22): softmmu: move vl.c to softmmu/ softmmu: split off vl.c:main() into main.c module: check module wasn't already initialized fuzz: add FUZZ_TARGET module type qtest: add qtest_server_send abstraction libqtest: add a layer of abstraction to send

[PATCH v10 03/22] module: check module wasn't already initialized

2020-02-19 Thread Alexander Bulekov
module. Signed-off-by: Alexander Bulekov Reviewed-by: Stefan Hajnoczi Reviewed-by: Darren Kenny Reviewed-by: Philippe Mathieu-Daudé --- util/module.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/util/module.c b/util/module.c index 8c5315a7a3..236a7bb52a 100644 --- a/util/module.c

[PATCH v10 01/22] softmmu: move vl.c to softmmu/

2020-02-19 Thread Alexander Bulekov
Move vl.c to a separate directory, similar to linux-user/ Update the chechpatch and get_maintainer scripts, since they relied on /vl.c for top_of_tree checks. Signed-off-by: Alexander Bulekov --- MAINTAINERS | 2 +- Makefile.objs | 2 -- Makefile.target | 1

[PATCH v10 02/22] softmmu: split off vl.c:main() into main.c

2020-02-19 Thread Alexander Bulekov
perform some initialization before running the softmmu initialization. Now, main simply calls three vl.c functions which handle the guest initialization, main loop and cleanup. Signed-off-by: Alexander Bulekov Reviewed-by: Stefan Hajnoczi Reviewed-by: Darren Kenny --- MAINTAINERS | 1

[PATCH v10 04/22] fuzz: add FUZZ_TARGET module type

2020-02-19 Thread Alexander Bulekov
Signed-off-by: Alexander Bulekov Reviewed-by: Stefan Hajnoczi Reviewed-by: Darren Kenny --- include/qemu/module.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/qemu/module.h b/include/qemu/module.h index 65ba596e46..684753d808 100644 --- a/include/qemu/module.h

[PATCH v10 05/22] qtest: add qtest_server_send abstraction

2020-02-19 Thread Alexander Bulekov
same process (inproc) Signed-off-by: Alexander Bulekov Reviewed-by: Stefan Hajnoczi Reviewed-by: Darren Kenny Acked-by: Thomas Huth --- include/sysemu/qtest.h | 3 +++ qtest.c| 18 -- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/include

[PATCH v10 14/22] main: keep rcu_atfork callback enabled for qtest

2020-02-19 Thread Alexander Bulekov
The qtest-based fuzzer makes use of forking to reset-state between tests. Keep the callback enabled, so the call_rcu thread gets created within the child process. Signed-off-by: Alexander Bulekov Reviewed-by: Darren Kenny Acked-by: Stefan Hajnoczi --- softmmu/vl.c | 12 +++- 1 file

[PATCH v10 10/22] libqos: split qos-test and libqos makefile vars

2020-02-19 Thread Alexander Bulekov
and ones that are qos-test specific into different variables. Signed-off-by: Alexander Bulekov Reviewed-by: Darren Kenny Reviewed-by: Stefan Hajnoczi Reviewed-by: Philippe Mathieu-Daudé --- tests/qtest/Makefile.include | 71 ++-- 1 file changed, 36 insertions

[PATCH v10 16/22] fuzz: add support for qos-assisted fuzz targets

2020-02-19 Thread Alexander Bulekov
Signed-off-by: Alexander Bulekov Reviewed-by: Stefan Hajnoczi --- tests/qtest/fuzz/Makefile.include | 2 + tests/qtest/fuzz/qos_fuzz.c | 234 ++ tests/qtest/fuzz/qos_fuzz.h | 33 + 3 files changed, 269 insertions(+) create mode 100644 tests/qtest

[PATCH v10 13/22] exec: keep ram block across fork when using qtest

2020-02-19 Thread Alexander Bulekov
Ram blocks were marked MADV_DONTFORK breaking fuzzing-tests which execute each test-input in a forked process. Signed-off-by: Alexander Bulekov Reviewed-by: Stefan Hajnoczi Reviewed-by: Darren Kenny --- exec.c | 12 ++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a

[PATCH v10 06/22] libqtest: add a layer of abstraction to send/recv

2020-02-19 Thread Alexander Bulekov
: Alexander Bulekov Reviewed-by: Stefan Hajnoczi Reviewed-by: Darren Kenny --- tests/qtest/libqtest.c | 48 ++ 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 76c9f8eade..e5056a1d0f 100644

[PATCH v10 19/22] fuzz: add i440fx fuzz targets

2020-02-19 Thread Alexander Bulekov
: Alexander Bulekov Reviewed-by: Stefan Hajnoczi Reviewed-by: Darren Kenny --- tests/qtest/fuzz/Makefile.include | 3 + tests/qtest/fuzz/i440fx_fuzz.c| 193 ++ 2 files changed, 196 insertions(+) create mode 100644 tests/qtest/fuzz/i440fx_fuzz.c diff --git a/tests

[PATCH v10 07/22] libqtest: make bufwrite rely on the TransportOps

2020-02-19 Thread Alexander Bulekov
e benefits of the direct socket_send call, while adding support for in-process qtest calls. Signed-off-by: Alexander Bulekov Reviewed-by: Stefan Hajnoczi Reviewed-by: Darren Kenny --- tests/qtest/libqtest.c | 71 -- tests/qtest/libqtest.h | 4 +++ 2 file

[PATCH v10 21/22] fuzz: add virtio-scsi fuzz target

2020-02-19 Thread Alexander Bulekov
The virtio-scsi fuzz target sets up and fuzzes the available virtio-scsi queues. After an element is placed on a queue, the fuzzer can select whether to perform a kick, or continue adding elements. Signed-off-by: Alexander Bulekov --- tests/qtest/fuzz/Makefile.include | 1 + tests/qtest

[PATCH v10 15/22] fuzz: support for fork-based fuzzing.

2020-02-19 Thread Alexander Bulekov
y the location of the counters/coverage bitmap. As a workaround, we rely on a custom linker script which forces all of the bitmaps we care about to be placed in a contiguous region, which is easy to locate and mmap over. Signed-off-by: Alexander Bulekov Reviewed-by: Stefan Hajnoczi --- tests/

[PATCH v10 08/22] qtest: add in-process incoming command handler

2020-02-19 Thread Alexander Bulekov
The handler allows a qtest client to send commands to the server by directly calling a function, rather than using a file/CharBackend Signed-off-by: Alexander Bulekov Reviewed-by: Stefan Hajnoczi Reviewed-by: Darren Kenny --- include/sysemu/qtest.h | 1 + qtest.c| 13

[PATCH v10 18/22] fuzz: add configure flag --enable-fuzzing

2020-02-19 Thread Alexander Bulekov
Signed-off-by: Alexander Bulekov Reviewed-by: Stefan Hajnoczi Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Darren Kenny --- configure | 39 +++ 1 file changed, 39 insertions(+) diff --git a/configure b/configure index 115dc38085..bd873177ad 100755

[PATCH v10 22/22] fuzz: add documentation to docs/devel/

2020-02-19 Thread Alexander Bulekov
Signed-off-by: Alexander Bulekov Reviewed-by: Stefan Hajnoczi Reviewed-by: Darren Kenny --- docs/devel/fuzzing.txt | 116 + 1 file changed, 116 insertions(+) create mode 100644 docs/devel/fuzzing.txt diff --git a/docs/devel/fuzzing.txt b/docs/devel

[PATCH v10 09/22] libqos: rename i2c_send and i2c_recv

2020-02-19 Thread Alexander Bulekov
The names i2c_send and i2c_recv collide with functions defined in hw/i2c/core.c. This causes an error when linking against libqos and softmmu simultaneously (for example when using qtest inproc). Rename the libqos functions to avoid this. Signed-off-by: Alexander Bulekov Reviewed-by: Stefan

[PATCH v10 12/22] fuzz: add fuzzer skeleton

2020-02-19 Thread Alexander Bulekov
ich should be used to define new fuzz targets. Signed-off-by: Alexander Bulekov Reviewed-by: Stefan Hajnoczi Reviewed-by: Darren Kenny --- MAINTAINERS | 8 ++ tests/qtest/fuzz/Makefile.include | 6 + tests/qtest/fuzz/fuzz.c | 179 +++

[PATCH v10 11/22] libqos: move useful qos-test funcs to qos_external

2020-02-19 Thread Alexander Bulekov
The moved functions are not specific to qos-test and might be useful elsewhere. For example the virtual-device fuzzer makes use of them for qos-assisted fuzz-targets. Signed-off-by: Alexander Bulekov Reviewed-by: Stefan Hajnoczi Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Darren Kenny

[PATCH v10 17/22] fuzz: add target/fuzz makefile rules

2020-02-19 Thread Alexander Bulekov
Signed-off-by: Alexander Bulekov Reviewed-by: Darren Kenny Reviewed-by: Stefan Hajnoczi --- Makefile| 15 ++- Makefile.target | 16 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f0e1a2fc1d..36ca26f0f5 100644 --- a

[PATCH v10 20/22] fuzz: add virtio-net fuzz target

2020-02-19 Thread Alexander Bulekov
The virtio-net fuzz target feeds inputs to all three virtio-net virtqueues, and uses forking to avoid leaking state between fuzz runs. Signed-off-by: Alexander Bulekov Reviewed-by: Stefan Hajnoczi --- tests/qtest/fuzz/Makefile.include | 1 + tests/qtest/fuzz/virtio_net_fuzz.c | 198

Re: [Qemu-devel] [PATCH v2 1/2] net: assert that tx packets have nonzero size

2019-11-21 Thread Alexander Bulekov
On 191107 1221, Jason Wang wrote: > > On 2019/7/22 下午9:24, Oleinik, Alexander wrote: > > Virtual devices should not try to send zero-sized packets. The caller > > should check the size prior to calling qemu_sendv_packet_async. > > > > Signed-off-by: Alexander Oleinik > > --- > > v2: > >* Imp

Re: [PATCH v8 18/21] fuzz: add i440fx fuzz targets

2020-02-06 Thread Alexander Bulekov
e using qtest and qos for fuzzing, as well as using > > rebooting and forking to reset state, or not resetting it at all. > > > > Signed-off-by: Alexander Bulekov > > Reviewed-by: Stefan Hajnoczi > > Reviewed-by: Darren Kenny > > A couple of nit below w.r.

Re: [PATCH v8 19/21] fuzz: add virtio-net fuzz target

2020-02-06 Thread Alexander Bulekov
On 200205 1357, Darren Kenny wrote: > On Wed, Jan 29, 2020 at 05:34:27AM +, Bulekov, Alexander wrote: > > The virtio-net fuzz target feeds inputs to all three virtio-net > > virtqueues, and uses forking to avoid leaking state between fuzz runs. > > > > Signe

Re: [PATCH v8 15/21] fuzz: add support for qos-assisted fuzz targets

2020-02-11 Thread Alexander Bulekov
On 200205 1318, Darren Kenny wrote: > On Wed, Jan 29, 2020 at 05:34:24AM +, Bulekov, Alexander wrote: > > Signed-off-by: Alexander Bulekov > > Reviewed-by: Stefan Hajnoczi > > --- > > > > +return allocate_objects(qts, current_path + 1, p_alloc); &g

[PATCH v9 00/23] Add virtual device fuzzing support

2020-02-11 Thread Alexander Bulekov
* rewrite fork-based fuzzer pending patch to libfuzzer * pass check-patch Alexander Bulekov (23): checkpatch: replace vl.c in the top of repo check softmmu: move vl.c to softmmu/ softmmu: split off vl.c:main() into main.c module: check module wasn't already initialized fuzz: add FUZZ_T

[PATCH v9 02/23] softmmu: move vl.c to softmmu/

2020-02-11 Thread Alexander Bulekov
Signed-off-by: Alexander Bulekov --- Makefile.objs | 2 -- Makefile.target | 1 + softmmu/Makefile.objs | 2 ++ vl.c => softmmu/vl.c | 0 4 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 softmmu/Makefile.objs rename vl.c => softmmu/vl.c (100%) diff -

[PATCH v9 01/23] checkpatch: replace vl.c in the top of repo check

2020-02-11 Thread Alexander Bulekov
524b4c2c5c moves vl.c into softmmu/ , breaking the checkpatch top-of-kernel-tree check. Replace with checks for softmmu and linux-user Signed-off-by: Alexander Bulekov --- scripts/checkpatch.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/checkpatch.pl b/scripts

[PATCH v9 05/23] fuzz: add FUZZ_TARGET module type

2020-02-11 Thread Alexander Bulekov
Signed-off-by: Alexander Bulekov Reviewed-by: Stefan Hajnoczi Reviewed-by: Darren Kenny --- include/qemu/module.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/qemu/module.h b/include/qemu/module.h index 65ba596e46..684753d808 100644 --- a/include/qemu/module.h

[PATCH v9 03/23] softmmu: split off vl.c:main() into main.c

2020-02-11 Thread Alexander Bulekov
perform some initialization before running the softmmu initialization. Now, main simply calls three vl.c functions which handle the guest initialization, main loop and cleanup. Signed-off-by: Alexander Bulekov Reviewed-by: Stefan Hajnoczi Reviewed-by: Darren Kenny --- Makefile.target | 2

[PATCH v9 11/23] libqos: split qos-test and libqos makefile vars

2020-02-11 Thread Alexander Bulekov
and ones that are qos-test specific into different variables. Signed-off-by: Alexander Bulekov Reviewed-by: Darren Kenny Reviewed-by: Stefan Hajnoczi Reviewed-by: Philippe Mathieu-Daudé --- tests/qtest/Makefile.include | 71 ++-- 1 file changed, 36 insertions

[PATCH v9 15/23] main: keep rcu_atfork callback enabled for qtest

2020-02-11 Thread Alexander Bulekov
The qtest-based fuzzer makes use of forking to reset-state between tests. Keep the callback enabled, so the call_rcu thread gets created within the child process. Signed-off-by: Alexander Bulekov Reviewed-by: Darren Kenny Acked-by: Stefan Hajnoczi --- softmmu/vl.c | 12 +++- 1 file

[PATCH v9 04/23] module: check module wasn't already initialized

2020-02-11 Thread Alexander Bulekov
module. Signed-off-by: Alexander Bulekov Reviewed-by: Stefan Hajnoczi Reviewed-by: Darren Kenny Reviewed-by: Philippe Mathieu-Daudé --- util/module.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/util/module.c b/util/module.c index 8c5315a7a3..236a7bb52a 100644 --- a/util/module.c

[PATCH v9 06/23] qtest: add qtest_server_send abstraction

2020-02-11 Thread Alexander Bulekov
same process (inproc) Signed-off-by: Alexander Bulekov Reviewed-by: Stefan Hajnoczi Reviewed-by: Darren Kenny Acked-by: Thomas Huth --- include/sysemu/qtest.h | 3 +++ qtest.c| 18 -- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/include

[PATCH v9 12/23] libqos: move useful qos-test funcs to qos_external

2020-02-11 Thread Alexander Bulekov
The moved functions are not specific to qos-test and might be useful elsewhere. For example the virtual-device fuzzer makes use of them for qos-assisted fuzz-targets. Signed-off-by: Alexander Bulekov Reviewed-by: Stefan Hajnoczi Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Darren Kenny

[PATCH v9 09/23] qtest: add in-process incoming command handler

2020-02-11 Thread Alexander Bulekov
The handler allows a qtest client to send commands to the server by directly calling a function, rather than using a file/CharBackend Signed-off-by: Alexander Bulekov Reviewed-by: Stefan Hajnoczi Reviewed-by: Darren Kenny --- include/sysemu/qtest.h | 1 + qtest.c| 13

[PATCH v9 13/23] fuzz: add fuzzer skeleton

2020-02-11 Thread Alexander Bulekov
ich should be used to define new fuzz targets. Signed-off-by: Alexander Bulekov Reviewed-by: Stefan Hajnoczi Reviewed-by: Darren Kenny --- tests/qtest/fuzz/Makefile.include | 6 + tests/qtest/fuzz/fuzz.c | 179 ++ tests/qtest/fuzz/fuzz.h

[PATCH v9 18/23] fuzz: add target/fuzz makefile rules

2020-02-11 Thread Alexander Bulekov
Signed-off-by: Alexander Bulekov Reviewed-by: Darren Kenny Reviewed-by: Stefan Hajnoczi --- Makefile| 15 ++- Makefile.target | 16 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f0e1a2fc1d..36ca26f0f5 100644 --- a

[PATCH v9 07/23] libqtest: add a layer of abstraction to send/recv

2020-02-11 Thread Alexander Bulekov
: Alexander Bulekov Reviewed-by: Stefan Hajnoczi Reviewed-by: Darren Kenny --- tests/qtest/libqtest.c | 48 ++ 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 76c9f8eade..e5056a1d0f 100644

[PATCH v9 22/23] fuzz: add virtio-scsi fuzz target

2020-02-11 Thread Alexander Bulekov
The virtio-scsi fuzz target sets up and fuzzes the available virtio-scsi queues. After an element is placed on a queue, the fuzzer can select whether to perform a kick, or continue adding elements. Signed-off-by: Alexander Bulekov --- tests/qtest/fuzz/Makefile.include | 1 + tests/qtest

[PATCH v9 23/23] fuzz: add documentation to docs/devel/

2020-02-11 Thread Alexander Bulekov
Signed-off-by: Alexander Bulekov Reviewed-by: Stefan Hajnoczi Reviewed-by: Darren Kenny --- docs/devel/fuzzing.txt | 116 + 1 file changed, 116 insertions(+) create mode 100644 docs/devel/fuzzing.txt diff --git a/docs/devel/fuzzing.txt b/docs/devel

[PATCH v9 08/23] libqtest: make bufwrite rely on the TransportOps

2020-02-11 Thread Alexander Bulekov
e benefits of the direct socket_send call, while adding support for in-process qtest calls. Signed-off-by: Alexander Bulekov Reviewed-by: Stefan Hajnoczi Reviewed-by: Darren Kenny --- tests/qtest/libqtest.c | 71 -- tests/qtest/libqtest.h | 4 +++ 2 file

[PATCH v9 20/23] fuzz: add i440fx fuzz targets

2020-02-11 Thread Alexander Bulekov
: Alexander Bulekov Reviewed-by: Stefan Hajnoczi Reviewed-by: Darren Kenny --- tests/qtest/fuzz/Makefile.include | 3 + tests/qtest/fuzz/i440fx_fuzz.c| 193 ++ 2 files changed, 196 insertions(+) create mode 100644 tests/qtest/fuzz/i440fx_fuzz.c diff --git a/tests

[PATCH v9 21/23] fuzz: add virtio-net fuzz target

2020-02-11 Thread Alexander Bulekov
The virtio-net fuzz target feeds inputs to all three virtio-net virtqueues, and uses forking to avoid leaking state between fuzz runs. Signed-off-by: Alexander Bulekov Reviewed-by: Stefan Hajnoczi --- tests/qtest/fuzz/Makefile.include | 1 + tests/qtest/fuzz/virtio_net_fuzz.c | 198

[PATCH v9 10/23] libqos: rename i2c_send and i2c_recv

2020-02-11 Thread Alexander Bulekov
The names i2c_send and i2c_recv collide with functions defined in hw/i2c/core.c. This causes an error when linking against libqos and softmmu simultaneously (for example when using qtest inproc). Rename the libqos functions to avoid this. Signed-off-by: Alexander Bulekov Reviewed-by: Stefan

[PATCH v9 14/23] exec: keep ram block across fork when using qtest

2020-02-11 Thread Alexander Bulekov
Ram blocks were marked MADV_DONTFORK breaking fuzzing-tests which execute each test-input in a forked process. Signed-off-by: Alexander Bulekov Reviewed-by: Stefan Hajnoczi Reviewed-by: Darren Kenny --- exec.c | 12 ++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a

[PATCH v9 16/23] fuzz: support for fork-based fuzzing.

2020-02-11 Thread Alexander Bulekov
y the location of the counters/coverage bitmap. As a workaround, we rely on a custom linker script which forces all of the bitmaps we care about to be placed in a contiguous region, which is easy to locate and mmap over. Signed-off-by: Alexander Bulekov Reviewed-by: Stefan Hajnoczi --- tests/

[PATCH v9 17/23] fuzz: add support for qos-assisted fuzz targets

2020-02-11 Thread Alexander Bulekov
Signed-off-by: Alexander Bulekov Reviewed-by: Stefan Hajnoczi --- tests/qtest/fuzz/Makefile.include | 2 + tests/qtest/fuzz/qos_fuzz.c | 234 ++ tests/qtest/fuzz/qos_fuzz.h | 33 + 3 files changed, 269 insertions(+) create mode 100644 tests/qtest

[PATCH v9 19/23] fuzz: add configure flag --enable-fuzzing

2020-02-11 Thread Alexander Bulekov
Signed-off-by: Alexander Bulekov Reviewed-by: Stefan Hajnoczi Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Darren Kenny --- configure | 39 +++ 1 file changed, 39 insertions(+) diff --git a/configure b/configure index 115dc38085..bd873177ad 100755

[PATCH v4 0/3] memory: prevent dma-reentracy issues

2023-01-18 Thread Alexander Bulekov
all of the DMA APIs, instead add an optional reentrancy guard to the BH API. v2 -> v3: Bite the bullet and modify the DMA APIs, rather than attempting to guess DeviceStates in BHs. Alexander Bulekov (3): memory: prevent dma-reentracy issues async: Add an optional reentrancy guard

[PATCH v4 0/3] memory: prevent dma-reentracy issues

2023-01-18 Thread Alexander Bulekov
all of the DMA APIs, instead add an optional reentrancy guard to the BH API. v2 -> v3: Bite the bullet and modify the DMA APIs, rather than attempting to guess DeviceStates in BHs. Alexander Bulekov (3): memory: prevent dma-reentracy issues async: Add an optional reentrancy guard

[PATCH v4 2/3] async: Add an optional reentrancy guard to the BH API

2023-01-18 Thread Alexander Bulekov
Devices can pass their MemoryReentrancyGuard (from their DeviceState), when creating new BHes. Then, the async API will toggle the guard before/after calling the BH call-back. This prevents bh->mmio reentrancy issues. Signed-off-by: Alexander Bulekov --- docs/devel/multiple-iothreads.txt |

[PATCH v4 1/3] memory: prevent dma-reentracy issues

2023-01-18 Thread Alexander Bulekov
//gitlab.com/qemu-project/qemu/-/issues/827 Signed-off-by: Alexander Bulekov --- include/hw/qdev-core.h | 7 +++ softmmu/memory.c | 15 +++ softmmu/trace-events | 1 + 3 files changed, 23 insertions(+) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 35fdd

[PATCH v4 1/3] memory: prevent dma-reentracy issues

2023-01-18 Thread Alexander Bulekov
//gitlab.com/qemu-project/qemu/-/issues/827 Signed-off-by: Alexander Bulekov --- include/hw/qdev-core.h | 7 +++ softmmu/memory.c | 15 +++ softmmu/trace-events | 1 + 3 files changed, 23 insertions(+) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 35fdd

[PATCH v4 3/3] hw: replace most qemu_bh_new calls with qemu_bh_new_guarded

2023-01-18 Thread Alexander Bulekov
This protects devices from bh->mmio reentrancy issues. Signed-off-by: Alexander Bulekov --- hw/9pfs/xen-9p-backend.c| 4 +++- hw/block/dataplane/virtio-blk.c | 3 ++- hw/block/dataplane/xen-block.c | 5 +++-- hw/block/virtio-blk.c | 5 +++-- hw/char/virtio-serial-bu

[PATCH v4 0/3] memory: prevent dma-reentracy issues

2023-01-18 Thread Alexander Bulekov
all of the DMA APIs, instead add an optional reentrancy guard to the BH API. v2 -> v3: Bite the bullet and modify the DMA APIs, rather than attempting to guess DeviceStates in BHs. Alexander Bulekov (3): memory: prevent dma-reentracy issues async: Add an optional reentrancy guard

Re: [PATCH] scsi/lsi53c895a: restrict DMA engine to memory regions (CVE-2023-0330)

2023-03-24 Thread Alexander Bulekov
On 230324 1200, Mauro Matteo Cascella wrote: > On Fri, Mar 17, 2023 at 10:59 PM Philippe Mathieu-Daudé > wrote: > > > > On 17/3/23 19:18, Karl Heubaum wrote: > > > Did this CVE fix fall in the cracks during the QEMU 8.0 merge window? > > > > The patch isn't reviewed, and apparently almost no activ

Re: [PATCH] usb/dev-wacom: fix OOB write in usb_mouse_poll()

2023-03-29 Thread Alexander Bulekov
On 230214 1148, Mauro Matteo Cascella wrote: > Hi Philippe, > > On Mon, Feb 13, 2023 at 7:26 PM Philippe Mathieu-Daudé > wrote: > > > > Hi Mauro, > > > > On 13/2/23 18:41, Mauro Matteo Cascella wrote: > > > The guest can control the size of buf; an OOB write occurs when buf is 1 > > > or 2 > > >

Re: [PATCH] usb/dev-wacom: fix OOB write in usb_mouse_poll()

2023-03-29 Thread Alexander Bulekov
Cascella Tested-by: Alexander Bulekov Thanks > --- > hw/usb/dev-wacom.c | 20 +--- > 1 file changed, 13 insertions(+), 7 deletions(-) > > diff --git a/hw/usb/dev-wacom.c b/hw/usb/dev-wacom.c > index 7177c17f03..ca9e6aa82f 100644 > --- a/hw/usb/dev-wacom.c > +

Re: [PATCH v3] hw/arm: do not free machine->fdt in arm_load_dtb()

2023-03-30 Thread Alexander Bulekov
On 230328 1859, Markus Armbruster wrote: > At this moment, arm_load_dtb() can free machine->fdt when > binfo->dtb_filename is NULL. If there's no 'dtb_filename', 'fdt' will be > retrieved by binfo->get_dtb(). If get_dtb() returns machine->fdt, as is > the case of machvirt_dtb() from hw/arm/virt.c,

Re: [PATCH v4 2/3] async: Add an optional reentrancy guard to the BH API

2023-01-25 Thread Alexander Bulekov
On 230125 1624, Stefan Hajnoczi wrote: > On Thu, Jan 19, 2023 at 02:03:07AM -0500, Alexander Bulekov wrote: > > Devices can pass their MemoryReentrancyGuard (from their DeviceState), > > when creating new BHes. Then, the async API will toggle the guard > > before/after cal

Re: [PATCH v4 1/3] memory: prevent dma-reentracy issues

2023-01-25 Thread Alexander Bulekov
On 230120 1447, Peter Maydell wrote: > On Fri, 20 Jan 2023 at 14:42, Darren Kenny wrote: > > Generally, this looks good, but I do have a comment below... > > > > On Thursday, 2023-01-19 at 02:00:02 -05, Alexander Bulekov wrote: > > > Add a flag to the DeviceState, w

[PATCH v5 1/4] memory: prevent dma-reentracy issues

2023-01-25 Thread Alexander Bulekov
//gitlab.com/qemu-project/qemu/-/issues/827 Reviewed-by: Stefan Hajnoczi Signed-off-by: Alexander Bulekov --- include/hw/qdev-core.h | 7 +++ softmmu/memory.c | 17 + softmmu/trace-events | 1 + 3 files changed, 25 insertions(+) diff --git a/include/hw/qdev-core.h

[PATCH v5 0/4] memory: prevent dma-reentracy issues

2023-01-25 Thread Alexander Bulekov
ad of changing all of the DMA APIs, instead add an optional reentrancy guard to the BH API. v2 -> v3: Bite the bullet and modify the DMA APIs, rather than attempting to guess DeviceStates in BHs. Alexander Bulekov (4): memory: prevent dma-reentracy issues async: Add an optional re

[PATCH v5 1/4] memory: prevent dma-reentracy issues

2023-01-25 Thread Alexander Bulekov
//gitlab.com/qemu-project/qemu/-/issues/827 Reviewed-by: Stefan Hajnoczi Signed-off-by: Alexander Bulekov --- include/hw/qdev-core.h | 7 +++ softmmu/memory.c | 17 + softmmu/trace-events | 1 + 3 files changed, 25 insertions(+) diff --git a/include/hw/qdev-core.h

[PATCH v5 0/4] memory: prevent dma-reentracy issues

2023-01-25 Thread Alexander Bulekov
ad of changing all of the DMA APIs, instead add an optional reentrancy guard to the BH API. v2 -> v3: Bite the bullet and modify the DMA APIs, rather than attempting to guess DeviceStates in BHs. Alexander Bulekov (4): memory: prevent dma-reentracy issues async: Add an optional re

[PATCH v5 2/4] async: Add an optional reentrancy guard to the BH API

2023-01-25 Thread Alexander Bulekov
Devices can pass their MemoryReentrancyGuard (from their DeviceState), when creating new BHes. Then, the async API will toggle the guard before/after calling the BH call-back. This prevents bh->mmio reentrancy issues. Signed-off-by: Alexander Bulekov --- docs/devel/multiple-iothreads.txt |

[PATCH v5 4/4] hw: replace most qemu_bh_new calls with qemu_bh_new_guarded

2023-01-25 Thread Alexander Bulekov
This protects devices from bh->mmio reentrancy issues. Reviewed-by: Stefan Hajnoczi Signed-off-by: Alexander Bulekov --- hw/9pfs/xen-9p-backend.c| 4 +++- hw/block/dataplane/virtio-blk.c | 3 ++- hw/block/dataplane/xen-block.c | 5 +++-- hw/block/virtio-blk.c | 5 +++--

[PATCH v5 3/4] checkpatch: add qemu_bh_new/aio_bh_new checks

2023-01-25 Thread Alexander Bulekov
Advise authors to use the _guarded versions of the APIs, instead. Signed-off-by: Alexander Bulekov --- scripts/checkpatch.pl | 8 1 file changed, 8 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 6ecabfb2b5..61bb4b0a19 100755 --- a/scripts/checkpatch.pl

Re: [PATCH] softmmu: Use memmove in flatview_write_continue

2023-01-30 Thread Alexander Bulekov
On 230130 2251, Akihiko Odaki wrote: > We found a case where the source passed to flatview_write_continue() may > overlap with the destination when fuzzing igb, a new proposed network > device with sanitizers. > > igb uses pci_dma_map() to get Tx packet, and pci_dma_write() to write Rx > buffer. W

Re: [PATCH] softmmu: Use memmove in flatview_write_continue

2023-01-30 Thread Alexander Bulekov
On 230130 1528, Peter Xu wrote: > On Mon, Jan 30, 2023 at 03:03:00PM -0500, Alexander Bulekov wrote: > > On 230130 2251, Akihiko Odaki wrote: > > > We found a case where the source passed to flatview_write_continue() may > > > overlap with the destination when fuzzing

Re: [PATCH-for-6.2 2/2] tests/qtest/fdc-test: Add a regression test for CVE-2021-3507

2021-11-23 Thread Alexander Bulekov
> 0x0c3280004590: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd > Shadow byte legend (one shadow byte represents 8 application bytes): > Addressable: 00 > Heap left redzone: fa > Freed heap region: fd > ==4028352==ABORTING > > Repor

Re: [PATCH-for-6.2 v3 2/2] tests/qtest/fdc-test: Add a regression test for CVE-2021-20196

2021-11-23 Thread Alexander Bulekov
On 211123 1449, Philippe Mathieu-Daudé wrote: > On 11/23/21 14:42, Hanna Reitz wrote: > > On 18.11.21 13:06, Philippe Mathieu-Daudé wrote: > >> From: Alexander Bulekov > >> > >> Without the previous commit, when running 'make check-qtest-i386' >

[PATCH] loongarch: mark loongarch_ipi_iocsr re-entrnacy safe

2023-05-06 Thread Alexander Bulekov
loongarch_ipi_iocsr MRs rely on re-entrant IO through the ipi_send function. As such, mark these MRs re-entrancy-safe. Fixes: a2e1753b80 ("memory: prevent dma-reentracy issues") Signed-off-by: Alexander Bulekov --- hw/intc/loongarch_ipi.c | 4 1 file changed, 4 insertions(+) di

[PATCH] pnv_lpc: disable reentrancy detection for lpc-hc

2023-05-11 Thread Alexander Bulekov
As lpc-hc is designed for re-entrant calls from xscom, mark it re-entrancy safe. Reported-by: Thomas Huth Signed-off-by: Alexander Bulekov --- hw/ppc/pnv_lpc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/ppc/pnv_lpc.c b/hw/ppc/pnv_lpc.c index 01f44c19eb..67fd049a7f 100644 --- a/hw

Re: [PATCH] pnv_lpc: disable reentrancy detection for lpc-hc

2023-05-11 Thread Alexander Bulekov
On 230511 1104, Cédric Le Goater wrote: > Hello Alexander > > On 5/11/23 10:53, Alexander Bulekov wrote: > > As lpc-hc is designed for re-entrant calls from xscom, mark it > > re-entrancy safe. > > > > Reported-by: Thomas Huth > > Signed-off-by: Alexander

[PATCH] memory: stricter checks prior to unsetting engaged_in_io

2023-05-16 Thread Alexander Bulekov
engaged_in_io could be unset by an MR with re-entrancy checks disabled. Ensure that only MRs that can set the engaged_in_io flag can unset it. Closes: https://gitlab.com/qemu-project/qemu/-/issues/1563 Reported-by: Thomas Huth Signed-off-by: Alexander Bulekov --- softmmu/memory.c | 4 +++- 1

Re: [PATCH] lsi53c895a: disable reentrancy detection for MMIO region, too

2023-05-16 Thread Alexander Bulekov
On 230516 1105, Thomas Huth wrote: > While trying to use a SCSI disk on the LSI controller with an > older version of Fedora (25), I'm getting: > > qemu: warning: Blocked re-entrant IO on MemoryRegion: lsi-mmio at addr: 0x34 Do you have a gdb backtrace for this one or is there some easy way to r

Re: [PATCH v2] memory: prevent dma-reentracy issues

2022-06-21 Thread Alexander Bulekov
On 220621 1034, David Hildenbrand wrote: > On 09.06.22 15:58, Alexander Bulekov wrote: > > Add a flag to the DeviceState, when a device is engaged in PIO/MMIO/DMA. > > This flag is set/checked prior to calling a device's MemoryRegion > > handlers, and set when devic

Re: [PATCH v2] memory: prevent dma-reentracy issues

2022-06-21 Thread Alexander Bulekov
On 220621 1630, Peter Maydell wrote: > On Thu, 9 Jun 2022 at 14:59, Alexander Bulekov wrote: > > > > Add a flag to the DeviceState, when a device is engaged in PIO/MMIO/DMA. > > This flag is set/checked prior to calling a device's MemoryRegion > > handlers, and se

[PATCH] build: improve -fsanitize-coverage-allowlist check

2022-06-21 Thread Alexander Bulekov
The sancov filter check still fails when unused arguments are treated as errors. To work around that, add a SanitizerCoverage flag to the build-check. Fixes: aa4f3a3b88 ("build: fix check for -fsanitize-coverage-allowlist") Signed-off-by: Alexander Bulekov --- meson.build | 3 +

[PATCH] fuzz: only use generic-fuzz targets on oss-fuzz

2022-06-22 Thread Alexander Bulekov
The non-generic-fuzz targets often time-out, or run out of memory. Additionally, they create unreproducible bug-reports. It is possible that this is resulting in failing coverage-reports on OSS-Fuzz. In the future, these test-cases should be fixed, or removed. Signed-off-by: Alexander Bulekov

Re: [PATCH] fuzz: only use generic-fuzz targets on oss-fuzz

2022-06-22 Thread Alexander Bulekov
t might read better - but it seems the default is that we don't > assume that, or am I wrong? (This is probably a question for others on > the CC-list) That sounds good to me. Should we change the script to #!/bin/bash, to be safe? -Alex > > Thanks, > > Darren. > >

[PATCH v2] fuzz: only use generic-fuzz targets on oss-fuzz

2022-06-23 Thread Alexander Bulekov
-off-by: Alexander Bulekov --- scripts/oss-fuzz/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/oss-fuzz/build.sh b/scripts/oss-fuzz/build.sh index 98b56e0521..aaf485cb55 100755 --- a/scripts/oss-fuzz/build.sh +++ b/scripts/oss-fuzz/build.sh @@ -1,4 +1,4

Re: [PATCH] rtl8139: fix large_send_mss divide-by-zero

2023-04-14 Thread Alexander Bulekov
rite 0xb800a646028c000e 0x1 0x47 > write 0xb800a646028c0010 0x1 0x02 > write 0xb800a646028c0017 0x1 0x06 > write 0xb800a646028c0036 0x1 0x80 > write 0xe0d9 0x1 0x40 > EOF > > Buglink: https://gitlab.com/qemu-project/qemu/-/issues/1582 Maybe instead: Closes:

[PATCH v8 1/8] memory: prevent dma-reentracy issues

2023-04-21 Thread Alexander Bulekov
//gitlab.com/qemu-project/qemu/-/issues/827 Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1282 Resolves: CVE-2023-0330 Signed-off-by: Alexander Bulekov --- include/exec/memory.h | 2 ++ include/hw/qdev-core.h | 7 +++ softmmu/memory.c | 14 ++ softmmu/trace-events

[PATCH v8 3/8] checkpatch: add qemu_bh_new/aio_bh_new checks

2023-04-21 Thread Alexander Bulekov
Advise authors to use the _guarded versions of the APIs, instead. Reviewed-by: Darren Kenny Signed-off-by: Alexander Bulekov --- scripts/checkpatch.pl | 8 1 file changed, 8 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index d768171dcf..eeaec436eb 100755

[PATCH v8 6/8] lsi53c895a: disable reentrancy detection for script RAM

2023-04-21 Thread Alexander Bulekov
As the code is designed to use the memory APIs to access the script ram, disable reentrancy checks for the pseudo-RAM ram_io MemoryRegion. In the future, ram_io may be converted from an IO to a proper RAM MemoryRegion. Reported-by: Fiona Ebner Signed-off-by: Alexander Bulekov Reviewed-by

[PATCH v8 5/8] memory: Allow disabling re-entrancy checking per-MR

2023-04-21 Thread Alexander Bulekov
Signed-off-by: Alexander Bulekov Reviewed-by: Thomas Huth Reviewed-by: Darren Kenny --- include/exec/memory.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/exec/memory.h b/include/exec/memory.h index 6c0a5e68d3..4e9531bd8a 100644 --- a/include/exec/memory.h +++ b/include/exec

[PATCH v8 4/8] hw: replace most qemu_bh_new calls with qemu_bh_new_guarded

2023-04-21 Thread Alexander Bulekov
This protects devices from bh->mmio reentrancy issues. Thanks: Thomas Huth for diagnosing OS X test failure. Reviewed-by: Darren Kenny Reviewed-by: Stefan Hajnoczi Reviewed-by: Michael S. Tsirkin Reviewed-by: Paul Durrant Signed-off-by: Alexander Bulekov Reviewed-by: Thomas Huth ---

[PATCH v8 0/8] memory: prevent dma-reentracy issues

2023-04-21 Thread Alexander Bulekov
st of the qemu_bh_new invocations with the guarded analog, except for the ones where the DeviceState was not trivially accessible. Alexander Bulekov (8): memory: prevent dma-reentracy issues async: Add an optional reentrancy guard to the BH API checkpatch: add qemu_bh_new/aio_bh_ne

[PATCH v8 2/8] async: Add an optional reentrancy guard to the BH API

2023-04-21 Thread Alexander Bulekov
Devices can pass their MemoryReentrancyGuard (from their DeviceState), when creating new BHes. Then, the async API will toggle the guard before/after calling the BH call-back. This prevents bh->mmio reentrancy issues. Reviewed-by: Darren Kenny Signed-off-by: Alexander Bulekov --- docs/de

[PATCH v8 7/8] bcm2835_property: disable reentrancy detection for iomem

2023-04-21 Thread Alexander Bulekov
As the code is designed for re-entrant calls from bcm2835_property to bcm2835_mbox and back into bcm2835_property, mark iomem as reentrancy-safe. Signed-off-by: Alexander Bulekov --- hw/misc/bcm2835_property.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/hw/misc/bcm2835_property.c

[PATCH v8 8/8] memory: abort on re-entrancy in debug builds

2023-04-21 Thread Alexander Bulekov
This is useful for using unit-tests/fuzzing to detect bugs introduced by the re-entrancy guard mechanism into devices that are intentionally re-entrant. Signed-off-by: Alexander Bulekov --- softmmu/memory.c | 3 +++ util/async.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a

  1   2   3   4   5   6   7   8   9   10   >