CVE-2021-3527-1.patch 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. From 05a40b172e4d691371534828078be47e7fff524c Mon Sep 17 00:00:00 2001
  2. From: Gerd Hoffmann <kraxel@redhat.com>
  3. Date: Mon, 3 May 2021 15:29:15 +0200
  4. Subject: [PATCH] usb: limit combined packets to 1 MiB (CVE-2021-3527)
  5. usb-host and usb-redirect try to batch bulk transfers by combining many
  6. small usb packets into a single, large transfer request, to reduce the
  7. overhead and improve performance.
  8. This patch adds a size limit of 1 MiB for those combined packets to
  9. restrict the host resources the guest can bind that way.
  10. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
  11. Message-Id: <20210503132915.2335822-6-kraxel@redhat.com>
  12. Upstream-Status: Backport
  13. https://gitlab.com/qemu-project/qemu/-/commit/05a40b172e4d691371534828078be47e7fff524c
  14. CVE: CVE-2021-3527
  15. Signed-off-by: Chee Yang Lee <chee.yang.lee@intel.com>
  16. ---
  17. hw/usb/combined-packet.c | 4 +++-
  18. 1 file changed, 3 insertions(+), 1 deletion(-)
  19. diff --git a/hw/usb/combined-packet.c b/hw/usb/combined-packet.c
  20. index 5d57e883dc..e56802f89a 100644
  21. --- a/hw/usb/combined-packet.c
  22. +++ b/hw/usb/combined-packet.c
  23. @@ -171,7 +171,9 @@ void usb_ep_combine_input_packets(USBEndpoint *ep)
  24. if ((p->iov.size % ep->max_packet_size) != 0 || !p->short_not_ok ||
  25. next == NULL ||
  26. /* Work around for Linux usbfs bulk splitting + migration */
  27. - (totalsize == (16 * KiB - 36) && p->int_req)) {
  28. + (totalsize == (16 * KiB - 36) && p->int_req) ||
  29. + /* Next package may grow combined package over 1MiB */
  30. + totalsize > 1 * MiB - ep->max_packet_size) {
  31. usb_device_handle_data(ep->dev, first);
  32. assert(first->status == USB_RET_ASYNC);
  33. if (first->combined) {
  34. --
  35. GitLab