syzbot


KASAN: use-after-free Read in cdc_ncm_tx_fixup

Status: upstream: reported syz repro on 2021/12/13 12:20
Reported-by: syzbot+5ec3d1378e31c88d87f4@syzkaller.appspotmail.com
First crash: 207d, last: 55d

Cause bisection: failed (bisect log)

Fix bisection: fixed by (bisect log) :
commit d1408f6b4dd78fb1b9e26bcf64477984e5f85409
Author: Lukas Wunner <lukas@wunner.de>
Date: Thu May 12 08:42:01 2022 +0000

  usbnet: Run unregister_netdev() before unbind() again

Patch testing requests:
Created Duration User Patch Repo Result
2022/03/08 15:08 10m hdanton@sina.com patch https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/ ea4424be1688 OK

Sample crash report:
usb 1-1: USB disconnect, device number 2
cdc_ncm 1-1:1.0 usb0: unregister 'cdc_ncm' usb-dummy_hcd.0-1, CDC NCM
==================================================================
BUG: KASAN: use-after-free in __lock_acquire+0x3f2f/0x56c0 kernel/locking/lockdep.c:4897
Read of size 8 at addr ffff88802116fcf0 by task kworker/0:2/3643

CPU: 0 PID: 3643 Comm: kworker/0:2 Not tainted 5.17.0-rc7-syzkaller-00064-g330f4c53d3c2 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: usb_hub_wq hub_event
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 print_address_description.constprop.0.cold+0x8d/0x303 mm/kasan/report.c:255
 __kasan_report mm/kasan/report.c:442 [inline]
 kasan_report.cold+0x83/0xdf mm/kasan/report.c:459
 __lock_acquire+0x3f2f/0x56c0 kernel/locking/lockdep.c:4897
 lock_acquire kernel/locking/lockdep.c:5639 [inline]
 lock_acquire+0x1ab/0x510 kernel/locking/lockdep.c:5604
 __raw_spin_lock_bh include/linux/spinlock_api_smp.h:126 [inline]
 _raw_spin_lock_bh+0x2f/0x40 kernel/locking/spinlock.c:178
 spin_lock_bh include/linux/spinlock.h:354 [inline]
 cdc_ncm_tx_fixup+0x8f/0x120 drivers/net/usb/cdc_ncm.c:1527
 usbnet_start_xmit+0x152/0x1f70 drivers/net/usb/usbnet.c:1372
 __netdev_start_xmit include/linux/netdevice.h:4683 [inline]
 netdev_start_xmit include/linux/netdevice.h:4697 [inline]
 xmit_one net/core/dev.c:3473 [inline]
 dev_hard_start_xmit+0x1eb/0x920 net/core/dev.c:3489
 sch_direct_xmit+0x19f/0xbe0 net/sched/sch_generic.c:342
 __dev_xmit_skb net/core/dev.c:3700 [inline]
 __dev_queue_xmit+0x148f/0x37b0 net/core/dev.c:4081
 lapb_data_transmit+0x8f/0xc0 net/lapb/lapb_iface.c:447
 lapb_transmit_buffer+0x183/0x390 net/lapb/lapb_out.c:149
 lapb_send_control+0x1c7/0x370 net/lapb/lapb_subr.c:251
 __lapb_disconnect_request+0x127/0x1a0 net/lapb/lapb_iface.c:326
 lapb_device_event+0x292/0x560 net/lapb/lapb_iface.c:492
 notifier_call_chain+0xb5/0x200 kernel/notifier.c:84
 call_netdevice_notifiers_info+0xb5/0x130 net/core/dev.c:1919
 call_netdevice_notifiers_extack net/core/dev.c:1931 [inline]
 call_netdevice_notifiers net/core/dev.c:1945 [inline]
 __dev_close_many+0xf1/0x2e0 net/core/dev.c:1465
 dev_close_many+0x22c/0x620 net/core/dev.c:1516
 dev_close net/core/dev.c:1542 [inline]
 dev_close+0x16d/0x210 net/core/dev.c:1536
 lapbeth_device_event+0x677/0xc00 drivers/net/wan/lapbether.c:462
 notifier_call_chain+0xb5/0x200 kernel/notifier.c:84
 call_netdevice_notifiers_info+0xb5/0x130 net/core/dev.c:1919
 call_netdevice_notifiers_extack net/core/dev.c:1931 [inline]
 call_netdevice_notifiers net/core/dev.c:1945 [inline]
 __dev_close_many+0xf1/0x2e0 net/core/dev.c:1465
 dev_close_many+0x22c/0x620 net/core/dev.c:1516
 unregister_netdevice_many+0x3ff/0x18d0 net/core/dev.c:10392
 unregister_netdevice_queue net/core/dev.c:10349 [inline]
 unregister_netdevice_queue+0x2dd/0x3c0 net/core/dev.c:10339
 unregister_netdevice include/linux/netdevice.h:2902 [inline]
 unregister_netdev+0x18/0x20 net/core/dev.c:10474
 usbnet_disconnect+0x139/0x270 drivers/net/usb/usbnet.c:1623
 usb_unbind_interface+0x1d8/0x8e0 drivers/usb/core/driver.c:458
 __device_release_driver+0x627/0x760 drivers/base/dd.c:1209
 device_release_driver_internal drivers/base/dd.c:1242 [inline]
 device_release_driver+0x26/0x40 drivers/base/dd.c:1265
 bus_remove_device+0x2eb/0x5a0 drivers/base/bus.c:529
 device_del+0x4f3/0xc80 drivers/base/core.c:3592
 usb_disable_device+0x35b/0x7b0 drivers/usb/core/message.c:1419
 usb_disconnect.cold+0x27a/0x78e drivers/usb/core/hub.c:2228
 hub_port_connect drivers/usb/core/hub.c:5202 [inline]
 hub_port_connect_change drivers/usb/core/hub.c:5502 [inline]
 port_event drivers/usb/core/hub.c:5660 [inline]
 hub_event+0x1e39/0x44d0 drivers/usb/core/hub.c:5742
 process_one_work+0x9ac/0x1650 kernel/workqueue.c:2307
 worker_thread+0x657/0x1110 kernel/workqueue.c:2454
 kthread+0x2e9/0x3a0 kernel/kthread.c:377
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
 </TASK>

Allocated by task 3643:
 kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
 kasan_set_track mm/kasan/common.c:45 [inline]
 set_alloc_info mm/kasan/common.c:436 [inline]
 ____kasan_kmalloc mm/kasan/common.c:515 [inline]
 ____kasan_kmalloc mm/kasan/common.c:474 [inline]
 __kasan_kmalloc+0xa6/0xd0 mm/kasan/common.c:524
 kasan_kmalloc include/linux/kasan.h:270 [inline]
 kmem_cache_alloc_trace+0x1ea/0x4a0 mm/slab.c:3567
 kmalloc include/linux/slab.h:581 [inline]
 kzalloc include/linux/slab.h:714 [inline]
 cdc_ncm_bind_common+0xb8/0x2df0 drivers/net/usb/cdc_ncm.c:826
 cdc_ncm_bind+0x7c/0x1c0 drivers/net/usb/cdc_ncm.c:1069
 usbnet_probe+0xaf8/0x2580 drivers/net/usb/usbnet.c:1747
 usb_probe_interface+0x315/0x7f0 drivers/usb/core/driver.c:396
 call_driver_probe drivers/base/dd.c:517 [inline]
 really_probe+0x245/0xcc0 drivers/base/dd.c:596
 __driver_probe_device+0x338/0x4d0 drivers/base/dd.c:755
 driver_probe_device+0x4c/0x1a0 drivers/base/dd.c:785
 __device_attach_driver+0x20b/0x2f0 drivers/base/dd.c:902
 bus_for_each_drv+0x15f/0x1e0 drivers/base/bus.c:427
 __device_attach+0x228/0x4a0 drivers/base/dd.c:973
 bus_probe_device+0x1e4/0x290 drivers/base/bus.c:487
 device_add+0xb83/0x1e20 drivers/base/core.c:3405
 usb_set_configuration+0x101e/0x1900 drivers/usb/core/message.c:2170
 usb_generic_driver_probe+0xba/0x100 drivers/usb/core/generic.c:238
 usb_probe_device+0xd9/0x2c0 drivers/usb/core/driver.c:293
 call_driver_probe drivers/base/dd.c:517 [inline]
 really_probe+0x245/0xcc0 drivers/base/dd.c:596
 __driver_probe_device+0x338/0x4d0 drivers/base/dd.c:755
 driver_probe_device+0x4c/0x1a0 drivers/base/dd.c:785
 __device_attach_driver+0x20b/0x2f0 drivers/base/dd.c:902
 bus_for_each_drv+0x15f/0x1e0 drivers/base/bus.c:427
 __device_attach+0x228/0x4a0 drivers/base/dd.c:973
 bus_probe_device+0x1e4/0x290 drivers/base/bus.c:487
 device_add+0xb83/0x1e20 drivers/base/core.c:3405
 usb_new_device.cold+0x63f/0x108e drivers/usb/core/hub.c:2566
 hub_port_connect drivers/usb/core/hub.c:5358 [inline]
 hub_port_connect_change drivers/usb/core/hub.c:5502 [inline]
 port_event drivers/usb/core/hub.c:5660 [inline]
 hub_event+0x2585/0x44d0 drivers/usb/core/hub.c:5742
 process_one_work+0x9ac/0x1650 kernel/workqueue.c:2307
 worker_thread+0x657/0x1110 kernel/workqueue.c:2454
 kthread+0x2e9/0x3a0 kernel/kthread.c:377
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

Freed by task 3643:
 kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
 kasan_set_track+0x21/0x30 mm/kasan/common.c:45
 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:370
 ____kasan_slab_free mm/kasan/common.c:366 [inline]
 ____kasan_slab_free+0xff/0x140 mm/kasan/common.c:328
 kasan_slab_free include/linux/kasan.h:236 [inline]
 __cache_free mm/slab.c:3437 [inline]
 kfree+0xf8/0x2b0 mm/slab.c:3794
 cdc_ncm_free+0x145/0x1a0 drivers/net/usb/cdc_ncm.c:786
 cdc_ncm_unbind+0x1a7/0x340 drivers/net/usb/cdc_ncm.c:1021
 usbnet_disconnect+0x103/0x270 drivers/net/usb/usbnet.c:1620
 usb_unbind_interface+0x1d8/0x8e0 drivers/usb/core/driver.c:458
 __device_release_driver+0x627/0x760 drivers/base/dd.c:1209
 device_release_driver_internal drivers/base/dd.c:1242 [inline]
 device_release_driver+0x26/0x40 drivers/base/dd.c:1265
 bus_remove_device+0x2eb/0x5a0 drivers/base/bus.c:529
 device_del+0x4f3/0xc80 drivers/base/core.c:3592
 usb_disable_device+0x35b/0x7b0 drivers/usb/core/message.c:1419
 usb_disconnect.cold+0x27a/0x78e drivers/usb/core/hub.c:2228
 hub_port_connect drivers/usb/core/hub.c:5202 [inline]
 hub_port_connect_change drivers/usb/core/hub.c:5502 [inline]
 port_event drivers/usb/core/hub.c:5660 [inline]
 hub_event+0x1e39/0x44d0 drivers/usb/core/hub.c:5742
 process_one_work+0x9ac/0x1650 kernel/workqueue.c:2307
 worker_thread+0x657/0x1110 kernel/workqueue.c:2454
 kthread+0x2e9/0x3a0 kernel/kthread.c:377
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

The buggy address belongs to the object at ffff88802116fc00
 which belongs to the cache kmalloc-512 of size 512
The buggy address is located 240 bytes inside of
 512-byte region [ffff88802116fc00, ffff88802116fe00)
The buggy address belongs to the page:
page:ffffea0000845bc0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x2116f
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 ffffea00008d3308 ffffea00008455c8 ffff888010c40600
raw: 0000000000000000 ffff88802116f000 0000000100000004 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x2420c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_COMP|__GFP_THISNODE), pid 2137, ts 10764288484, free_ts 10762473799
 prep_new_page mm/page_alloc.c:2434 [inline]
 get_page_from_freelist+0xa72/0x2f50 mm/page_alloc.c:4165
 __alloc_pages+0x1b2/0x500 mm/page_alloc.c:5389
 __alloc_pages_node include/linux/gfp.h:572 [inline]
 kmem_getpages mm/slab.c:1378 [inline]
 cache_grow_begin+0x75/0x390 mm/slab.c:2584
 cache_alloc_refill+0x27f/0x380 mm/slab.c:2957
 ____cache_alloc mm/slab.c:3040 [inline]
 ____cache_alloc mm/slab.c:3023 [inline]
 __do_cache_alloc mm/slab.c:3267 [inline]
 slab_alloc mm/slab.c:3308 [inline]
 kmem_cache_alloc_trace+0x380/0x4a0 mm/slab.c:3565
 kmalloc include/linux/slab.h:581 [inline]
 kzalloc include/linux/slab.h:714 [inline]
 alloc_bprm+0x51/0x8f0 fs/exec.c:1507
 kernel_execve+0x55/0x460 fs/exec.c:1947
 call_usermodehelper_exec_async+0x2e3/0x580 kernel/umh.c:112
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1352 [inline]
 free_pcp_prepare+0x374/0x870 mm/page_alloc.c:1404
 free_unref_page_prepare mm/page_alloc.c:3325 [inline]
 free_unref_page_list+0x1a9/0xfa0 mm/page_alloc.c:3441
 release_pages+0x317/0x1220 mm/swap.c:980
 tlb_batch_pages_flush mm/mmu_gather.c:50 [inline]
 tlb_flush_mmu_free mm/mmu_gather.c:243 [inline]
 tlb_flush_mmu mm/mmu_gather.c:250 [inline]
 tlb_finish_mmu+0x165/0x8c0 mm/mmu_gather.c:341
 exit_mmap+0x21b/0x6a0 mm/mmap.c:3180
 __mmput+0x122/0x4b0 kernel/fork.c:1114
 mmput+0x56/0x60 kernel/fork.c:1135
 free_bprm+0x65/0x2e0 fs/exec.c:1485
 kernel_execve+0x380/0x460 fs/exec.c:1982
 call_usermodehelper_exec_async+0x2e3/0x580 kernel/umh.c:112
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

Memory state around the buggy address:
 ffff88802116fb80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88802116fc00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88802116fc80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                             ^
 ffff88802116fd00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88802116fd80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (33):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce-selinux-root 2022/03/09 19:44 upstream 330f4c53d3c2 9e8eaa75 .config log report syz KASAN: use-after-free Read in cdc_ncm_tx_fixup
ci-upstream-kasan-gce 2022/03/08 07:01 upstream ea4424be1688 7bdd8b2c .config log report syz KASAN: use-after-free Read in cdc_ncm_tx_fixup
ci-upstream-kasan-gce 2022/05/10 02:07 upstream 9be9ed2612b5 8b277b8e .config log report info KASAN: use-after-free Read in cdc_ncm_tx_fixup
ci-upstream-kasan-gce 2022/04/11 15:09 upstream ce522ba9ef7e af01ee7d .config log report info KASAN: use-after-free Read in cdc_ncm_tx_fixup
ci-upstream-kasan-gce 2022/04/10 01:16 upstream f1b45d8ccb98 e22c3da3 .config log report info KASAN: use-after-free Read in cdc_ncm_tx_fixup
ci-upstream-kasan-gce 2022/04/09 20:50 upstream f1b45d8ccb98 e22c3da3 .config log report info KASAN: use-after-free Read in cdc_ncm_tx_fixup
ci-upstream-kasan-gce 2022/04/08 17:35 upstream 1831fed55973 15be3cba .config log report info KASAN: use-after-free Read in cdc_ncm_tx_fixup
ci-upstream-kasan-gce 2022/04/01 09:59 upstream b4a5ea09b293 68fc921a .config log report info KASAN: use-after-free Read in cdc_ncm_tx_fixup
ci-upstream-kasan-gce 2022/04/01 04:17 upstream b4a5ea09b293 68fc921a .config log report info KASAN: use-after-free Read in cdc_ncm_tx_fixup
ci-upstream-kasan-gce 2022/03/29 08:09 upstream cffb2b72d3ed 6bdac766 .config log report info KASAN: use-after-free Read in cdc_ncm_tx_fixup
ci-upstream-kasan-gce 2022/03/29 05:50 upstream cffb2b72d3ed 6bdac766 .config log report info KASAN: use-after-free Read in cdc_ncm_tx_fixup
ci-upstream-kasan-gce 2022/03/24 20:48 upstream ed4643521e6a 89bc8608 .config log report info KASAN: use-after-free Read in cdc_ncm_tx_fixup
ci-upstream-kasan-gce 2022/03/23 13:58 upstream 6b1f86f8e9c7 5ff41e94 .config log report info KASAN: use-after-free Read in cdc_ncm_tx_fixup
ci-upstream-kasan-gce 2022/03/20 08:09 upstream 97e9c8eb4bb1 e2d91b1d .config log report info KASAN: use-after-free Read in cdc_ncm_tx_fixup
ci-upstream-kasan-gce 2022/03/18 14:21 upstream 551acdc3c3d2 e2d91b1d .config log report info KASAN: use-after-free Read in cdc_ncm_tx_fixup
ci-upstream-kasan-gce 2022/03/14 08:30 upstream f0e18b03fcaf 9e8eaa75 .config log report info KASAN: use-after-free Read in cdc_ncm_tx_fixup
ci-upstream-kasan-gce-smack-root 2022/03/12 16:36 upstream 68453767131a 9e8eaa75 .config log report info KASAN: use-after-free Read in cdc_ncm_tx_fixup
ci-upstream-kasan-gce-selinux-root 2022/03/11 22:37 upstream 79b00034e9dc 9e8eaa75 .config log report info KASAN: use-after-free Read in cdc_ncm_tx_fixup
ci-upstream-kasan-gce-selinux-root 2022/03/10 09:04 upstream e7e19defa575 9e8eaa75 .config log report info KASAN: use-after-free Read in cdc_ncm_tx_fixup
ci-upstream-kasan-gce-selinux-root 2022/03/09 16:14 upstream 330f4c53d3c2 9e8eaa75 .config log report info KASAN: use-after-free Read in cdc_ncm_tx_fixup
ci-upstream-kasan-gce-selinux-root 2022/03/08 03:15 upstream ea4424be1688 7bdd8b2c .config log report info KASAN: use-after-free Read in cdc_ncm_tx_fixup
ci-upstream-kasan-gce 2022/03/08 03:13 upstream ea4424be1688 7bdd8b2c .config log report info KASAN: use-after-free Read in cdc_ncm_tx_fixup
ci-upstream-kasan-gce-smack-root 2022/03/08 03:10 upstream ea4424be1688 7bdd8b2c .config log report info KASAN: use-after-free Read in cdc_ncm_tx_fixup
ci-upstream-kasan-gce-selinux-root 2022/03/01 17:45 upstream 719fce7539cd 45a13a73 .config log report info KASAN: use-after-free Read in cdc_ncm_tx_fixup
ci-qemu-upstream 2021/12/09 12:14 upstream 2a987e65025e a4a2a501 .config log report info KASAN: use-after-free Read in cdc_ncm_tx_fixup
ci-upstream-kasan-gce-386 2022/04/11 23:21 upstream ce522ba9ef7e af01ee7d .config log report info KASAN: use-after-free Read in cdc_ncm_tx_fixup
ci-upstream-kasan-gce-386 2022/03/17 12:12 upstream 56e337f2cf13 dfa9a8ed .config log report info KASAN: use-after-free Read in cdc_ncm_tx_fixup
ci-upstream-kasan-gce-386 2022/03/15 15:54 upstream 09688c0166e7 9e8eaa75 .config log report info KASAN: use-after-free Read in cdc_ncm_tx_fixup
ci-upstream-kasan-gce-386 2022/03/12 16:58 upstream 68453767131a 9e8eaa75 .config log report info KASAN: use-after-free Read in cdc_ncm_tx_fixup
ci-upstream-linux-next-kasan-gce-root 2022/03/14 02:45 linux-next 91265a6da44d 9e8eaa75 .config log report info KASAN: use-after-free Read in cdc_ncm_tx_fixup
ci-upstream-linux-next-kasan-gce-root 2022/03/12 02:44 linux-next 91265a6da44d 9e8eaa75 .config log report info KASAN: use-after-free Read in cdc_ncm_tx_fixup
ci-upstream-linux-next-kasan-gce-root 2022/03/08 03:26 linux-next 91265a6da44d 7bdd8b2c .config log report info KASAN: use-after-free Read in cdc_ncm_tx_fixup
ci2-upstream-usb 2022/03/06 08:01 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing 98d107b84614 7bdd8b2c .config log report info KASAN: use-after-free Read in cdc_ncm_tx_fixup