[syzbot] divide error in usbnet_start_xmit

10 views
Skip to first unread message

syzbot

unread,
Oct 18, 2021, 11:17:30 PM10/18/21
to da...@davemloft.net, ku...@kernel.org, linux-...@vger.kernel.org, linu...@vger.kernel.org, net...@vger.kernel.org, one...@suse.com, syzkall...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: c03fb16bafdf Merge 5.15-rc6 into usb-next
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
console output: https://syzkaller.appspot.com/x/log.txt?x=12d48f1f300000
kernel config: https://syzkaller.appspot.com/x/.config?x=c27d285bdb7457e2
dashboard link: https://syzkaller.appspot.com/bug?extid=76bb1d34ffa0adc03baa
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=14fe6decb00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=15c7bcaf300000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+76bb1d...@syzkaller.appspotmail.com

divide error: 0000 [#1] SMP KASAN
CPU: 0 PID: 1315 Comm: kworker/0:6 Not tainted 5.15.0-rc6-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: mld mld_ifc_work
RIP: 0010:usbnet_start_xmit+0x3f1/0x1f70 drivers/net/usb/usbnet.c:1404
Code: 00 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 0f b6 04 02 84 c0 74 08 3c 03 0f 8e 4b 18 00 00 8b 44 24 08 31 d2 31 ff <41> f7 b5 28 0d 00 00 41 89 d4 89 d6 e8 4e 12 b5 fd 45 85 e4 0f 84
RSP: 0018:ffffc9000104f660 EFLAGS: 00010246
RAX: 000000000000005a RBX: 0000000000000000 RCX: 0000000000000000
RDX: 0000000000000000 RSI: ffffffff838cbdc1 RDI: 0000000000000000
RBP: ffff8881155b1350 R08: 0000000000000001 R09: 0000000000000000
R10: ffffffff838cbdb4 R11: 0000000000000000 R12: 00000000c0011100
R13: ffff888119304000 R14: ffff8881155b1280 R15: ffff8881155b0d00
FS: 0000000000000000(0000) GS:ffff8881f6800000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f24d7edaa70 CR3: 000000010a45d000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
__netdev_start_xmit include/linux/netdevice.h:4988 [inline]
netdev_start_xmit include/linux/netdevice.h:5002 [inline]
xmit_one net/core/dev.c:3576 [inline]
dev_hard_start_xmit+0x1df/0x890 net/core/dev.c:3592
sch_direct_xmit+0x25b/0x790 net/sched/sch_generic.c:342
__dev_xmit_skb net/core/dev.c:3803 [inline]
__dev_queue_xmit+0xf25/0x2d40 net/core/dev.c:4170
neigh_resolve_output net/core/neighbour.c:1492 [inline]
neigh_resolve_output+0x50e/0x820 net/core/neighbour.c:1472
neigh_output include/net/neighbour.h:510 [inline]
ip6_finish_output2+0xdbe/0x1b20 net/ipv6/ip6_output.c:126
__ip6_finish_output.part.0+0x387/0xbb0 net/ipv6/ip6_output.c:191
__ip6_finish_output include/linux/skbuff.h:982 [inline]
ip6_finish_output net/ipv6/ip6_output.c:201 [inline]
NF_HOOK_COND include/linux/netfilter.h:296 [inline]
ip6_output+0x3d2/0x810 net/ipv6/ip6_output.c:224
dst_output include/net/dst.h:450 [inline]
NF_HOOK include/linux/netfilter.h:307 [inline]
NF_HOOK include/linux/netfilter.h:301 [inline]
mld_sendpack+0x979/0xe10 net/ipv6/mcast.c:1826
mld_send_cr net/ipv6/mcast.c:2127 [inline]
mld_ifc_work+0x71c/0xdc0 net/ipv6/mcast.c:2659
process_one_work+0x9bf/0x1620 kernel/workqueue.c:2297
worker_thread+0x658/0x11f0 kernel/workqueue.c:2444
kthread+0x3c2/0x4a0 kernel/kthread.c:319
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
Modules linked in:
---[ end trace 3c734ee50b55655e ]---
RIP: 0010:usbnet_start_xmit+0x3f1/0x1f70 drivers/net/usb/usbnet.c:1404
Code: 00 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 0f b6 04 02 84 c0 74 08 3c 03 0f 8e 4b 18 00 00 8b 44 24 08 31 d2 31 ff <41> f7 b5 28 0d 00 00 41 89 d4 89 d6 e8 4e 12 b5 fd 45 85 e4 0f 84
RSP: 0018:ffffc9000104f660 EFLAGS: 00010246
RAX: 000000000000005a RBX: 0000000000000000 RCX: 0000000000000000
RDX: 0000000000000000 RSI: ffffffff838cbdc1 RDI: 0000000000000000
RBP: ffff8881155b1350 R08: 0000000000000001 R09: 0000000000000000
R10: ffffffff838cbdb4 R11: 0000000000000000 R12: 00000000c0011100
R13: ffff888119304000 R14: ffff8881155b1280 R15: ffff8881155b0d00
FS: 0000000000000000(0000) GS:ffff8881f6800000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f24d7edaa70 CR3: 000000010a45d000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess), 1 bytes skipped:
0: 48 b8 00 00 00 00 00 movabs $0xdffffc0000000000,%rax
7: fc ff df
a: 48 89 fa mov %rdi,%rdx
d: 48 c1 ea 03 shr $0x3,%rdx
11: 0f b6 04 02 movzbl (%rdx,%rax,1),%eax
15: 84 c0 test %al,%al
17: 74 08 je 0x21
19: 3c 03 cmp $0x3,%al
1b: 0f 8e 4b 18 00 00 jle 0x186c
21: 8b 44 24 08 mov 0x8(%rsp),%eax
25: 31 d2 xor %edx,%edx
27: 31 ff xor %edi,%edi
* 29: 41 f7 b5 28 0d 00 00 divl 0xd28(%r13) <-- trapping instruction
30: 41 89 d4 mov %edx,%r12d
33: 89 d6 mov %edx,%esi
35: e8 4e 12 b5 fd callq 0xfdb51288
3a: 45 85 e4 test %r12d,%r12d
3d: 0f .byte 0xf
3e: 84 .byte 0x84


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches

Oliver Neukum

unread,
Oct 19, 2021, 4:14:27 AM10/19/21
to syzbot, linu...@vger.kernel.org, net...@vger.kernel.org, syzkall...@googlegroups.com

On 19.10.21 05:17, syzbot wrote:
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: c03fb16bafdf Merge 5.15-rc6 into usb-next
> git tree: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
> console output: https://syzkaller.appspot.com/x/log.txt?x=12d48f1f300000
> kernel config: https://syzkaller.appspot.com/x/.config?x=c27d285bdb7457e2
> dashboard link: https://syzkaller.appspot.com/bug?extid=76bb1d34ffa0adc03baa
> compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=14fe6decb00000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=15c7bcaf300000
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+76bb1d...@syzkaller.appspotmail.com

#syz test:
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git c03fb16bafdf

From a5270791d4480e9a6bc009c69a4454039aa160e7 Mon Sep 17 00:00:00 2001
From: Oliver Neukum <one...@suse.com>
Date: Tue, 19 Oct 2021 10:02:42 +0200
Subject: [PATCH] usbnet: sanity check for maxpacket

We cannot leave maxpacket at 0 because we divide by it.
Devices that give us a 0 there are unlikely to work, but let's
assume a 1, so we don't oops and a least try to operate.

Signed-off-by: Oliver Neukum <one...@suse.com>
Reported-by: syzbot+76bb1d...@syzkaller.appspotmail.com
---
 drivers/net/usb/usbnet.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 840c1c2ab16a..2bdc3e0c1579 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1788,6 +1788,9 @@ usbnet_probe (struct usb_interface *udev, const
struct usb_device_id *prod)
     if (!dev->rx_urb_size)
         dev->rx_urb_size = dev->hard_mtu;
     dev->maxpacket = usb_maxpacket (dev->udev, dev->out, 1);
+    if (dev->maxpacket == 0)
+        /* that is a strange device */
+        dev->maxpacket = 1;
 
     /* let userspace know we have a random address */
     if (ether_addr_equal(net->dev_addr, node_id))
--
2.26.2

syzbot

unread,
Oct 19, 2021, 4:24:12 AM10/19/21
to linu...@vger.kernel.org, net...@vger.kernel.org, one...@suse.com, syzkall...@googlegroups.com
Hello,

syzbot tried to test the proposed patch but the build/boot failed:

failed to apply patch:
checking file drivers/net/usb/usbnet.c
patch: **** unexpected end of file in patch



Tested on:

commit: c03fb16b Merge 5.15-rc6 into usb-next
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git
patch: https://syzkaller.appspot.com/x/patch.diff?x=1149aaf0b00000

Johan Hovold

unread,
Oct 19, 2021, 5:23:54 AM10/19/21
to Oliver Neukum, syzbot, linu...@vger.kernel.org, net...@vger.kernel.org, syzkall...@googlegroups.com
Just bail out; what can you do with a 1-byte packet size? Also compare
usbnet_get_endpoints() where such endpoints are ignored.

Johan

Oliver Neukum

unread,
Oct 19, 2021, 6:04:38 AM10/19/21
to Johan Hovold, Oliver Neukum, syzbot, linu...@vger.kernel.org, net...@vger.kernel.org, syzkall...@googlegroups.com
On 19.10.21 11:23, Johan Hovold wrote:

> Just bail out; what can you do with a 1-byte packet size? Also compare
> usbnet_get_endpoints() where such endpoints are ignored.

OK. We'd accept a 1 now, though. Can you think of a sensible lower bound?

    Regards
        Oliver

Johan Hovold

unread,
Oct 19, 2021, 6:08:19 AM10/19/21
to Oliver Neukum, syzbot, linu...@vger.kernel.org, net...@vger.kernel.org, syzkall...@googlegroups.com
You can continue accepting 1 if you want, just reject zero and abort
probe.

Johan

syzbot

unread,
Oct 22, 2021, 1:51:13 AM10/22/21
to 1111...@vivo.com, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+76bb1d...@syzkaller.appspotmail.com

Tested on:

commit: 64222515 Merge tag 'drm-fixes-2021-10-22' of git://ano..
git tree: upstream
kernel config: https://syzkaller.appspot.com/x/.config?x=c27d285bdb7457e2
dashboard link: https://syzkaller.appspot.com/bug?extid=76bb1d34ffa0adc03baa
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
patch: https://syzkaller.appspot.com/x/patch.diff?x=1593eef0b00000

Note: testing is done by a robot and is best-effort only.
Reply all
Reply to author
Forward
0 new messages