public inbox for qemu-devel@nongnu.org
 help / color / mirror / Atom feed
* [PATCH v2] hw/usb/hcd-ohci: check for MPS=0 to avoid infinite loop
@ 2026-03-21  0:04 Jenny Guanni Qu
  2026-03-21 17:43 ` Peter Maydell
  2026-03-24 14:40 ` Philippe Mathieu-Daudé
  0 siblings, 2 replies; 3+ messages in thread
From: Jenny Guanni Qu @ 2026-03-21  0:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: berrange, mcascell, peter.maydell, qemu-security, 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,
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.

Fixes: CVE-2026-3890
Reported-by: Jenny Guanni Qu <qguanni@gmail.com>
Signed-off-by: Jenny Guanni Qu <qguanni@gmail.com>
---
 hw/usb/hcd-ohci.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
index 1aeed9286f..6ed8046fc2 100644
--- a/hw/usb/hcd-ohci.c
+++ b/hw/usb/hcd-ohci.c
@@ -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;
             }
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] hw/usb/hcd-ohci: check for MPS=0 to avoid infinite loop
  2026-03-21  0:04 [PATCH v2] hw/usb/hcd-ohci: check for MPS=0 to avoid infinite loop Jenny Guanni Qu
@ 2026-03-21 17:43 ` Peter Maydell
  2026-03-24 14:40 ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2026-03-21 17:43 UTC (permalink / raw)
  To: Jenny Guanni Qu; +Cc: qemu-devel, berrange, mcascell, qemu-security

On Sat, 21 Mar 2026 at 00:04, Jenny Guanni Qu <qguanni@gmail.com> wrote:
>
> 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.
>
> Fixes: CVE-2026-3890
> Reported-by: Jenny Guanni Qu <qguanni@gmail.com>
> Signed-off-by: Jenny Guanni Qu <qguanni@gmail.com>
> ---


Reviewed-by: Peter Maydell <peter.maydell@linaro.org>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] hw/usb/hcd-ohci: check for MPS=0 to avoid infinite loop
  2026-03-21  0:04 [PATCH v2] hw/usb/hcd-ohci: check for MPS=0 to avoid infinite loop Jenny Guanni Qu
  2026-03-21 17:43 ` Peter Maydell
@ 2026-03-24 14:40 ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-03-24 14:40 UTC (permalink / raw)
  To: Jenny Guanni Qu, qemu-devel
  Cc: berrange, mcascell, peter.maydell, qemu-security

On 21/3/26 01:04, Jenny Guanni Qu wrote:
> 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.
> 
> Fixes: CVE-2026-3890
> Reported-by: Jenny Guanni Qu <qguanni@gmail.com>
> Signed-off-by: Jenny Guanni Qu <qguanni@gmail.com>
> ---
>   hw/usb/hcd-ohci.c | 11 +++++++++++
>   1 file changed, 11 insertions(+)
Merged as commit 129922c2bc398b656a9180150e667f98fdf0d402, thanks.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-03-24 14:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-21  0:04 [PATCH v2] hw/usb/hcd-ohci: check for MPS=0 to avoid infinite loop Jenny Guanni Qu
2026-03-21 17:43 ` Peter Maydell
2026-03-24 14:40 ` Philippe Mathieu-Daudé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox