From: Jenny Guanni Qu <qguanni@gmail.com>
To: qemu-devel@nongnu.org
Cc: berrange@redhat.com, mcascell@redhat.com,
peter.maydell@linaro.org, qemu-security@nongnu.org,
Jenny Guanni Qu <qguanni@gmail.com>
Subject: [PATCH v2] hw/usb/hcd-ohci: check for MPS=0 to avoid infinite loop
Date: Sat, 21 Mar 2026 00:04:44 +0000 [thread overview]
Message-ID: <20260321000444.909451-1-qguanni@gmail.com> (raw)
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
next reply other threads:[~2026-03-21 0:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-21 0:04 Jenny Guanni Qu [this message]
2026-03-21 17:43 ` [PATCH v2] hw/usb/hcd-ohci: check for MPS=0 to avoid infinite loop Peter Maydell
2026-03-24 14:40 ` Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260321000444.909451-1-qguanni@gmail.com \
--to=qguanni@gmail.com \
--cc=berrange@redhat.com \
--cc=mcascell@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-security@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox