* [PATCH net,stable] cdc_ncm: fix divide-by-zero caused by invalid wMaxPacketSize
@ 2019-09-18 12:01 Bjørn Mork
2019-09-18 12:26 ` divide error in cdc_ncm_update_rxtx_max syzbot
2019-09-21 19:30 ` [PATCH net,stable] cdc_ncm: fix divide-by-zero caused by invalid wMaxPacketSize Jakub Kicinski
0 siblings, 2 replies; 3+ messages in thread
From: Bjørn Mork @ 2019-09-18 12:01 UTC (permalink / raw)
To: netdev
Cc: linux-usb, Oliver Neukum, Bjørn Mork, syzbot+ce366e2b8296e25d84f5
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>
---
#syz test: https://github.com/google/kasan.git f0df5c1b
drivers/net/usb/cdc_ncm.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 50c05d0f44cb..00cab3f43a4c 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -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)) {
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: divide error in cdc_ncm_update_rxtx_max
2019-09-18 12:01 [PATCH net,stable] cdc_ncm: fix divide-by-zero caused by invalid wMaxPacketSize Bjørn Mork
@ 2019-09-18 12:26 ` syzbot
2019-09-21 19:30 ` [PATCH net,stable] cdc_ncm: fix divide-by-zero caused by invalid wMaxPacketSize Jakub Kicinski
1 sibling, 0 replies; 3+ messages in thread
From: syzbot @ 2019-09-18 12:26 UTC (permalink / raw)
To: bjorn, linux-usb, netdev, oliver, syzkaller-bugs
Hello,
syzbot has tested the proposed patch and the reproducer did not trigger
crash:
Reported-and-tested-by:
syzbot+ce366e2b8296e25d84f5@syzkaller.appspotmail.com
Tested on:
commit: f0df5c1b usb-fuzzer: main usb gadget fuzzer driver
git tree: https://github.com/google/kasan.git
kernel config: https://syzkaller.appspot.com/x/.config?x=5c6633fa4ed00be5
dashboard link: https://syzkaller.appspot.com/bug?extid=ce366e2b8296e25d84f5
compiler: gcc (GCC) 9.0.0 20181231 (experimental)
patch: https://syzkaller.appspot.com/x/patch.diff?x=114971b5600000
Note: testing is done by a robot and is best-effort only.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net,stable] cdc_ncm: fix divide-by-zero caused by invalid wMaxPacketSize
2019-09-18 12:01 [PATCH net,stable] cdc_ncm: fix divide-by-zero caused by invalid wMaxPacketSize Bjørn Mork
2019-09-18 12:26 ` divide error in cdc_ncm_update_rxtx_max syzbot
@ 2019-09-21 19:30 ` Jakub Kicinski
1 sibling, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2019-09-21 19:30 UTC (permalink / raw)
To: Bjørn Mork
Cc: netdev, linux-usb, Oliver Neukum, syzbot+ce366e2b8296e25d84f5
On Wed, 18 Sep 2019 14:01:46 +0200, Bjørn Mork wrote:
> 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>
Applied, queued, thank you!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-09-21 19:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-18 12:01 [PATCH net,stable] cdc_ncm: fix divide-by-zero caused by invalid wMaxPacketSize Bjørn Mork
2019-09-18 12:26 ` divide error in cdc_ncm_update_rxtx_max syzbot
2019-09-21 19:30 ` [PATCH net,stable] cdc_ncm: fix divide-by-zero caused by invalid wMaxPacketSize Jakub Kicinski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).