blob: 33e6a661938ca53dfd96eedc9b16d88f944fcab9 [file] [log] [blame]
Andrew Geissler09036742021-06-25 14:25:14 -05001CVE: CVE-2021-3546
2Upstream-Status: Backport
3Signed-off-by: Ross Burton <ross.burton@arm.com>
4
5From 9f22893adcb02580aee5968f32baa2cd109b3ec2 Mon Sep 17 00:00:00 2001
6From: Li Qiang <liq3ea@163.com>
7Date: Sat, 15 May 2021 20:04:02 -0700
8Subject: [PATCH 7/7] vhost-user-gpu: fix OOB write in 'virgl_cmd_get_capset'
9 (CVE-2021-3546)
10MIME-Version: 1.0
11Content-Type: text/plain; charset=UTF-8
12Content-Transfer-Encoding: 8bit
13
14If 'virgl_cmd_get_capset' set 'max_size' to 0,
15the 'virgl_renderer_fill_caps' will write the data after the 'resp'.
16This patch avoid this by checking the returned 'max_size'.
17
18virtio-gpu fix: abd7f08b23 ("display: virtio-gpu-3d: check
19virgl capabilities max_size")
20
21Fixes: CVE-2021-3546
22Reported-by: Li Qiang <liq3ea@163.com>
23Reviewed-by: Prasad J Pandit <pjp@fedoraproject.org>
24Signed-off-by: Li Qiang <liq3ea@163.com>
25Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
26Message-Id: <20210516030403.107723-8-liq3ea@163.com>
27Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
28---
29 contrib/vhost-user-gpu/virgl.c | 4 ++++
30 1 file changed, 4 insertions(+)
31
32diff --git a/contrib/vhost-user-gpu/virgl.c b/contrib/vhost-user-gpu/virgl.c
33index a16a311d80..7172104b19 100644
34--- a/contrib/vhost-user-gpu/virgl.c
35+++ b/contrib/vhost-user-gpu/virgl.c
36@@ -177,6 +177,10 @@ virgl_cmd_get_capset(VuGpu *g,
37
38 virgl_renderer_get_cap_set(gc.capset_id, &max_ver,
39 &max_size);
40+ if (!max_size) {
41+ cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER;
42+ return;
43+ }
44 resp = g_malloc0(sizeof(*resp) + max_size);
45
46 resp->hdr.type = VIRTIO_GPU_RESP_OK_CAPSET;
47--
482.25.1
49