usbnet: sanity checking of packet sizes and device mtu
Oliver Neukum
maintainerPATCH 1/1 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 [email protected]
Signed-off-by Oliver Neukum <[email protected]>
--- drivers/net/usb/usbnet.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/usb/usbnet.c +3 -0
@@ -339,6 +339,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;
@@ -355,6 +357,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 ; } }
Signature · 1 line
2.16.4
David Miller
maintainerFrom: Oliver Neukum <[email protected]>
Date: Thu, 19 Sep 2019 10:23:08 +0200
Quoted 7 lines
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 [email protected]Signed-off-by Oliver Neukum <[email protected]>
Applied and queued up for -stable.