- hw/virtio/virtio-crypto: Protect from DMA re-entrancy bugs(CVE-2024-3446) - hw/char/virtio-serial-bus: Protect from DMA re-entrancy bugs(CVE-2024-3446) - hw/display/virtio-gpu: Protect from DMA re-entrancy bugs(CVE-2024-3446) - hw/virtio: Introduce virtio_bh_new_guarded() helper - hw: replace most qemu_bh_new calls with qemu_bh_new_guarded - checkpatch: add qemu_bh_new/aio_bh_new checks - async: avoid use-after-free on re-entrancy guard - async: Add an optional reentrancy guard to the BH API - hw/sd/sdhci: Do not update TRNMOD when Command Inhibit (DAT) is set(CVE-2024-3447) - rtl8139: Remove unused variable - tulip: Remove unused variable - virtio-mem: Fix the bitmap index of the section offset - virtio-mem: Fix the iterator variable in a vmem->rdl_list loop - system/memory: use ldn_he_p/stn_he_p - block: Fix crash when loading snapshot on inactive node - smmu: Clear SMMUPciBus pointer cache when system reset - block/mirror: Fix NULL s->job in active writes - amd_iommu: Fix APIC address check - virtio-crypto: fix NULL pointer dereference in virtio_crypto_free_reques - libqos/virtio.c: Correct 'flags' reading in qvirtqueue_kick cherry-pick from 66e411885a23c96ff73742d06b793fec3ceaebb7 - ivshmem-test.c: enable test_ivshmem_server for ppc64 arch - ivshmem.c: change endianness to LITTLE_ENDIAN - hw/ppc/mac.h: Remove MAX_CPUS macro - configure: remove dead variables - virtio-gpu: do not byteswap padding - hw/intc: clean-up error reporting for failed ITS cmd - qemu-iotests: Discard stderr when probing devices - linux-user: un-parent OBJECT(cpu) when closing thread - hw/net/rocker: Avoid undefined shifts with more than 31 ports - contrib/vhost-user-blk: Clean up deallocation of VuVirtqElement - scsi-disk: fix overflow when block size is not a multiple of BDRV_SECTOR_SIZE Signed-off-by: Jiabo Feng <fengjiabo1@huawei.com> (cherry picked from commit bf54b48c2963c869dfdc89977c57be4bd9e772aa)
69 lines
2.5 KiB
Diff
69 lines
2.5 KiB
Diff
From 53203b7c0c933bd0ce07c58bdd7113e2fba62fa3 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= <philmd@linaro.org>
|
|
Date: Thu, 4 Apr 2024 20:56:11 +0200
|
|
Subject: [PATCH] hw/virtio: Introduce virtio_bh_new_guarded() helper
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Introduce virtio_bh_new_guarded(), similar to qemu_bh_new_guarded()
|
|
but using the transport memory guard, instead of the device one
|
|
(there can only be one virtio device per virtio bus).
|
|
|
|
Inspired-by: Gerd Hoffmann <kraxel@redhat.com>
|
|
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
|
|
Acked-by: Michael S. Tsirkin <mst@redhat.com>
|
|
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
|
|
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
Message-Id: <20240409105537.18308-2-philmd@linaro.org>
|
|
Signed-off-by: liuxiangdong <liuxiangdong5@huawei.com>
|
|
---
|
|
hw/virtio/virtio.c | 10 ++++++++++
|
|
include/hw/virtio/virtio.h | 7 +++++++
|
|
2 files changed, 17 insertions(+)
|
|
|
|
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
|
|
index e3f392fc59..80156bfbd5 100644
|
|
--- a/hw/virtio/virtio.c
|
|
+++ b/hw/virtio/virtio.c
|
|
@@ -3960,3 +3960,13 @@ static void virtio_register_types(void)
|
|
}
|
|
|
|
type_init(virtio_register_types)
|
|
+
|
|
+QEMUBH *virtio_bh_new_guarded_full(DeviceState *dev,
|
|
+ QEMUBHFunc *cb, void *opaque,
|
|
+ const char *name)
|
|
+{
|
|
+ DeviceState *transport = qdev_get_parent_bus(dev)->parent;
|
|
+
|
|
+ return qemu_bh_new_full(cb, opaque, name,
|
|
+ &transport->mem_reentrancy_guard);
|
|
+}
|
|
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
|
|
index 43509b33ff..4cc278f12c 100644
|
|
--- a/include/hw/virtio/virtio.h
|
|
+++ b/include/hw/virtio/virtio.h
|
|
@@ -23,6 +23,7 @@
|
|
#include "standard-headers/linux/virtio_ring.h"
|
|
#include "qom/object.h"
|
|
#include "hw/virtio/vhost.h"
|
|
+#include "block/aio.h"
|
|
|
|
/* A guest should never accept this. It implies negotiation is broken. */
|
|
#define VIRTIO_F_BAD_FEATURE 30
|
|
@@ -409,4 +410,10 @@ static inline bool virtio_device_disabled(VirtIODevice *vdev)
|
|
bool virtio_legacy_allowed(VirtIODevice *vdev);
|
|
bool virtio_legacy_check_disabled(VirtIODevice *vdev);
|
|
|
|
+QEMUBH *virtio_bh_new_guarded_full(DeviceState *dev,
|
|
+ QEMUBHFunc *cb, void *opaque,
|
|
+ const char *name);
|
|
+#define virtio_bh_new_guarded(dev, cb, opaque) \
|
|
+ virtio_bh_new_guarded_full((dev), (cb), (opaque), (stringify(cb)))
|
|
+
|
|
#endif
|
|
--
|
|
2.27.0
|
|
|