CVE-2021-3527-2.patch 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. From 7ec54f9eb62b5d177e30eb8b1cad795a5f8d8986 Mon Sep 17 00:00:00 2001
  2. From: Gerd Hoffmann <kraxel@redhat.com>
  3. Date: Mon, 3 May 2021 15:29:12 +0200
  4. Subject: [PATCH] usb/redir: avoid dynamic stack allocation (CVE-2021-3527)
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. Use autofree heap allocation instead.
  9. Fixes: 4f4321c11ff ("usb: use iovecs in USBPacket")
  10. Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
  11. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
  12. Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
  13. Message-Id: <20210503132915.2335822-3-kraxel@redhat.com>
  14. Upstream-Status: Backport
  15. https://gitlab.com/qemu-project/qemu/-/commit/7ec54f9eb62b5d177e30eb8b1cad795a5f8d8986
  16. CVE: CVE-2021-3527
  17. Signed-off-by: Chee Yang Lee <chee.yang.lee@intel.com>
  18. ---
  19. hw/usb/redirect.c | 6 +++---
  20. 1 file changed, 3 insertions(+), 3 deletions(-)
  21. diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
  22. index 17f06f3417..6a75b0dc4a 100644
  23. --- a/hw/usb/redirect.c
  24. +++ b/hw/usb/redirect.c
  25. @@ -620,7 +620,7 @@ static void usbredir_handle_iso_data(USBRedirDevice *dev, USBPacket *p,
  26. .endpoint = ep,
  27. .length = p->iov.size
  28. };
  29. - uint8_t buf[p->iov.size];
  30. + g_autofree uint8_t *buf = g_malloc(p->iov.size);
  31. /* No id, we look at the ep when receiving a status back */
  32. usb_packet_copy(p, buf, p->iov.size);
  33. usbredirparser_send_iso_packet(dev->parser, 0, &iso_packet,
  34. @@ -818,7 +818,7 @@ static void usbredir_handle_bulk_data(USBRedirDevice *dev, USBPacket *p,
  35. usbredirparser_send_bulk_packet(dev->parser, p->id,
  36. &bulk_packet, NULL, 0);
  37. } else {
  38. - uint8_t buf[size];
  39. + g_autofree uint8_t *buf = g_malloc(size);
  40. usb_packet_copy(p, buf, size);
  41. usbredir_log_data(dev, "bulk data out:", buf, size);
  42. usbredirparser_send_bulk_packet(dev->parser, p->id,
  43. @@ -923,7 +923,7 @@ static void usbredir_handle_interrupt_out_data(USBRedirDevice *dev,
  44. USBPacket *p, uint8_t ep)
  45. {
  46. struct usb_redir_interrupt_packet_header interrupt_packet;
  47. - uint8_t buf[p->iov.size];
  48. + g_autofree uint8_t *buf = g_malloc(p->iov.size);
  49. DPRINTF("interrupt-out ep %02X len %zd id %"PRIu64"\n", ep,
  50. p->iov.size, p->id);
  51. --
  52. GitLab