blob: e70f3c02c268cbd7b51502f300b6664d3076f6f7 [file] [log] [blame]
Andrew Geissler09036742021-06-25 14:25:14 -05001CVE: CVE-2021-3544
2Upstream-Status: Backport
3Signed-off-by: Ross Burton <ross.burton@arm.com>
4
5From f6091d86ba9ea05f4e111b9b42ee0005c37a6779 Mon Sep 17 00:00:00 2001
6From: Li Qiang <liq3ea@163.com>
7Date: Sat, 15 May 2021 20:04:00 -0700
8Subject: [PATCH 5/7] vhost-user-gpu: fix memory leak in
9 'virgl_cmd_resource_unref' (CVE-2021-3544)
10MIME-Version: 1.0
11Content-Type: text/plain; charset=UTF-8
12Content-Transfer-Encoding: 8bit
13
14The 'res->iov' will be leaked if the guest trigger following sequences:
15
16 virgl_cmd_create_resource_2d
17 virgl_resource_attach_backing
18 virgl_cmd_resource_unref
19
20This patch fixes this.
21
22Fixes: CVE-2021-3544
23Reported-by: Li Qiang <liq3ea@163.com>
24virtio-gpu fix: 5e8e3c4c75 ("virtio-gpu: fix resource leak
25in virgl_cmd_resource_unref"
26
27Signed-off-by: Li Qiang <liq3ea@163.com>
28Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
29Message-Id: <20210516030403.107723-6-liq3ea@163.com>
30Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
31---
32 contrib/vhost-user-gpu/virgl.c | 7 +++++++
33 1 file changed, 7 insertions(+)
34
35diff --git a/contrib/vhost-user-gpu/virgl.c b/contrib/vhost-user-gpu/virgl.c
36index 6a332d601f..c669d73a1d 100644
37--- a/contrib/vhost-user-gpu/virgl.c
38+++ b/contrib/vhost-user-gpu/virgl.c
39@@ -108,9 +108,16 @@ virgl_cmd_resource_unref(VuGpu *g,
40 struct virtio_gpu_ctrl_command *cmd)
41 {
42 struct virtio_gpu_resource_unref unref;
43+ struct iovec *res_iovs = NULL;
44+ int num_iovs = 0;
45
46 VUGPU_FILL_CMD(unref);
47
48+ virgl_renderer_resource_detach_iov(unref.resource_id,
49+ &res_iovs,
50+ &num_iovs);
51+ g_free(res_iovs);
52+
53 virgl_renderer_resource_unref(unref.resource_id);
54 }
55
56--
572.25.1
58