0003-vhost-user-gpu-fix-memory-leak-in-vg_resource_attach.patch 1.5 KB

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