Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame^] | 1 | CVE: CVE-2021-3546 |
| 2 | Upstream-Status: Backport |
| 3 | Signed-off-by: Ross Burton <ross.burton@arm.com> |
| 4 | |
| 5 | From 9f22893adcb02580aee5968f32baa2cd109b3ec2 Mon Sep 17 00:00:00 2001 |
| 6 | From: Li Qiang <liq3ea@163.com> |
| 7 | Date: Sat, 15 May 2021 20:04:02 -0700 |
| 8 | Subject: [PATCH 7/7] vhost-user-gpu: fix OOB write in 'virgl_cmd_get_capset' |
| 9 | (CVE-2021-3546) |
| 10 | MIME-Version: 1.0 |
| 11 | Content-Type: text/plain; charset=UTF-8 |
| 12 | Content-Transfer-Encoding: 8bit |
| 13 | |
| 14 | If 'virgl_cmd_get_capset' set 'max_size' to 0, |
| 15 | the 'virgl_renderer_fill_caps' will write the data after the 'resp'. |
| 16 | This patch avoid this by checking the returned 'max_size'. |
| 17 | |
| 18 | virtio-gpu fix: abd7f08b23 ("display: virtio-gpu-3d: check |
| 19 | virgl capabilities max_size") |
| 20 | |
| 21 | Fixes: CVE-2021-3546 |
| 22 | Reported-by: Li Qiang <liq3ea@163.com> |
| 23 | Reviewed-by: Prasad J Pandit <pjp@fedoraproject.org> |
| 24 | Signed-off-by: Li Qiang <liq3ea@163.com> |
| 25 | Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> |
| 26 | Message-Id: <20210516030403.107723-8-liq3ea@163.com> |
| 27 | Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> |
| 28 | --- |
| 29 | contrib/vhost-user-gpu/virgl.c | 4 ++++ |
| 30 | 1 file changed, 4 insertions(+) |
| 31 | |
| 32 | diff --git a/contrib/vhost-user-gpu/virgl.c b/contrib/vhost-user-gpu/virgl.c |
| 33 | index 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 | -- |
| 48 | 2.25.1 |
| 49 | |