Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 1 | CVE: CVE-2021-3544 |
| 2 | Upstream-Status: Backport |
| 3 | Signed-off-by: Ross Burton <ross.burton@arm.com> |
| 4 | |
| 5 | From b9f79858a614d95f5de875d0ca31096eaab72c3b Mon Sep 17 00:00:00 2001 |
| 6 | From: Li Qiang <liq3ea@163.com> |
| 7 | Date: Sat, 15 May 2021 20:03:58 -0700 |
| 8 | Subject: [PATCH 3/7] vhost-user-gpu: fix memory leak in |
| 9 | vg_resource_attach_backing (CVE-2021-3544) |
| 10 | MIME-Version: 1.0 |
| 11 | Content-Type: text/plain; charset=UTF-8 |
| 12 | Content-Transfer-Encoding: 8bit |
| 13 | |
| 14 | Check whether the 'res' has already been attach_backing to avoid |
| 15 | memory leak. |
| 16 | |
| 17 | Fixes: CVE-2021-3544 |
| 18 | Reported-by: Li Qiang <liq3ea@163.com> |
| 19 | virtio-gpu fix: 204f01b309 ("virtio-gpu: fix memory leak |
| 20 | in resource attach backing") |
| 21 | |
| 22 | Signed-off-by: Li Qiang <liq3ea@163.com> |
| 23 | Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> |
| 24 | Message-Id: <20210516030403.107723-4-liq3ea@163.com> |
| 25 | Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> |
| 26 | --- |
| 27 | contrib/vhost-user-gpu/vhost-user-gpu.c | 5 +++++ |
| 28 | 1 file changed, 5 insertions(+) |
| 29 | |
| 30 | diff --git a/contrib/vhost-user-gpu/vhost-user-gpu.c b/contrib/vhost-user-gpu/vhost-user-gpu.c |
| 31 | index b5e153d0d6..0437e52b64 100644 |
| 32 | --- a/contrib/vhost-user-gpu/vhost-user-gpu.c |
| 33 | +++ b/contrib/vhost-user-gpu/vhost-user-gpu.c |
| 34 | @@ -489,6 +489,11 @@ vg_resource_attach_backing(VuGpu *g, |
| 35 | return; |
| 36 | } |
| 37 | |
| 38 | + if (res->iov) { |
| 39 | + cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; |
| 40 | + return; |
| 41 | + } |
| 42 | + |
| 43 | ret = vg_create_mapping_iov(g, &ab, cmd, &res->iov); |
| 44 | if (ret != 0) { |
| 45 | cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; |
| 46 | -- |
| 47 | 2.25.1 |
| 48 | |