mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alan Stern <stern@rowland.harvard.edu>
To: Artem Dinaburg <artem@trailofbits.com>
Cc: mathias.nyman@intel.com, gregkh@linuxfoundation.org,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] usb: xhci: reject bulk transfers beyond mapped scatterlists
Date: Tue, 1 Dec 2026 15:43:27 -0500	[thread overview]
Message-ID: <c6093548-fa5e-4869-8847-68f00eae4607@rowland.harvard.edu> (raw)
In-Reply-To: <20261201202438.32470.9674.04-xhci-sg-length-patch@trailofbits.com>

On Tue, Dec 01, 2026 at 03:24:40PM -0500, Artem Dinaburg wrote:
> A bulk or interrupt URB can request more bytes than its mapped
> scatterlist covers. count_sg_trbs_needed() counts only the mapped
> entries, but xhci_queue_bulk_tx() queues TRBs until the requested length
> is reached. After the final entry it continues from the last DMA address
> and length, so the controller transfers data outside the mapping.
> 
> A USB device can cause this mismatch.
> 
> Reject the mismatch in the existing counting pass, before
> prepare_transfer() changes the ring. This also rejects an SG URB with no
> mapped entries.

Why are you trying to fix this by modifying the xhci-hcd driver?  In 
theory the same thing could happen to any HCD.

This possible error should be handled in the USB core, in 
usb_submit_urb().  That routine already has a section specifically for 
checking transfers that use scatter-gather; it's the perfect place to 
add your check.

Alan Stern

  reply	other threads:[~2026-12-01 20:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 20:24 Artem Dinaburg
2026-12-01 20:43 ` Alan Stern [this message]
2026-12-01 20:54   ` Artem Dinaburg
2026-12-01 21:45 ` Michal Pecio
2026-12-02  2:24   ` Artem Dinaburg

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=c6093548-fa5e-4869-8847-68f00eae4607@rowland.harvard.edu \
    --to=stern@rowland.harvard.edu \
    --cc=artem@trailofbits.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    /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®