From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH master] usb: xhci: fix erroneous USB_DT_CONFIG descriptor size
Date: Mon, 5 Aug 2024 17:26:11 +0200 [thread overview]
Message-ID: <20240805152611.3015730-1-a.fatoum@pengutronix.de> (raw)
This bug initially manifested itself as an infinite loop printing the
message:
ERROR: usb2: ifno = 17 > USB_MAXINTERFACES = 16 !
Such a hang could equally happen if actual USB devices besides the root
hub report bogus descriptors. This was fixed by not trusting device-reported
sizes blindly in commit b6a510525e63 ("usb: Use well-known descriptor sizes
when parsing configuration").
The root cause remains though, which is that the xHCI root hub reported
an erroneous size for USB_DT_CONFIG descriptor:
The descriptor size of 0x19 seems to be a copy-paste left-over from
EHCI (USB_DT_CONFIG_SIZE + USB_DT_INTERFACE_SIZE + USB_DT_ENDPOINT_SIZE).
xHCI has an additional USB_DT_SS_EP_COMP_SIZE == 6 for SuperSpeed,
which gets us to 0x19 + 0x6 == 0x1f.
By using 0x19, the memcpy() in xhci_submit_root skipped over the last 6
bytes, but the descriptor itself still had a wTotalLength of 0x1f
leading to a read of 6 uninitialized bytes.
Fix this by using the correct size.
Fixes: 105b2eabd55a ("usb: Add U-Boot xhci driver")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/usb/host/xhci.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index e7b8344181ee..bad247ff9e19 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -903,7 +903,7 @@ static int xhci_submit_root(struct usb_device *udev, unsigned long pipe,
case USB_DT_CONFIG:
dev_dbg(&udev->dev, "USB_DT_CONFIG config\n");
srcptr = &descriptor.config;
- srclen = 0x19;
+ srclen = 0x1f;
break;
case USB_DT_STRING:
dev_dbg(&udev->dev, "USB_DT_STRING config\n");
--
2.39.2
next reply other threads:[~2024-08-05 15:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-05 15:26 Ahmad Fatoum [this message]
2024-08-06 5:56 ` Sascha Hauer
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=20240805152611.3015730-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.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