Re: [PATCH net] net: usb: smsc75xx: reject frames shorter than the FCS

From: Andrew Lunn

Date: Tue Nov 10 2026 - 17:43:39 EST


On Tue, Nov 10, 2026 at 09:03:21AM +0000, Joas Antonio dos Santos via B4 Relay wrote:
> From: Joas Antonio dos Santos <joasantonio108@xxxxxxxxx>
>
> smsc75xx_rx_fixup() takes the frame length from the RX command word
> supplied by the device and strips the FCS by using "size - 4" for the
> allocation, skb_put() and memcpy() of each frame that is not the last
> one in the URB. The length is only checked against an upper bound and
> against skb->len, so a device can report a length field of 2..5, which
> gives a size of 0..3 after RXW_PADDING is subtracted.
>
> size is a u32, so "size - 4" then wraps to 0xfffffffc..0xffffffff.
> __netdev_alloc_skb() adds NET_SKB_PAD to the unsigned length, which
> wraps back to a small value and the allocation succeeds. skb_put()
> adds the length to the 32-bit skb->tail and skb->len, which also wrap,
> so the skb_over_panic() check does not fire. The following memcpy()
> then tries to copy almost 4 GiB from the URB buffer into that small
> allocation and writes far beyond it.
>
> A malicious or malfunctioning USB device can use this to corrupt
> kernel memory or crash the machine.
>
> Reject frames that are too short to hold an FCS, as lan78xx_rx() does.

I assume there is soon going to be another check to ensure the frame
is big enough to have an ethernet header? Can these checks be
combined?

Andrew