qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb/hcd-xhci: check slotid in xhci_wakeup_endpoint()
@ 2022-07-05 17:47 Mauro Matteo Cascella
  0 siblings, 0 replies; only message in thread
From: Mauro Matteo Cascella @ 2022-07-05 17:47 UTC (permalink / raw)
  To: qemu-devel; +Cc: mcascell, soulchen8650, kraxel

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>
---
 hw/usb/hcd-xhci.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index 0cd0a5e540..cecf8a0d96 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -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;
     }
-- 
2.35.3



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-07-05 17:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-05 17:47 [PATCH] usb/hcd-xhci: check slotid in xhci_wakeup_endpoint() Mauro Matteo Cascella

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).