Skip to contentSkip to conversation

usb: Check USB_TOKEN_SETUP in usb_ep_get(CVE-2024-8354)

PATCH New Madhu Marri 1 participant 1 message Feb 13, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: Check USB_TOKEN_SETUP in usb_ep_get(CVE-2024-8354)

USB_TOKEN_SETUP packet not being handled in usb_ep_get function. This causes the program to hit the assertion that checks for only USB_TOKEN_IN or USB_TOKEN_OUT, leading to the failure and core dump when the USB_TOKEN_SETUP packet is processed.

Added a check for USB_TOKEN_SETUP to avoid triggering an assertion failure and crash.

Fixes: CVE-2024-8354
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2548

---
 hw/usb/core.c | 6 ++++++
 1 file changed, 6 insertions(+)
hw/usb/core.c +6 -0
index 975f76250a..df2aec5aca 100644
@@ -741,6 +741,12 @@ struct USBEndpoint *usb_ep_get(USBDevice *dev, int pid, int ep)
     if (ep == 0) {
         return &dev->ep_ctl;
     }
+
+    if (pid == USB_TOKEN_SETUP) {
+        /* Do not handle setup packets here */
+        return &dev->ep_ctl;
+    }
+
     assert(pid == USB_TOKEN_IN || pid == USB_TOKEN_OUT);
     assert(ep > 0 && ep <= USB_MAX_ENDPOINTS);
     eps = (pid == USB_TOKEN_IN) ? dev->ep_in : dev->ep_out;
Signature · 1 line
2.44.1