All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net,stable] net: qmi_wwan: fix divide by 0 on bad descriptors
@ 2017-11-06 14:32 Bjørn Mork
  2017-11-08  4:44 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Bjørn Mork @ 2017-11-06 14:32 UTC (permalink / raw)
  To: netdev
  Cc: linux-usb, Oliver Neukum, Dmitry Vyukov, Kostya Serebryany,
	syzkaller, Bjørn Mork

A CDC Ethernet functional descriptor with wMaxSegmentSize = 0 will
cause a divide error in usbnet_probe:

divide error: 0000 [#1] PREEMPT SMP KASAN
Modules linked in:
CPU: 0 PID: 24 Comm: kworker/0:1 Not tainted 4.14.0-rc8-44453-g1fdc1a82c34f #56
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
Workqueue: usb_hub_wq hub_event
task: ffff88006bef5c00 task.stack: ffff88006bf60000
RIP: 0010:usbnet_update_max_qlen+0x24d/0x390 drivers/net/usb/usbnet.c:355
RSP: 0018:ffff88006bf67508 EFLAGS: 00010246
RAX: 00000000000163c8 RBX: ffff8800621fce40 RCX: ffff8800621fcf34
RDX: 0000000000000000 RSI: ffffffff837ecb7a RDI: ffff8800621fcf34
RBP: ffff88006bf67520 R08: ffff88006bef5c00 R09: ffffed000c43f881
R10: ffffed000c43f880 R11: ffff8800621fc406 R12: 0000000000000003
R13: ffffffff85c71de0 R14: 0000000000000000 R15: 0000000000000000
FS:  0000000000000000(0000) GS:ffff88006ca00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007ffe9c0d6dac CR3: 00000000614f4000 CR4: 00000000000006f0
Call Trace:
 usbnet_probe+0x18b5/0x2790 drivers/net/usb/usbnet.c:1783
 qmi_wwan_probe+0x133/0x220 drivers/net/usb/qmi_wwan.c:1338
 usb_probe_interface+0x324/0x940 drivers/usb/core/driver.c:361
 really_probe drivers/base/dd.c:413
 driver_probe_device+0x522/0x740 drivers/base/dd.c:557

Fix by simply ignoring the bogus descriptor, as it is optional
for QMI devices anyway.

Fixes: 423ce8caab7e ("net: usb: qmi_wwan: New driver for Huawei QMI based WWAN devices")
Reported-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Bjørn Mork <bjorn@mork.no>
---
 drivers/net/usb/qmi_wwan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index 8c3733608271..a4f229edcceb 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -681,7 +681,7 @@ static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf)
 	}
 
 	/* errors aren't fatal - we can live with the dynamic address */
-	if (cdc_ether) {
+	if (cdc_ether && cdc_ether->wMaxSegmentSize) {
 		dev->hard_mtu = le16_to_cpu(cdc_ether->wMaxSegmentSize);
 		usbnet_get_ethernet_addr(dev, cdc_ether->iMACAddress);
 	}
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net,stable] net: qmi_wwan: fix divide by 0 on bad descriptors
  2017-11-06 14:32 [PATCH net,stable] net: qmi_wwan: fix divide by 0 on bad descriptors Bjørn Mork
@ 2017-11-08  4:44 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2017-11-08  4:44 UTC (permalink / raw)
  To: bjorn; +Cc: netdev, linux-usb, oneukum, dvyukov, kcc, syzkaller

From: Bjørn Mork <bjorn@mork.no>
Date: Mon,  6 Nov 2017 15:32:18 +0100

> A CDC Ethernet functional descriptor with wMaxSegmentSize = 0 will
> cause a divide error in usbnet_probe:
> 
> divide error: 0000 [#1] PREEMPT SMP KASAN
 ...
> Fix by simply ignoring the bogus descriptor, as it is optional
> for QMI devices anyway.
> 
> Fixes: 423ce8caab7e ("net: usb: qmi_wwan: New driver for Huawei QMI based WWAN devices")
> Reported-by: Andrey Konovalov <andreyknvl@google.com>
> Signed-off-by: Bjørn Mork <bjorn@mork.no>

Applied and queued up for -stable.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-11-08  4:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-06 14:32 [PATCH net,stable] net: qmi_wwan: fix divide by 0 on bad descriptors Bjørn Mork
2017-11-08  4:44 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.