Skip to content

usbip: host: ignore number_of_packets for non-isoc URBs - #7572

Open
zjzhao-eda wants to merge 1 commit into
raspberrypi:rpi-6.18.yfrom
edatec:usbip-fix-non-isoc-number_of_packets
Open

usbip: host: ignore number_of_packets for non-isoc URBs#7572
zjzhao-eda wants to merge 1 commit into
raspberrypi:rpi-6.18.yfrom
edatec:usbip-fix-non-isoc-number_of_packets

Conversation

@zjzhao-eda

Copy link
Copy Markdown
Contributor

number_of_packets is only meaningful for isochronous URBs. The USB/IP stub currently copies the value from the CMD_SUBMIT PDU into the local URB verbatim for all endpoint types.

Some clients (e.g. usbip-win) leave number_of_packets uninitialized for non-isoc URBs, so a garbage/huge value reaches usb_submit_urb(). Host controllers that size per-URB allocations by this field (e.g. dwc2's dwc2_hcd_urb_alloc(), which always sizes the iso descriptor array by urb->number_of_packets) then attempt a multi-gigabyte allocation that fails with -ENOMEM, making usbip-host reset the device in an endless loop (older dwc_otg crashes outright instead).

Sanitize number_of_packets to 0 for non-isochronous endpoints in the stub. This is a strict no-op for well-behaved clients (Linux vhci already sends 0 for non-isoc URBs) and fixes the dwc2/dwc_otg failures.

number_of_packets is only meaningful for isochronous URBs.  The USB/IP
stub currently copies the value from the CMD_SUBMIT PDU into the local
URB verbatim for all endpoint types.

Some clients (e.g. usbip-win) leave number_of_packets uninitialized for
non-isoc URBs, so a garbage/huge value reaches usb_submit_urb().  Host
controllers that size per-URB allocations by this field (e.g. dwc2's
dwc2_hcd_urb_alloc(), which always sizes the iso descriptor array by
urb->number_of_packets) then attempt a multi-gigabyte allocation that
fails with -ENOMEM, making usbip-host reset the device in an endless
loop (older dwc_otg crashes outright instead).

Sanitize number_of_packets to 0 for non-isochronous endpoints in the
stub.  This is a strict no-op for well-behaved clients (Linux vhci
already sends 0 for non-isoc URBs) and fixes the dwc2/dwc_otg failures.

Signed-off-by: zjzhao-eda <zjzhao@edatec.cn>
@P33M

P33M commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

This is a bug in unmodified upstream code.

$ ./scripts/get_maintainer.pl drivers/usb/usbip/
Valentina Manea <valentina.manea.m@gmail.com> (maintainer:USB OVER IP DRIVER)
Shuah Khan <shuah@kernel.org> (maintainer:USB OVER IP DRIVER)
Hongren Zheng <i@zenithal.me> (reviewer:USB OVER IP DRIVER)
Greg Kroah-Hartman <gregkh@linuxfoundation.org> (maintainer:USB SUBSYSTEM)
linux-usb@vger.kernel.org (open list:USB OVER IP DRIVER)
linux-kernel@vger.kernel.org (open list)
USB SUBSYSTEM status: Supported

In the first instance you should submit this to the linux-usb list, following their patch submission guidelines.

Once the patch is accepted upstream, we can merge it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants