Skip to contentSkip to conversation

usb/hcd-xhci: check slotid in xhci_wakeup_endpoint()

PATCH New Mauro Matteo Cascella 1 participant 1 message Jul 5, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb/hcd-xhci: check slotid in xhci_wakeup_endpoint()

This prevents an OOB read (followed by an assertion failure in xhci_kick_ep) when slotid > xhci->numslots.

---
 hw/usb/hcd-xhci.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/usb/hcd-xhci.c +2 -1
index 0cd0a5e540..cecf8a0d96 100644
@@ -3269,7 +3269,8 @@ static void xhci_wakeup_endpoint(USBBus *bus, USBEndpoint *ep,
 
     DPRINTF("%s\n", __func__);
     slotid = ep->dev->addr;
-    if (slotid == 0 || !xhci->slots[slotid-1].enabled) {
+    if (slotid == 0 || slotid > xhci->numslots ||
+        !xhci->slots[slotid-1].enabled) {
         DPRINTF("%s: oops, no slot for dev %d\n", __func__, ep->dev->addr);
         return;
     }
Signature · 1 line
2.35.3