qemu-pmb887x/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
cryptodev-builtin.c cryptodev-builtin: Limit the maximum size 2026-02-05 05:06:46 -05:00
cryptodev-hmp-cmds.c
cryptodev-lkcf.c backends/cryptodev-lkcf: skip cleanup when not initialized 2026-06-06 09:15:23 +04:00
cryptodev-vhost-user.c
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
dbus-vmstate1.xml
host_iommu_device.c
hostmem-epc.c
hostmem-file.c
hostmem-memfd.c
hostmem-ram.c
hostmem-shm.c
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
meson.build igvm: add device tree parameter support 2026-07-02 11:14:19 +02:00
rng-builtin.c
rng-egd.c
rng-random.c
rng.c backends/rng: cap request size to avoid oversized allocation 2026-07-27 15:14:13 -04:00
spdm-socket.c
trace-events backends/iommufd: Fix dev_id and type order in viommu trace 2026-07-07 07:12:46 +02:00
trace.h
vhost-user.c vhost-user: Fix stale error logs and return values in teardown paths 2026-06-03 08:36:12 -04:00