qemu/backends
Laurent Vivier 70074cc48f backends/rng: cap request size to avoid oversized allocation
rng_backend_request_entropy() uses the requested size to allocate
a buffer with g_malloc(). With virtio-rng, this size comes from
guest-supplied descriptor lengths. A malicious guest can set a very
large descriptor length, causing QEMU to attempt a multi-gigabyte
allocation and abort.

Cap the allocation to 64 KiB. The virtio-rng queue size is
hardcoded to 8 entries, the EGD backend protocol limits requests
to 255 bytes, the Linux kernel hwrng framework requests at most
SMP_CACHE_BYTES per call (64 bytes on x86_64), and the Windows
viorng driver uses a 4 KiB buffer. The worst legitimate case is
8 x 4 KiB = 32 KiB, so 64 KiB is well above any legitimate use.

Fixes: 1441703965 ("virtio-rng: use virtqueue_get_avail_bytes, fix migration")
Cc: qemu-stable@nongnu.org
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3983
Reported-by: dong ling <dongling226655@outlook.com>
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20260715141300.2295392-1-lvivier@redhat.com>
2026-07-27 15:14:13 -04:00
..
tpm tpm: Add conditional to not compile ioctls on GNU/Hurd 2026-06-17 15:15:43 +02:00
confidential-guest-support.c backends/confidential-guest-support: Add set_guest_policy() function 2025-07-12 15:28:21 +02:00
cryptodev-builtin.c cryptodev-builtin: Limit the maximum size 2026-02-05 05:06:46 -05:00
cryptodev-hmp-cmds.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
cryptodev-lkcf.c backends/cryptodev-lkcf: skip cleanup when not initialized 2026-06-06 09:15:23 +04:00
cryptodev-vhost-user.c char: rename CharBackend->CharFrontend 2025-10-28 14:49:52 +01:00
cryptodev-vhost.c vhost: move protocol_features to vhost_user 2026-06-03 08:36:11 -04:00
cryptodev.c qom: replace 'can_be_deleted' with 'prepare_delete' 2026-07-07 11:16:22 +02:00
dbus-vmstate.c qom: Make InterfaceInfo[] uses const 2025-04-25 17:00:41 +02:00
dbus-vmstate1.xml docs: move D-Bus VMState documentation to source XML 2021-12-21 10:50:21 +04:00
host_iommu_device.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
hostmem-epc.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
hostmem-file.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
hostmem-memfd.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
hostmem-ram.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
hostmem-shm.c hostmem/shm: Allow shm memory backend serve as shared memory for coco-VMs 2025-11-03 16:04:10 -05:00
hostmem.c qom: replace 'can_be_deleted' with 'prepare_delete' 2026-07-07 11:16:22 +02:00
igvm-cfg.c backends/igvm-cfg: free filename on finalization 2026-05-11 23:59:33 +04:00
igvm.c igvm: add device tree parameter support 2026-07-02 11:14:19 +02:00
iommufd.c Monitor patches for 2026-07-07 2026-07-07 19:17:41 +02:00
Kconfig backends: Initial support for SPDM socket support 2024-07-22 20:15:42 -04:00
meson.build igvm: add device tree parameter support 2026-07-02 11:14:19 +02:00
rng-builtin.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
rng-egd.c char: rename CharBackend->CharFrontend 2025-10-28 14:49:52 +01:00
rng-random.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
rng.c backends/rng: cap request size to avoid oversized allocation 2026-07-27 15:14:13 -04:00
spdm-socket.c error: Use error_setg_errno() for simplicity and consistency 2026-01-08 07:50:32 +01:00
trace-events backends/iommufd: Fix dev_id and type order in viommu trace 2026-07-07 07:12:46 +02:00
trace.h trace: switch position of headers to what Meson requires 2020-08-21 06:18:24 -04:00
vhost-user.c vhost-user: Fix stale error logs and return values in teardown paths 2026-06-03 08:36:12 -04:00