0004-vhost-user-gpu-fix-memory-leak-while-calling-vg_reso.patch 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. CVE: CVE-2021-3544
  2. Upstream-Status: Backport
  3. Signed-off-by: Ross Burton <ross.burton@arm.com>
  4. From b7afebcf9e6ecf3cf9b5a9b9b731ed04bca6aa3e Mon Sep 17 00:00:00 2001
  5. From: Li Qiang <liq3ea@163.com>
  6. Date: Sat, 15 May 2021 20:03:59 -0700
  7. Subject: [PATCH 4/7] vhost-user-gpu: fix memory leak while calling
  8. 'vg_resource_unref' (CVE-2021-3544)
  9. MIME-Version: 1.0
  10. Content-Type: text/plain; charset=UTF-8
  11. Content-Transfer-Encoding: 8bit
  12. If the guest trigger following sequences, the attach_backing will be leaked:
  13. vg_resource_create_2d
  14. vg_resource_attach_backing
  15. vg_resource_unref
  16. This patch fix this by freeing 'res->iov' in vg_resource_destroy.
  17. Fixes: CVE-2021-3544
  18. Reported-by: Li Qiang <liq3ea@163.com>
  19. virtio-gpu fix: 5e8e3c4c75 ("virtio-gpu: fix resource leak
  20. in virgl_cmd_resource_unref")
  21. Reviewed-by: Prasad J Pandit <pjp@fedoraproject.org>
  22. Signed-off-by: Li Qiang <liq3ea@163.com>
  23. Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
  24. Message-Id: <20210516030403.107723-5-liq3ea@163.com>
  25. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
  26. ---
  27. contrib/vhost-user-gpu/vhost-user-gpu.c | 1 +
  28. 1 file changed, 1 insertion(+)
  29. diff --git a/contrib/vhost-user-gpu/vhost-user-gpu.c b/contrib/vhost-user-gpu/vhost-user-gpu.c
  30. index 0437e52b64..770dfad529 100644
  31. --- a/contrib/vhost-user-gpu/vhost-user-gpu.c
  32. +++ b/contrib/vhost-user-gpu/vhost-user-gpu.c
  33. @@ -400,6 +400,7 @@ vg_resource_destroy(VuGpu *g,
  34. }
  35. vugbm_buffer_destroy(&res->buffer);
  36. + g_free(res->iov);
  37. pixman_image_unref(res->image);
  38. QTAILQ_REMOVE(&g->reslist, res, next);
  39. g_free(res);
  40. --
  41. 2.25.1