mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 11:26:02 +09:00
usbnet: sanity checking of packet sizes and device mtu
[ Upstream commit 280ceaed79 ]
After a reset packet sizes and device mtu can change and need
to be reevaluated to calculate queue sizes.
Malicious devices can set this to zero and we divide by it.
Introduce sanity checking.
Reported-and-tested-by: syzbot+6102c120be558c885f04@syzkaller.appspotmail.com
Signed-off-by: Oliver Neukum <oneukum@suse.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
@@ -354,6 +354,8 @@ void usbnet_update_max_qlen(struct usbnet *dev)
|
||||
{
|
||||
enum usb_device_speed speed = dev->udev->speed;
|
||||
|
||||
if (!dev->rx_urb_size || !dev->hard_mtu)
|
||||
goto insanity;
|
||||
switch (speed) {
|
||||
case USB_SPEED_HIGH:
|
||||
dev->rx_qlen = MAX_QUEUE_MEMORY / dev->rx_urb_size;
|
||||
@@ -370,6 +372,7 @@ void usbnet_update_max_qlen(struct usbnet *dev)
|
||||
dev->tx_qlen = 5 * MAX_QUEUE_MEMORY / dev->hard_mtu;
|
||||
break;
|
||||
default:
|
||||
insanity:
|
||||
dev->rx_qlen = dev->tx_qlen = 4;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user