Re: [PATCH] usb: xhci: fix potential divide-by-zero in xhci_urb_enqueue()

From: Alan Stern

Date: Sat Jan 10 2026 - 17:08:21 EST


On Sat, Jan 10, 2026 at 01:34:21PM -0500, pip-izony wrote:
> From: Seungjin Bae <eeodqql09@xxxxxxxxx>
>
> The `xhci_urb_enqueue()` validates Bulk OUT transfers by checking if the
> buffer length is a multiple of the packet size. However, it doesn't check
> whether the endpoint's `wMaxPacketSize` is zero before using it as a
> divisor in a modulo operation.
>
> If a malicious USB device sends a descriptor with `wMaxPacketSize` set to
> 0, it triggers a divide-by-zero exception (kernel panic). This allows an
> attacker with physical access to crash the system, leading to a Denial of
> Service.

How did you become aware of this problem?

> Fix this by adding a check to ensure `wMaxPacketSize` is greater than 0
> before performing the modulo operation.

Not necessary. This can never happen, because transfers to or from
endpoints with wMaxPacketSize set to 0 are rejected in usb_submit_urb()
with error code -EMSGSIZE.

Alan Stern