usb/hcd-xhci: check slotid in xhci_wakeup_endpoint()
authorMauro Matteo Cascella <mcascell@redhat.com>
Tue, 5 Jul 2022 17:47:34 +0000 (19:47 +0200)
committerGerd Hoffmann <kraxel@redhat.com>
Tue, 19 Jul 2022 12:36:38 +0000 (14:36 +0200)
This prevents an OOB read (followed by an assertion failure in
xhci_kick_ep) when slotid > xhci->numslots.

Reported-by: Soul Chen <soulchen8650@gmail.com>
Signed-off-by: Mauro Matteo Cascella <mcascell@redhat.com>
Message-Id: <20220705174734.2348829-1-mcascell@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
hw/usb/hcd-xhci.c

index 0cd0a5e540272a4183176ce8426d0f461349d9ff..296cc6c8e69498185b332baee63bae02aa9d421d 100644 (file)
@@ -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;
     }