syzbot


KASAN: use-after-free Read in cfusbl_device_notify

Status: fixed on 2023/06/08 14:41
Subsystems: net
[Documentation on labels]
Reported-by: syzbot+b563d33852b893653a9e@syzkaller.appspotmail.com
Fix commit: 9781e98a9711 net: caif: Fix use-after-free in cfusbl_device_notify()
First crash: 819d, last: 445d
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
  
Discussions (3)
Title Replies (including bot) Last reply
[PATCH net v2] net: caif: Fix use-after-free in cfusbl_device_notify() 2 (2) 2023/03/03 06:30
[PATCH net] net: caif: Fix use-after-free in cfusbl_device_notify() 3 (3) 2023/02/28 16:52
[syzbot] KASAN: use-after-free Read in cfusbl_device_notify 0 (1) 2022/10/12 16:59

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 (341):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2022/06/24 15:54 upstream 92f20ff72066 a5dbd430 .config console log report syz C ci-upstream-kasan-gce-selinux-root KASAN: use-after-free Read in cfusbl_device_notify
2022/05/15 05:21 upstream 2fe1020d73ca 744a39e2 .config strace log report syz C ci-upstream-kasan-gce-smack-root KASAN: use-after-free Read in cfusbl_device_notify
2022/04/07 03:13 upstream 3e732ebf7316 97582466 .config console log report syz C ci-upstream-kasan-gce-root KASAN: use-after-free Read in cfusbl_device_notify
2022/05/13 22:20 linux-next 1e1b28b936ae 107f6434 .config strace log report syz C ci-upstream-linux-next-kasan-gce-root KASAN: use-after-free Read in cfusbl_device_notify
2023/02/20 19:35 upstream c9c3395d5e3d 4f5f5209 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root KASAN: use-after-free Read in cfusbl_device_notify
2023/02/20 18:15 upstream c9c3395d5e3d 4f5f5209 .config console log report info ci-qemu-upstream KASAN: use-after-free Read in cfusbl_device_notify
2023/02/20 12:35 upstream c9c3395d5e3d bcdf85f8 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root KASAN: use-after-free Read in cfusbl_device_notify
2023/02/16 12:08 upstream 033c40a89f55 7338e3c4 .config console log report info ci-upstream-kasan-gce-selinux-root KASAN: use-after-free Read in cfusbl_device_notify
2023/02/15 15:58 upstream e1c04510f521 6be0f1f5 .config console log report info ci-upstream-kasan-gce-selinux-root KASAN: use-after-free Read in cfusbl_device_notify
2023/02/15 03:03 upstream e1c04510f521 1d6b4af7 .config console log report info ci-upstream-kasan-gce-selinux-root KASAN: use-after-free Read in cfusbl_device_notify
2023/02/07 12:53 upstream 05ecb680708a 7d00f0e1 .config console log report info ci-upstream-kasan-gce-selinux-root KASAN: use-after-free Read in cfusbl_device_notify
2023/02/06 17:47 upstream d2d11f342b17 0a9c11b6 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root KASAN: use-after-free Read in cfusbl_device_notify
2023/02/05 06:08 upstream 95078069c1e7 be607b78 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root KASAN: use-after-free Read in cfusbl_device_notify
2023/01/06 10:21 upstream 1f5abbd77e2c 1dac8c7a .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root KASAN: use-after-free Read in cfusbl_device_notify
2023/01/03 08:45 upstream 69b41ac87e4a ab32d508 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root KASAN: use-after-free Read in cfusbl_device_notify
2023/01/02 17:34 upstream 88603b6dc419 ab32d508 .config console log report info ci-upstream-kasan-gce-root KASAN: use-after-free Read in cfusbl_device_notify
2023/01/01 09:51 upstream e4cf7c25bae5 ab32d508 .config console log report info ci-qemu-upstream KASAN: use-after-free Read in cfusbl_device_notify
2022/12/21 03:47 upstream b6bb9676f216 d3e76707 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root KASAN: use-after-free Read in cfusbl_device_notify
2022/12/20 12:29 upstream 6feb57c2fd7c d3e76707 .config console log report info ci-upstream-kasan-gce-selinux-root KASAN: use-after-free Read in cfusbl_device_notify
2022/12/18 09:29 upstream f9ff5644bcc0 05494336 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root KASAN: use-after-free Read in cfusbl_device_notify
2022/12/12 00:45 upstream 830b3c68c1fb 67be1ae7 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root KASAN: use-after-free Read in cfusbl_device_notify
2022/12/10 10:39 upstream 3ecc37918c80 67be1ae7 .config console log report info ci-upstream-kasan-gce-selinux-root KASAN: use-after-free Read in cfusbl_device_notify
2022/12/09 11:44 upstream 0d1409e4ff08 1034e5fa .config console log report info ci-upstream-kasan-gce-selinux-root KASAN: use-after-free Read in cfusbl_device_notify
2022/12/09 03:00 upstream f3e8416619ce 1034e5fa .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root KASAN: use-after-free Read in cfusbl_device_notify
2022/11/02 06:58 upstream 200204f56f3b 08977f5d .config console log report info ci-qemu-upstream-386 KASAN: use-after-free Read in cfusbl_device_notify
2023/02/27 03:38 net-old aaa3c08ee065 ee50e71c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-this-kasan-gce KASAN: use-after-free Read in cfusbl_device_notify
2023/02/12 16:06 net-old 20ab8432420e 93e26d60 .config console log report info ci-upstream-net-this-kasan-gce KASAN: use-after-free Read in cfusbl_device_notify
2023/01/06 20:51 net-old c244c092f1ed 1dac8c7a .config console log report info ci-upstream-net-this-kasan-gce KASAN: use-after-free Read in cfusbl_device_notify
2022/12/30 11:22 net-old 1573c6882018 44712fbc .config console log report info ci-upstream-net-this-kasan-gce KASAN: use-after-free Read in cfusbl_device_notify
2022/12/25 23:50 net-old be1236fce5f4 9da18ae8 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-this-kasan-gce KASAN: use-after-free Read in cfusbl_device_notify
2022/12/22 07:16 net-old 609d3bc62305 4067838e .config console log report info ci-upstream-net-this-kasan-gce KASAN: use-after-free Read in cfusbl_device_notify
2022/12/13 17:17 net-old e095493091e8 e660de91 .config console log report info ci-upstream-net-this-kasan-gce KASAN: use-after-free Read in cfusbl_device_notify
2022/12/12 21:19 net-old 5fe02e046e64 67be1ae7 .config console log report info ci-upstream-net-this-kasan-gce KASAN: use-after-free Read in cfusbl_device_notify
2022/12/09 16:39 net-old 01de1123322e 67be1ae7 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-this-kasan-gce KASAN: use-after-free Read in cfusbl_device_notify
2022/12/09 13:46 net-old 01de1123322e 67be1ae7 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-this-kasan-gce KASAN: use-after-free Read in cfusbl_device_notify
2022/12/09 00:54 net-old f8bac7f9fdb0 1034e5fa .config console log report info ci-upstream-net-this-kasan-gce KASAN: use-after-free Read in cfusbl_device_notify
2022/12/05 03:24 net-old 5c306de8f787 e080de16 .config console log report info ci-upstream-net-this-kasan-gce KASAN: use-after-free Read in cfusbl_device_notify
2023/02/21 03:11 net-next-old 3fcdf2dfefb6 4f5f5209 .config console log report info ci-upstream-net-kasan-gce KASAN: use-after-free Read in cfusbl_device_notify
2023/02/16 17:57 net-next-old 10d13421a6ae 7338e3c4 .config console log report info ci-upstream-net-kasan-gce KASAN: use-after-free Read in cfusbl_device_notify
2023/01/16 00:22 net-next-old 298bfe27d112 a63719e7 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-kasan-gce KASAN: use-after-free Read in cfusbl_device_notify
2023/01/10 19:04 net-next-old cbdbb58b6c79 1dac8c7a .config console log report info ci-upstream-net-kasan-gce KASAN: use-after-free Read in cfusbl_device_notify
2022/02/28 02:52 net-next-old b42a738e409b 45a13a73 .config console log report info ci-upstream-net-kasan-gce KASAN: use-after-free Read in cfusbl_device_notify
2022/12/21 00:06 linux-next e45fb347b630 d3e76707 .config console log report info ci-upstream-linux-next-kasan-gce-root KASAN: use-after-free Read in cfusbl_device_notify
2022/12/15 16:53 linux-next 459c73db4069 6f9c033e .config console log report info ci-upstream-linux-next-kasan-gce-root KASAN: use-after-free Read in cfusbl_device_notify
2023/03/04 18:05 upstream 0988a0ea7919 f8902b57 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root KASAN: slab-use-after-free Read in cfusbl_device_notify
2023/03/04 01:13 upstream 0a3f9a6b0265 f8902b57 .config console log report info ci-upstream-kasan-gce-root KASAN: slab-use-after-free Read in cfusbl_device_notify
2023/03/03 17:00 upstream 2eb29d59ddf0 f8902b57 .config console log report info ci-qemu-upstream KASAN: slab-use-after-free Read in cfusbl_device_notify
2023/03/02 05:04 upstream ee3f96b16468 f8902b57 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root KASAN: slab-use-after-free Read in cfusbl_device_notify
2023/03/01 20:15 upstream 1d2aea1bcf68 f8902b57 .config console log report info ci-qemu-upstream KASAN: slab-use-after-free Read in cfusbl_device_notify
2023/02/27 05:06 upstream f3a2439f20d9 ee50e71c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root KASAN: slab-use-after-free Read in cfusbl_device_notify
2023/02/26 04:55 upstream 1ec35eadc3b4 630c6bc9 .config console log report info ci-qemu-upstream KASAN: slab-use-after-free Read in cfusbl_device_notify
2023/02/25 18:08 upstream 489fa31ea873 630c6bc9 .config console log report info ci-qemu-upstream KASAN: slab-use-after-free Read in cfusbl_device_notify
2023/02/24 05:20 upstream d2980d8d8265 630c6bc9 .config console log report info ci-qemu-upstream KASAN: slab-use-after-free Read in cfusbl_device_notify
2022/10/16 14:54 upstream 55be6084c8e0 67cb024c .config console log report info [disk image] [vmlinux] ci-upstream-kasan-gce-selinux-root KASAN: slab-out-of-bounds Read in cfusbl_device_notify
2023/03/08 23:09 net-next 10369080454d 4fc6d98d .config console log report info ci-upstream-net-kasan-gce KASAN: slab-use-after-free Read in cfusbl_device_notify
2023/02/21 01:08 linux-next d2af0fa4bfa4 4f5f5209 .config console log report info ci-upstream-linux-next-kasan-gce-root KASAN: slab-use-after-free Read in cfusbl_device_notify
* Struck through repros no longer work on HEAD.