]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
cdc_ncm: fix divide-by-zero caused by invalid wMaxPacketSize
authorBjørn Mork <bjorn@mork.no>
Wed, 18 Sep 2019 12:01:46 +0000 (14:01 +0200)
committerJakub Kicinski <jakub.kicinski@netronome.com>
Sat, 21 Sep 2019 19:06:49 +0000 (12:06 -0700)
Endpoints with zero wMaxPacketSize are not usable for transferring
data. Ignore such endpoints when looking for valid in, out and
status pipes, to make the driver more robust against invalid and
meaningless descriptors.

The wMaxPacketSize of the out pipe is used as divisor. So this change
fixes a divide-by-zero bug.

Reported-by: syzbot+ce366e2b8296e25d84f5@syzkaller.appspotmail.com
Signed-off-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
drivers/net/usb/cdc_ncm.c

index 50c05d0f44cb376276c6ed17f335aeae0180bc80..00cab3f43a4ca3f3e91f1471f5ab189e78d601dc 100644 (file)
@@ -681,8 +681,12 @@ cdc_ncm_find_endpoints(struct usbnet *dev, struct usb_interface *intf)
        u8 ep;
 
        for (ep = 0; ep < intf->cur_altsetting->desc.bNumEndpoints; ep++) {
-
                e = intf->cur_altsetting->endpoint + ep;
+
+               /* ignore endpoints which cannot transfer data */
+               if (!usb_endpoint_maxp(&e->desc))
+                       continue;
+
                switch (e->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) {
                case USB_ENDPOINT_XFER_INT:
                        if (usb_endpoint_dir_in(&e->desc)) {