sr9700: sanity check for packet length
authorOliver Neukum <oneukum@suse.com>
Thu, 17 Feb 2022 13:10:44 +0000 (14:10 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 2 Mar 2022 10:32:00 +0000 (11:32 +0100)
commit e9da0b56fe27206b49f39805f7dcda8a89379062 upstream.

A malicious device can leak heap data to user space
providing bogus frame lengths. Introduce a sanity check.

Signed-off-by: Oliver Neukum <oneukum@suse.com>
Reviewed-by: Grant Grundler <grundler@chromium.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/usb/sr9700.c

index aadfe1d1c37ee67e2a7d17c759db12dad248c41d..f4c4df01874c3813e5db6ce6b07ed6aecf703fd1 100644 (file)
@@ -409,7 +409,7 @@ static int sr9700_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
                /* ignore the CRC length */
                len = (skb->data[1] | (skb->data[2] << 8)) - 4;
 
-               if (len > ETH_FRAME_LEN)
+               if (len > ETH_FRAME_LEN || len > skb->len)
                        return 0;
 
                /* the last packet of current skb */