From: Shuah Khan <skhan@linuxfoundation.org>
To: Raul E Rangel <rrangel@chromium.org>,
Valentina Manea <valentina.manea.m@gmail.com>,
Shuah Khan <shuah@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Hongren Zheng <i@zenithal.me>,
linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
Anirudh Rayabharam <mail@anirudhrb.com>,
"Brian G. Merrell" <bgmerrell@novell.com>,
Suwan Kim <suwan.kim027@gmail.com>,
Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH 0/6] usbip: vhci_hcd: fix URB giveback leaks and disconnect races
Date: Thu, 12 Nov 2026 15:43:03 -0700 [thread overview]
Message-ID: <c9154293-a804-44a2-9eca-d27d1f6cdb03@linuxfoundation.org> (raw)
In-Reply-To: <20261021150704.3129446-1-rrangel@chromium.org>
On 10/21/26 09:06, Raul E Rangel wrote:
> This series fixes a set of URB lifecycle, locking, and disconnect
> teardown bugs in drivers/usb/usbip/vhci_hcd that can orphan pending URBs
> and wedge usb_kill_urb() and usb_hub_wq in uninterruptible D state when
> a virtual USB port disconnects under concurrent transfer/unlink load.
>
> Patch breakdown:
> 1. Protect urb->hcpriv accesses in vhci_urb_dequeue() with
> vdev->priv_lock inside vhci->lock (matching vhci_urb_enqueue() and
> the cleanup helpers), and add a !portnum || portnum > VHCI_HC_PORTS
> bounds guard to both vhci_urb_enqueue() and vhci_urb_dequeue().
> 2. Track whether an URB has been moved from vdev->priv_tx to
> vdev->priv_rx via priv->submitted under vdev->priv_lock, and
> complete unsent (!priv->submitted) URBs locally in
> vhci_urb_dequeue() instead of queuing a CMD_UNLINK PDU. This
> prevents vhci_device_unlink_cleanup() from freeing the unlink entry
> and orphaning an unsent URB on priv_tx, and prevents CMD_UNLINK
> from being transmitted before CMD_SUBMIT on an active connection.
> 3. Clear vdev->ud.tcp_socket under vhci->lock and vdev->ud.lock in
> vhci_shutdown_connection(), reject vhci_urb_enqueue() once
> USBIP_EH_SHUTDOWN is set or tcp_socket is NULL, and drain all
> remaining URBs on vdev->priv_tx and vdev->priv_rx in
> vhci_device_unlink_cleanup().
> 4. Move the URB_DMA_MAP_SG clearing from vhci_recv_ret_submit() into
> pickup_urb_and_free_priv() and also clear URB_DMA_MAP_SG in
> vhci_urb_dequeue() and vhci_cleanup_priv_list() so USB core does
> not call dma_unmap_sg() on unmapped scatterlists on any giveback
> path.
> 5. Allocate struct vhci_priv with mem_flags before acquiring spinlocks
> in vhci_urb_enqueue(), and return 0 (with VDEV_EVENT_ERROR_MALLOC
> triggered) if struct vhci_unlink allocation fails in
> vhci_urb_dequeue() after usb_hcd_check_unlink_urb() has already
> marked urb->unlinked.
> 6. Serialize vdev->udev clearing in vhci_device_reset() under
> vhci->lock and ud->lock (dropping old usb_device and socket
> references outside the spinlocks in both vhci_device_reset() and
> vhci_urb_enqueue()), and reject URBs from a stale usb_device
> (including address-0 requests from an already-registered
> usb_device undergoing USBDEVFS_RESET) if the same rhport is
> re-attached before usb_hub_wq finishes disconnecting the old
> device.
What problems does this series fix? Do you have reproducers for these?
thanks,
-- Shuah
prev parent reply other threads:[~2026-11-12 22:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 15:06 Raul E Rangel
2026-10-21 15:06 ` [PATCH 1/6] usbip: vhci_hcd: protect urb->hcpriv with priv_lock in vhci_urb_dequeue() Raul E Rangel
2026-10-21 15:06 ` [PATCH 2/6] usbip: vhci_hcd: complete unsent URBs locally " Raul E Rangel
2026-10-21 15:06 ` [PATCH 3/6] usbip: vhci_hcd: stop enqueue and drain all pending URBs on disconnect Raul E Rangel
2026-10-21 15:06 ` [PATCH 4/6] usbip: vhci_hcd: clear URB_DMA_MAP_SG on all giveback paths Raul E Rangel
2026-10-21 15:07 ` [PATCH 5/6] usbip: vhci_hcd: allocate vhci_priv outside lock and handle ENOMEM Raul E Rangel
2026-10-21 15:07 ` [PATCH 6/6] usbip: vhci_hcd: reject URBs from stale usb_device after port re-attach Raul E Rangel
2026-11-12 22:43 ` Shuah Khan [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=c9154293-a804-44a2-9eca-d27d1f6cdb03@linuxfoundation.org \
--to=skhan@linuxfoundation.org \
--cc=bgmerrell@novell.com \
--cc=gregkh@linuxfoundation.org \
--cc=i@zenithal.me \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mail@anirudhrb.com \
--cc=rrangel@chromium.org \
--cc=shuah@kernel.org \
--cc=suwan.kim027@gmail.com \
--cc=valentina.manea.m@gmail.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®