blob: 59ccfdd03cc92fe39383d28cb0aa657e9c57a4ec [file] [log] [blame]
Andrew Geissler9aee5002022-03-30 16:27:02 +00001CVE: CVE-2022-26353
2Upstream-Status: Backport
3Signed-off-by: Ross Burton <ross.burton@arm.com>
4
5From 4d65ecbddd16f38a8cf23b3053ca5c3594f8d4a4 Mon Sep 17 00:00:00 2001
6From: Jason Wang <jasowang@redhat.com>
7Date: Tue, 8 Mar 2022 10:42:51 +0800
8Subject: [PATCH 2/2] virtio-net: fix map leaking on error during receive
9
10Commit bedd7e93d0196 ("virtio-net: fix use after unmap/free for sg")
11tries to fix the use after free of the sg by caching the virtqueue
12elements in an array and unmap them at once after receiving the
13packets, But it forgot to unmap the cached elements on error which
14will lead to leaking of mapping and other unexpected results.
15
16Fixing this by detaching the cached elements on error. This addresses
17CVE-2022-26353.
18
19Reported-by: Victor Tom <vv474172261@gmail.com>
20Cc: qemu-stable@nongnu.org
21Fixes: CVE-2022-26353
22Fixes: bedd7e93d0196 ("virtio-net: fix use after unmap/free for sg")
23Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
24Signed-off-by: Jason Wang <jasowang@redhat.com>
25---
26 hw/net/virtio-net.c | 1 +
27 1 file changed, 1 insertion(+)
28
29diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
30index f2014d5ea0..e1f4748831 100644
31--- a/hw/net/virtio-net.c
32+++ b/hw/net/virtio-net.c
33@@ -1862,6 +1862,7 @@ static ssize_t virtio_net_receive_rcu(NetClientState *nc, const uint8_t *buf,
34
35 err:
36 for (j = 0; j < i; j++) {
37+ virtqueue_detach_element(q->rx_vq, elems[j], lens[j]);
38 g_free(elems[j]);
39 }
40
41--
422.25.1
43