hw/usb/hcd-ohci: check for MPS=0 to avoid infinite loop
PATCH v2 1/1 hw/usb/hcd-ohci: check for MPS=0 to avoid infinite loop
When a guest sets MaxPacketSize to 0 in an OHCI Endpoint Descriptor, ohci_service_td() transfers 0 bytes per iteration. The Transfer Descriptor never completes because CBP never advances toward BE, causing ohci_service_ed_list() to loop indefinitely and hang QEMU.
Add a check for MPS==0 after extracting the field from ED flags. If MPS is zero, call ohci_die() to reset the controller and return an error, preventing the infinite loop.
--- hw/usb/hcd-ohci.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
hw/usb/hcd-ohci.c +11 -0
@@ -956,6 +956,17 @@ static int ohci_service_td(OHCIState *ohci, struct ohci_ed *ed)if (len && dir !=OHCI_TD_DIR_IN ) {/* The endpoint may not allow us to transfer it all now */ pktlen = (ed->flags &OHCI_ED_MPS_MASK ) >>OHCI_ED_MPS_SHIFT ; +/* +* The OHCI spec does not say what to do if the guest hands us +* an endpoint descriptor which specifies a MaximumPacketSize +* of zero, which would mean we can never actually make forward +* progress transferring data to it. We choose to treat it as +* an error. +*/ +if (pktlen ==0 ) { +ohci_die (ohci); +return 1 ; + }if (pktlen > len) { pktlen = len; }
Signature · 1 line
2.34.1
Quoted 6 lines · Jenny Guanni Qu
When a guest sets MaxPacketSize to 0 in an OHCI Endpoint Descriptor,
ohci_service_td()transfers 0 bytes per iteration. The Transfer Descriptor never completes because CBP never advances toward BE, causingohci_service_ed_list()to loop indefinitely and hang QEMU.
Quoted 8 lines
Add a check for MPS==0 after extracting the field from ED flags. If MPS is zero, call
ohci_die()to reset the controller and return an error, preventing the infinite loop.Fixes CVE-2026-3890Reported-by Jenny Guanni Qu <[email protected]>Signed-off-by Jenny Guanni Qu <[email protected]>---
Quoted 9 lines · Jenny Guanni Qu
When a guest sets MaxPacketSize to 0 in an OHCI Endpoint Descriptor,
ohci_service_td()transfers 0 bytes per iteration. The Transfer Descriptor never completes because CBP never advances toward BE, causingohci_service_ed_list()to loop indefinitely and hang QEMU.Add a check for MPS==0 after extracting the field from ED flags. If MPS is zero, call
ohci_die()to reset the controller and return an error, preventing the infinite loop.
Quoted 6 lines
Fixes CVE-2026-3890Reported-by Jenny Guanni Qu <[email protected]>Signed-off-by Jenny Guanni Qu <[email protected]>--- hw/usb/hcd-ohci.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
Merged as commit 129922c2bc398b656a9180150e667f98fdf0d402, thanks.