Commit 280ceaed authored by Oliver Neukum's avatar Oliver Neukum Committed by David S. Miller

usbnet: sanity checking of packet sizes and device mtu

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: default avatarOliver Neukum <oneukum@suse.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b41dae06
...@@ -339,6 +339,8 @@ void usbnet_update_max_qlen(struct usbnet *dev) ...@@ -339,6 +339,8 @@ void usbnet_update_max_qlen(struct usbnet *dev)
{ {
enum usb_device_speed speed = dev->udev->speed; enum usb_device_speed speed = dev->udev->speed;
if (!dev->rx_urb_size || !dev->hard_mtu)
goto insanity;
switch (speed) { switch (speed) {
case USB_SPEED_HIGH: case USB_SPEED_HIGH:
dev->rx_qlen = MAX_QUEUE_MEMORY / dev->rx_urb_size; dev->rx_qlen = MAX_QUEUE_MEMORY / dev->rx_urb_size;
...@@ -355,6 +357,7 @@ void usbnet_update_max_qlen(struct usbnet *dev) ...@@ -355,6 +357,7 @@ void usbnet_update_max_qlen(struct usbnet *dev)
dev->tx_qlen = 5 * MAX_QUEUE_MEMORY / dev->hard_mtu; dev->tx_qlen = 5 * MAX_QUEUE_MEMORY / dev->hard_mtu;
break; break;
default: default:
insanity:
dev->rx_qlen = dev->tx_qlen = 4; dev->rx_qlen = dev->tx_qlen = 4;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment