mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Cheng Yongkang <teel4res@gmail.com>
To: Mathias Nyman <mathias.nyman@intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Alan Stern <stern@rowland.harvard.edu>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] usb: core: use the clamped bMaxBurst and Mult for the wBytesPerInterval check
Date: Mon, 16 Nov 2026 19:43:11 -0800	[thread overview]
Message-ID: <20261117034311.538314-1-teel4res@gmail.com> (raw)
In-Reply-To: <77330361-136e-4e26-b5ac-9c4259f90978@rowland.harvard.edu>

usb_parse_ss_endpoint_companion() clamps bMaxBurst to 15 and the isoc
Mult to 3 in ep->ss_ep_comp, but then computes max_tx for the
wBytesPerInterval check from the original descriptor. A device with an
invalid bMaxBurst or Mult can then keep a wBytesPerInterval that the
clamped endpoint cannot carry.

With wMaxPacketSize 1024, bMaxBurst 16 and Mult 1, bMaxBurst becomes 15
but wBytesPerInterval is limited to 17408 instead of 16384.
usb_submit_urb() uses the clamped values and rejects isoc frames above
16384, while usb_endpoint_max_periodic_payload() returns 17408, which
xHCI uses as the Max ESIT Payload. The same endpoint context gets a Max
Burst of 15, so the two fields disagree.

The rest of the code treats ep->ss_ep_comp as the sanitized copy of the
descriptor. usb_parse_endpoint() checks and fixes ep->desc the same
way, and everything after parsing, including usb_submit_urb(),
usb_endpoint_max_periodic_payload() and xHCI, reads only these copies.
max_tx itself already takes wMaxPacketSize from ep->desc. Before commit
842f16905dfc ("USB: remove the usb_host_ss_ep_comp structure"), the
clamps modified the descriptor in place, so max_tx was computed from
the clamped values. That commit moved the clamps to the copy but left
max_tx reading the original descriptor.

Compute max_tx from ep->ss_ep_comp.

Fixes: 842f16905dfc ("USB: remove the usb_host_ss_ep_comp structure")
Signed-off-by: Cheng Yongkang <teel4res@gmail.com>
---
Report: https://lore.kernel.org/linux-usb/20261115163701.226491-1-teel4res@gmail.com/

 drivers/usb/core/config.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index 0e79b7f8a73d..2f031ea6a437 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -170,12 +170,12 @@ static void usb_parse_ss_endpoint_companion(struct device *ddev, int cfgno,
 	}
 
 	if (usb_endpoint_xfer_isoc(&ep->desc))
-		max_tx = (desc->bMaxBurst + 1) *
-			(USB_SS_MULT(desc->bmAttributes)) *
+		max_tx = (ep->ss_ep_comp.bMaxBurst + 1) *
+			(USB_SS_MULT(ep->ss_ep_comp.bmAttributes)) *
 			usb_endpoint_maxp(&ep->desc);
 	else if (usb_endpoint_xfer_int(&ep->desc))
 		max_tx = usb_endpoint_maxp(&ep->desc) *
-			(desc->bMaxBurst + 1);
+			(ep->ss_ep_comp.bMaxBurst + 1);
 	else
 		max_tx = 999999;
 	/*

base-commit: 3149e8b3237f58d4dd440fc64c45c93404c4b064
-- 
2.34.1


      reply	other threads:[~2026-11-17  3:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-15 16:37 [BUG] usb: core: wBytesPerInterval checked with unsanitized bMaxBurst Cheng Yongkang
2026-11-16 18:51 ` Alan Stern
2026-11-17  3:43   ` Cheng Yongkang [this message]

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=20261117034311.538314-1-teel4res@gmail.com \
    --to=teel4res@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    --cc=stern@rowland.harvard.edu \
    /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

all inboxes | Powered by JetHome®