[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v2 36/47] vhost-vsock: detach the virqueue element in case of erro
From: |
Michael S. Tsirkin |
Subject: |
[PULL v2 36/47] vhost-vsock: detach the virqueue element in case of error |
Date: |
Mon, 7 Mar 2022 05:03:06 -0500 |
From: Stefano Garzarella <sgarzare@redhat.com>
In vhost_vsock_common_send_transport_reset(), if an element popped from
the virtqueue is invalid, we should call virtqueue_detach_element() to
detach it from the virtqueue before freeing its memory.
Fixes: fc0b9b0e1c ("vhost-vsock: add virtio sockets device")
Fixes: CVE-2022-26354
Cc: qemu-stable@nongnu.org
Reported-by: VictorV <vv474172261@gmail.com>
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Message-Id: <20220228095058.27899-1-sgarzare@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/virtio/vhost-vsock-common.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c
index 3f3771274e..ed706681ac 100644
--- a/hw/virtio/vhost-vsock-common.c
+++ b/hw/virtio/vhost-vsock-common.c
@@ -153,19 +153,23 @@ static void
vhost_vsock_common_send_transport_reset(VHostVSockCommon *vvc)
if (elem->out_num) {
error_report("invalid vhost-vsock event virtqueue element with "
"out buffers");
- goto out;
+ goto err;
}
if (iov_from_buf(elem->in_sg, elem->in_num, 0,
&event, sizeof(event)) != sizeof(event)) {
error_report("vhost-vsock event virtqueue element is too short");
- goto out;
+ goto err;
}
virtqueue_push(vq, elem, sizeof(event));
virtio_notify(VIRTIO_DEVICE(vvc), vq);
-out:
+ g_free(elem);
+ return;
+
+err:
+ virtqueue_detach_element(vq, elem, 0);
g_free(elem);
}
--
MST
- [PULL v2 26/47] pcie: Add a helper to the SR/IOV API, (continued)
- [PULL v2 26/47] pcie: Add a helper to the SR/IOV API, Michael S. Tsirkin, 2022/03/07
- [PULL v2 27/47] pcie: Add 1.2 version token for the Power Management Capability, Michael S. Tsirkin, 2022/03/07
- [PULL v2 28/47] pci-bridge/xio3130_upstream: Fix error handling, Michael S. Tsirkin, 2022/03/07
- [PULL v2 30/47] headers: Add pvpanic.h, Michael S. Tsirkin, 2022/03/07
- [PULL v2 29/47] pci-bridge/xio3130_downstream: Fix error handling, Michael S. Tsirkin, 2022/03/07
- [PULL v2 31/47] hw/misc/pvpanic: Use standard headers instead, Michael S. Tsirkin, 2022/03/07
- [PULL v2 33/47] pci: expose TYPE_XIO3130_DOWNSTREAM name, Michael S. Tsirkin, 2022/03/07
- [PULL v2 34/47] acpi: pcihp: pcie: set power on cap on parent slot, Michael S. Tsirkin, 2022/03/07
- [PULL v2 37/47] x86: cleanup unused compat_apic_id_mode, Michael S. Tsirkin, 2022/03/07
- [PULL v2 20/47] tests/qtest/virtio-iommu-test: Check bypass config, Michael S. Tsirkin, 2022/03/07
- [PULL v2 36/47] vhost-vsock: detach the virqueue element in case of error,
Michael S. Tsirkin <=
- [PULL v2 32/47] pci: show id info when pci BDF conflict, Michael S. Tsirkin, 2022/03/07
- [PULL v2 35/47] pc: add option to disable PS/2 mouse/keyboard, Michael S. Tsirkin, 2022/03/07
- [PULL v2 40/47] event_notifier: add event_notifier_get_wfd(), Michael S. Tsirkin, 2022/03/07
- [PULL v2 38/47] hw/smbios: Add table 4 parameter, "processor-id", Michael S. Tsirkin, 2022/03/07
- [PULL v2 41/47] vhost: use wfd on functions setting vring call fd, Michael S. Tsirkin, 2022/03/07
- [PULL v2 39/47] pci: drop COMPAT_PROP_PCP for 2.0 machine types, Michael S. Tsirkin, 2022/03/07
- [PULL v2 42/47] configure, meson: allow enabling vhost-user on all POSIX systems, Michael S. Tsirkin, 2022/03/07
- [PULL v2 43/47] docs: vhost-user: add subsection for non-Linux platforms, Michael S. Tsirkin, 2022/03/07
- [PULL v2 47/47] hw/acpi/microvm: turn on 8042 bit in FADT boot architecture flags if present, Michael S. Tsirkin, 2022/03/07
- [PULL v2 44/47] tests/acpi: i386: allow FACP acpi table changes, Michael S. Tsirkin, 2022/03/07