syzbot


KASAN: use-after-free Read in cfusbl_device_notify

Status: upstream: reported C repro on 2022/10/12 16:59
Reported-by: syzbot+b563d33852b893653a9e@syzkaller.appspotmail.com
First crash: 274d, last: 11h07m

Cause bisection: introduced by (bisect log) :
commit da0efe30944476275c902c52fbac812db0541d87
Author: Muchun Song <songmuchun@bytedance.com>
Date: Tue Mar 22 21:41:15 2022 +0000

  mm: memcontrol: move memcg_online_kmem() to mem_cgroup_css_online()

Crash: unregister_netdevice: waiting for DEV to become free (log)
Repro: C syz .config

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in cfusbl_device_notify+0x7c9/0x870 net/caif/caif_usb.c:138
Read of size 8 at addr ffff88807ac4e6f0 by task kworker/u4:6/1214

CPU: 0 PID: 1214 Comm: kworker/u4:6 Not tainted 5.19.0-rc3-syzkaller-00146-g92f20ff72066 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: netns cleanup_net
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+0xeb/0x467 mm/kasan/report.c:313
 print_report mm/kasan/report.c:429 [inline]
 kasan_report.cold+0xf4/0x1c6 mm/kasan/report.c:491
 cfusbl_device_notify+0x7c9/0x870 net/caif/caif_usb.c:138
 notifier_call_chain+0xb5/0x200 kernel/notifier.c:87
 call_netdevice_notifiers_info+0xb5/0x130 net/core/dev.c:1945
 call_netdevice_notifiers_extack net/core/dev.c:1983 [inline]
 call_netdevice_notifiers net/core/dev.c:1997 [inline]
 netdev_wait_allrefs_any net/core/dev.c:10227 [inline]
 netdev_run_todo+0xbc0/0x10f0 net/core/dev.c:10341
 default_device_exit_batch+0x44e/0x590 net/core/dev.c:11334
 ops_exit_list+0x125/0x170 net/core/net_namespace.c:167
 cleanup_net+0x4ea/0xb00 net/core/net_namespace.c:594
 process_one_work+0x996/0x1610 kernel/workqueue.c:2289
 worker_thread+0x665/0x1080 kernel/workqueue.c:2436
 kthread+0x2e9/0x3a0 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:302
 </TASK>

Allocated by task 3641:
 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
 kmalloc_node include/linux/slab.h:623 [inline]
 kvmalloc_node+0x3e/0x190 mm/util.c:613
 kvmalloc include/linux/slab.h:750 [inline]
 kvzalloc include/linux/slab.h:758 [inline]
 alloc_netdev_mqs+0x98/0x1180 net/core/dev.c:10580
 rtnl_create_link+0x9d7/0xc00 net/core/rtnetlink.c:3241
 veth_newlink+0x214/0x9a0 drivers/net/veth.c:1753
 rtnl_newlink_create net/core/rtnetlink.c:3363 [inline]
 __rtnl_newlink+0x1087/0x17e0 net/core/rtnetlink.c:3580
 rtnl_newlink+0x64/0xa0 net/core/rtnetlink.c:3593
 rtnetlink_rcv_msg+0x43a/0xc90 net/core/rtnetlink.c:6089
 netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2501
 netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline]
 netlink_unicast+0x543/0x7f0 net/netlink/af_netlink.c:1345
 netlink_sendmsg+0x917/0xe10 net/netlink/af_netlink.c:1921
 sock_sendmsg_nosec net/socket.c:714 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:734
 __sys_sendto+0x21a/0x320 net/socket.c:2119
 __do_sys_sendto net/socket.c:2131 [inline]
 __se_sys_sendto net/socket.c:2127 [inline]
 __x64_sys_sendto+0xdd/0x1b0 net/socket.c:2127
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x46/0xb0

Freed by task 1214:
 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+0x13d/0x180 mm/kasan/common.c:328
 kasan_slab_free include/linux/kasan.h:200 [inline]
 __cache_free mm/slab.c:3425 [inline]
 kfree+0x113/0x310 mm/slab.c:3796
 kvfree+0x42/0x50 mm/util.c:655
 device_release+0x9f/0x240 drivers/base/core.c:2230
 kobject_cleanup lib/kobject.c:673 [inline]
 kobject_release lib/kobject.c:704 [inline]
 kref_put include/linux/kref.h:65 [inline]
 kobject_put+0x1c8/0x540 lib/kobject.c:721
 netdev_run_todo+0x75e/0x10f0 net/core/dev.c:10362
 default_device_exit_batch+0x44e/0x590 net/core/dev.c:11334
 ops_exit_list+0x125/0x170 net/core/net_namespace.c:167
 cleanup_net+0x4ea/0xb00 net/core/net_namespace.c:594
 process_one_work+0x996/0x1610 kernel/workqueue.c:2289
 worker_thread+0x665/0x1080 kernel/workqueue.c:2436
 kthread+0x2e9/0x3a0 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:302

The buggy address belongs to the object at ffff88807ac4e000
 which belongs to the cache kmalloc-cg-4k of size 4096
The buggy address is located 1776 bytes inside of
 4096-byte region [ffff88807ac4e000, ffff88807ac4f000)

The buggy address belongs to the physical page:
page:ffffea0001eb1380 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7ac4e
head:ffffea0001eb1380 order:1 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 ffffea0000892208 ffffea0001ed7d08 ffff888011843d00
raw: 0000000000000000 ffff88807ac4e000 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 1, migratetype Unmovable, gfp_mask 0x2460c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_RETRY_MAYFAIL|__GFP_COMP|__GFP_THISNODE), pid 3641, tgid 3641 (syz-executor787), ts 210855385315, free_ts 210802994009
 prep_new_page mm/page_alloc.c:2456 [inline]
 get_page_from_freelist+0x1290/0x3b70 mm/page_alloc.c:4198
 __alloc_pages+0x1c7/0x510 mm/page_alloc.c:5426
 __alloc_pages_node include/linux/gfp.h:587 [inline]
 kmem_getpages mm/slab.c:1363 [inline]
 cache_grow_begin+0x75/0x350 mm/slab.c:2569
 cache_alloc_refill+0x27f/0x380 mm/slab.c:2942
 ____cache_alloc mm/slab.c:3024 [inline]
 ____cache_alloc mm/slab.c:3007 [inline]
 slab_alloc_node mm/slab.c:3227 [inline]
 kmem_cache_alloc_node_trace+0x518/0x5b0 mm/slab.c:3611
 __do_kmalloc_node mm/slab.c:3633 [inline]
 __kmalloc_node+0x38/0x60 mm/slab.c:3641
 kmalloc_node include/linux/slab.h:623 [inline]
 kvmalloc_node+0x3e/0x190 mm/util.c:613
 kvmalloc include/linux/slab.h:750 [inline]
 kvzalloc include/linux/slab.h:758 [inline]
 alloc_netdev_mqs+0x98/0x1180 net/core/dev.c:10580
 rtnl_create_link+0x9d7/0xc00 net/core/rtnetlink.c:3241
 veth_newlink+0x214/0x9a0 drivers/net/veth.c:1753
 rtnl_newlink_create net/core/rtnetlink.c:3363 [inline]
 __rtnl_newlink+0x1087/0x17e0 net/core/rtnetlink.c:3580
 rtnl_newlink+0x64/0xa0 net/core/rtnetlink.c:3593
 rtnetlink_rcv_msg+0x43a/0xc90 net/core/rtnetlink.c:6089
 netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2501
 netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline]
 netlink_unicast+0x543/0x7f0 net/netlink/af_netlink.c:1345
 netlink_sendmsg+0x917/0xe10 net/netlink/af_netlink.c:1921
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1371 [inline]
 free_pcp_prepare+0x549/0xd20 mm/page_alloc.c:1421
 free_unref_page_prepare mm/page_alloc.c:3343 [inline]
 free_unref_page+0x19/0x6a0 mm/page_alloc.c:3438
 slab_destroy mm/slab.c:1615 [inline]
 slabs_destroy+0x89/0xc0 mm/slab.c:1635
 cache_flusharray mm/slab.c:3397 [inline]
 ___cache_free+0x34e/0x670 mm/slab.c:3460
 qlink_free mm/kasan/quarantine.c:168 [inline]
 qlist_free_all+0x4f/0x1b0 mm/kasan/quarantine.c:187
 kasan_quarantine_reduce+0x180/0x200 mm/kasan/quarantine.c:294
 __kasan_slab_alloc+0x97/0xb0 mm/kasan/common.c:446
 kasan_slab_alloc include/linux/kasan.h:224 [inline]
 slab_post_alloc_hook mm/slab.h:750 [inline]
 slab_alloc mm/slab.c:3302 [inline]
 kmem_cache_alloc_trace+0x258/0x4a0 mm/slab.c:3567
 kmalloc include/linux/slab.h:600 [inline]
 kzalloc include/linux/slab.h:733 [inline]
 kobject_uevent_env+0x235/0x1660 lib/kobject_uevent.c:524
 __kobject_del+0x169/0x200 lib/kobject.c:585
 kobject_cleanup lib/kobject.c:664 [inline]
 kobject_release lib/kobject.c:704 [inline]
 kref_put include/linux/kref.h:65 [inline]
 kobject_put+0x2b6/0x540 lib/kobject.c:721
 netdev_queue_update_kobjects+0x367/0x4e0 net/core/net-sysfs.c:1733
 netif_set_real_num_tx_queues+0x1b6/0x770 net/core/dev.c:2893
 veth_init_queues+0xdd/0x190 drivers/net/veth.c:1691
 veth_newlink+0x687/0x9a0 drivers/net/veth.c:1817
 rtnl_newlink_create net/core/rtnetlink.c:3363 [inline]
 __rtnl_newlink+0x1087/0x17e0 net/core/rtnetlink.c:3580

Memory state around the buggy address:
 ffff88807ac4e580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88807ac4e600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88807ac4e680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                             ^
 ffff88807ac4e700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88807ac4e780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (286):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce-selinux-root 2022/06/24 15:54 upstream 92f20ff72066 a5dbd430 .config log report syz C KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-kasan-gce-smack-root 2022/05/15 05:21 upstream 2fe1020d73ca 744a39e2 .config log report syz C KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-kasan-gce-root 2022/04/07 03:13 upstream 3e732ebf7316 97582466 .config log report syz C KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-linux-next-kasan-gce-root 2022/05/13 22:20 linux-next 1e1b28b936ae 107f6434 .config log report syz C KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-kasan-gce-selinux-root 2022/11/04 00:01 upstream f2f32f8af2b0 6d752409 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-kasan-gce-selinux-root 2022/11/02 05:23 upstream b229b6ca5abb edac4fd1 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-kasan-gce-smack-root 2022/10/29 22:33 upstream b229b6ca5abb 899d812a .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-kasan-gce-selinux-root 2022/10/27 11:42 upstream 98555239e4c3 86777b7f .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-kasan-gce-selinux-root 2022/10/24 20:21 upstream 247f34f7b803 ff2fe65d .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-kasan-gce-selinux-root 2022/10/23 22:15 upstream d47136c28015 23bf86af .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-kasan-gce-selinux-root 2022/10/21 08:16 upstream 6d36c728bc2e 63e790dd .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-kasan-gce-selinux-root 2022/10/20 21:47 upstream 55be6084c8e0 a0fd4dab .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-kasan-gce-selinux-root 2022/10/19 10:53 upstream 55be6084c8e0 b31320fc .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-kasan-gce-selinux-root 2022/10/15 14:02 upstream 55be6084c8e0 67cb024c .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-kasan-gce-selinux-root 2022/10/15 07:07 upstream 55be6084c8e0 67cb024c .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-kasan-gce-selinux-root 2022/10/13 14:32 upstream 55be6084c8e0 adf90437 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-kasan-gce-selinux-root 2022/10/12 16:21 upstream 55be6084c8e0 89b5a509 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-kasan-gce-smack-root 2022/10/12 08:38 upstream 55be6084c8e0 16a9c9e0 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-kasan-gce-smack-root 2022/10/09 22:46 upstream a6afa4199d3d aea5da89 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-kasan-gce-selinux-root 2022/10/07 20:46 upstream 4c86114194e6 0de35f24 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-kasan-gce-selinux-root 2022/10/04 17:32 upstream a5088ee7251e eab8f949 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-kasan-gce-selinux-root 2022/10/04 17:29 upstream a5088ee7251e eab8f949 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-kasan-gce-smack-root 2022/10/04 10:10 upstream a5088ee7251e feb56351 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-kasan-gce-root 2022/08/28 12:50 upstream 10d4879f9ef0 07177916 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-qemu-upstream 2022/07/31 16:26 upstream 6a010258447d fef302b1 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-qemu-upstream-386 2022/11/02 06:58 upstream 200204f56f3b 08977f5d .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-qemu-upstream-386 2022/10/05 00:29 upstream 0326074ff465 267e3bb1 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-qemu-upstream-386 2022/10/01 18:13 upstream b357fd1c2afc feb56351 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-net-this-kasan-gce 2022/10/09 10:10 net aabf6155dfb8 aea5da89 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-net-this-kasan-gce 2022/10/04 06:42 net 7a62ed61367b feb56351 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-net-this-kasan-gce 2022/09/30 22:21 net 0bafedc53649 feb56351 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-net-this-kasan-gce 2022/09/30 13:52 net 0bafedc53649 1d385642 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-net-this-kasan-gce 2022/09/29 13:44 net 3b04cba7add0 1d385642 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-net-kasan-gce 2022/11/28 23:49 net-next a66d79ee0bd5 247de55b .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-net-kasan-gce 2022/11/26 09:29 net-next a6e3d86ece0b 74a66371 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-net-kasan-gce 2022/11/25 18:39 net-next 14e5f71e31ff 74a66371 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-net-kasan-gce 2022/11/21 20:40 net-next 8719a1c30d3a 1c576c23 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-net-kasan-gce 2022/11/05 14:52 net-next fbeb229a6622 6d752409 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-net-kasan-gce 2022/11/02 18:07 net-next 99c8eb46773e 08977f5d .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-net-kasan-gce 2022/10/31 12:50 net-next 99c8eb46773e 2a71366b .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-net-kasan-gce 2022/10/24 12:29 net-next 3bd5549bd479 23bf86af .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-net-kasan-gce 2022/10/23 09:06 net-next 3bd5549bd479 c0b80a55 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-net-kasan-gce 2022/10/23 03:47 net-next 3bd5549bd479 c0b80a55 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-net-kasan-gce 2022/10/22 22:36 net-next 3bd5549bd479 c0b80a55 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-net-kasan-gce 2022/10/22 19:22 net-next 3bd5549bd479 c0b80a55 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-net-kasan-gce 2022/10/21 19:32 net-next 070f822d077f 4bfd3c27 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-net-kasan-gce 2022/10/21 15:10 net-next 070f822d077f 4bfd3c27 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-net-kasan-gce 2022/10/20 20:33 net-next 0326074ff465 a0fd4dab .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-net-kasan-gce 2022/10/11 17:07 net-next 0326074ff465 1353c374 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-net-kasan-gce 2022/10/11 02:43 net-next 0326074ff465 2b253ced .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-net-kasan-gce 2022/10/09 03:29 net-next 0326074ff465 aea5da89 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-net-kasan-gce 2022/10/06 23:06 net-next 0326074ff465 8a212197 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-net-kasan-gce 2022/10/05 11:34 net-next 0326074ff465 267e3bb1 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-net-kasan-gce 2022/10/04 07:52 net-next 450a580fc4b5 feb56351 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-net-kasan-gce 2022/10/02 00:13 net-next bc37b24ee05e feb56351 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-net-kasan-gce 2022/10/01 14:33 net-next 5fcc2cfc14ae feb56351 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-net-kasan-gce 2022/02/28 02:52 net-next b42a738e409b 45a13a73 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-linux-next-kasan-gce-root 2022/11/10 05:20 linux-next 0cdb3579f1ee b2488a87 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-linux-next-kasan-gce-root 2022/06/20 06:13 linux-next 07dc787be231 8f633d84 .config log report info KASAN: use-after-free Read in cfusbl_device_notify
ci-upstream-kasan-gce-selinux-root 2022/10/16 14:54 upstream 55be6084c8e0 67cb024c .config log report info KASAN: slab-out-of-bounds Read in cfusbl_device_notify
* Struck through repros no longer work on HEAD.