]> git.proxmox.com Git - pve-qemu.git/blob - debian/patches/extra/0014-vhost-vsock-detach-the-virqueue-element-in-case-of-e.patch
bump version to 6.2.0-11
[pve-qemu.git] / debian / patches / extra / 0014-vhost-vsock-detach-the-virqueue-element-in-case-of-e.patch
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Stefano Garzarella <sgarzare@redhat.com>
3 Date: Mon, 28 Feb 2022 10:50:58 +0100
4 Subject: [PATCH] vhost-vsock: detach the virqueue element in case of error
5
6 In vhost_vsock_common_send_transport_reset(), if an element popped from
7 the virtqueue is invalid, we should call virtqueue_detach_element() to
8 detach it from the virtqueue before freeing its memory.
9
10 Fixes: fc0b9b0e1c ("vhost-vsock: add virtio sockets device")
11 Fixes: CVE-2022-26354
12 Cc: qemu-stable@nongnu.org
13 Reported-by: VictorV <vv474172261@gmail.com>
14 Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
15 Message-Id: <20220228095058.27899-1-sgarzare@redhat.com>
16 Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
17 Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
18 Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
19 (cherry picked from commit 8d1b247f3748ac4078524130c6d7ae42b6140aaf)
20 Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
21 ---
22 hw/virtio/vhost-vsock-common.c | 10 +++++++---
23 1 file changed, 7 insertions(+), 3 deletions(-)
24
25 diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c
26 index 3f3771274e..ed706681ac 100644
27 --- a/hw/virtio/vhost-vsock-common.c
28 +++ b/hw/virtio/vhost-vsock-common.c
29 @@ -153,19 +153,23 @@ static void vhost_vsock_common_send_transport_reset(VHostVSockCommon *vvc)
30 if (elem->out_num) {
31 error_report("invalid vhost-vsock event virtqueue element with "
32 "out buffers");
33 - goto out;
34 + goto err;
35 }
36
37 if (iov_from_buf(elem->in_sg, elem->in_num, 0,
38 &event, sizeof(event)) != sizeof(event)) {
39 error_report("vhost-vsock event virtqueue element is too short");
40 - goto out;
41 + goto err;
42 }
43
44 virtqueue_push(vq, elem, sizeof(event));
45 virtio_notify(VIRTIO_DEVICE(vvc), vq);
46
47 -out:
48 + g_free(elem);
49 + return;
50 +
51 +err:
52 + virtqueue_detach_element(vq, elem, 0);
53 g_free(elem);
54 }
55