================================================================== BUG: KASAN: use-after-free in __queue_work+0x10e/0xed0 kernel/workqueue.c:1454 Read of size 4 at addr ffffaf8010f979c0 by task syz-fuzzer/3138 CPU: 0 PID: 3138 Comm: syz-fuzzer Not tainted 5.17.0-rc1-syzkaller-00002-g0966d385830d #0 Hardware name: riscv-virtio,qemu (DT) Call Trace: [] dump_backtrace+0x2e/0x3c arch/riscv/kernel/stacktrace.c:113 [] show_stack+0x34/0x40 arch/riscv/kernel/stacktrace.c:119 [] __dump_stack lib/dump_stack.c:88 [inline] [] dump_stack_lvl+0xe4/0x150 lib/dump_stack.c:106 [] print_address_description.constprop.0+0x2a/0x330 mm/kasan/report.c:255 [] __kasan_report mm/kasan/report.c:442 [inline] [] kasan_report+0x184/0x1e0 mm/kasan/report.c:459 [] check_region_inline mm/kasan/generic.c:183 [inline] [] __asan_load4+0x6e/0x96 mm/kasan/generic.c:255 [] __queue_work+0x10e/0xed0 kernel/workqueue.c:1454 [] queue_work_on+0xe8/0xfe kernel/workqueue.c:1562 [] queue_work include/linux/workqueue.h:502 [inline] [] nci_cmd_timer+0x52/0x5e net/nfc/nci/core.c:611 [] call_timer_fn+0x164/0x698 kernel/time/timer.c:1421 [] expire_timers kernel/time/timer.c:1466 [inline] [] __run_timers.part.0+0x484/0x4e6 kernel/time/timer.c:1734 [] __run_timers kernel/time/timer.c:1715 [inline] [] run_timer_softirq+0x86/0x100 kernel/time/timer.c:1747 [] __do_softirq+0x274/0x8fc kernel/softirq.c:558 [] do_softirq_own_stack include/asm-generic/softirq_stack.h:10 [inline] [] invoke_softirq kernel/softirq.c:439 [inline] [] __irq_exit_rcu+0x142/0x1f8 kernel/softirq.c:637 [] irq_exit+0x10/0x7a kernel/softirq.c:661 [] generic_handle_arch_irq+0x48/0x54 kernel/irq/handle.c:240 [] ret_from_exception+0x0/0x10 [] skip_context_tracking+0x2a/0x62 Allocated by task 6484: stack_trace_save+0xa6/0xd8 kernel/stacktrace.c:122 kasan_save_stack+0x2c/0x58 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+0x80/0xb2 mm/kasan/common.c:524 kasan_kmalloc include/linux/kasan.h:270 [inline] __kmalloc+0x190/0x318 mm/slub.c:4424 kmalloc include/linux/slab.h:586 [inline] kzalloc.constprop.0+0x24/0x2e include/linux/slab.h:715 alloc_workqueue+0x146/0x92e kernel/workqueue.c:4325 nci_register_device+0x198/0x612 net/nfc/nci/core.c:1220 virtual_ncidev_open+0x82/0x12c drivers/nfc/virtual_ncidev.c:143 misc_open+0x272/0x2c8 drivers/char/misc.c:141 chrdev_open+0x1d4/0x478 fs/char_dev.c:414 do_dentry_open+0x2a4/0x7d4 fs/open.c:824 vfs_open+0x52/0x5e fs/open.c:959 do_open fs/namei.c:3476 [inline] path_openat+0x12b6/0x189e fs/namei.c:3609 do_filp_open+0x10e/0x22a fs/namei.c:3636 do_sys_openat2+0x174/0x31e fs/open.c:1214 do_sys_open fs/open.c:1230 [inline] __do_sys_openat fs/open.c:1246 [inline] sys_openat+0xdc/0x164 fs/open.c:1241 ret_from_syscall+0x0/0x2 Freed by task 3576: stack_trace_save+0xa6/0xd8 kernel/stacktrace.c:122 kasan_save_stack+0x2c/0x58 mm/kasan/common.c:38 kasan_set_track+0x1a/0x26 mm/kasan/common.c:45 kasan_set_free_info+0x1e/0x3a mm/kasan/generic.c:370 ____kasan_slab_free mm/kasan/common.c:366 [inline] ____kasan_slab_free+0x15e/0x180 mm/kasan/common.c:328 __kasan_slab_free+0x10/0x18 mm/kasan/common.c:374 kasan_slab_free include/linux/kasan.h:236 [inline] slab_free_hook mm/slub.c:1728 [inline] slab_free_freelist_hook+0x8e/0x1cc mm/slub.c:1754 slab_free mm/slub.c:3509 [inline] kfree+0xe0/0x3e4 mm/slub.c:4562 rcu_free_wq+0xb0/0xde kernel/workqueue.c:3542 rcu_do_batch kernel/rcu/tree.c:2527 [inline] rcu_core+0x63c/0xf36 kernel/rcu/tree.c:2778 rcu_core_si+0xc/0x14 kernel/rcu/tree.c:2795 __do_softirq+0x274/0x8fc kernel/softirq.c:558 Last potentially related work creation: stack_trace_save+0xa6/0xd8 kernel/stacktrace.c:122 kasan_save_stack+0x2c/0x58 mm/kasan/common.c:38 __kasan_record_aux_stack+0xc4/0xdc mm/kasan/generic.c:348 kasan_record_aux_stack_noalloc+0xe/0x16 mm/kasan/generic.c:358 __call_rcu kernel/rcu/tree.c:3026 [inline] call_rcu+0x8c/0x4ce kernel/rcu/tree.c:3106 pwq_unbound_release_workfn+0x1a8/0x1f8 kernel/workqueue.c:3747 process_one_work+0x654/0xffe kernel/workqueue.c:2307 worker_thread+0x360/0x8fa kernel/workqueue.c:2454 kthread+0x19e/0x1fa kernel/kthread.c:377 ret_from_exception+0x0/0x10 Second to last potentially related work creation: stack_trace_save+0xa6/0xd8 kernel/stacktrace.c:122 kasan_save_stack+0x2c/0x58 mm/kasan/common.c:38 __kasan_record_aux_stack+0xc4/0xdc mm/kasan/generic.c:348 kasan_record_aux_stack_noalloc+0xe/0x16 mm/kasan/generic.c:358 kvfree_call_rcu+0x8e/0x440 kernel/rcu/tree.c:3591 neigh_destroy+0x324/0x492 net/core/neighbour.c:888 neigh_release include/net/neighbour.h:451 [inline] neigh_cleanup_and_release net/core/neighbour.c:103 [inline] neigh_flush_dev+0x5a0/0x6b4 net/core/neighbour.c:369 __neigh_ifdown.isra.0+0x42/0x23a net/core/neighbour.c:386 neigh_ifdown+0x22/0x30 net/core/neighbour.c:403 rt6_disable_ip+0x71e/0x7f6 net/ipv6/route.c:4900 addrconf_ifdown.isra.0+0xf6/0xe96 net/ipv6/addrconf.c:3726 addrconf_notify+0xca/0x1360 net/ipv6/addrconf.c:3651 notifier_call_chain+0xb8/0x188 kernel/notifier.c:84 raw_notifier_call_chain+0x2a/0x38 kernel/notifier.c:392 call_netdevice_notifiers_info+0x9e/0x10c 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+0x228/0x340 net/core/dev.c:1520 unregister_netdevice_many+0x328/0xf50 net/core/dev.c:10392 default_device_exit_batch+0x28a/0x2dc net/core/dev.c:10945 ops_exit_list+0xcc/0xe8 net/core/net_namespace.c:173 cleanup_net+0x430/0x732 net/core/net_namespace.c:597 process_one_work+0x654/0xffe kernel/workqueue.c:2307 worker_thread+0x360/0x8fa kernel/workqueue.c:2454 kthread+0x19e/0x1fa kernel/kthread.c:377 ret_from_exception+0x0/0x10 The buggy address belongs to the object at ffffaf8010f97800 which belongs to the cache kmalloc-1k of size 1024 The buggy address is located 448 bytes inside of 1024-byte region [ffffaf8010f97800, ffffaf8010f97c00) The buggy address belongs to the page: page:ffffaf807ab0f080 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x91190 head:ffffaf807ab0f080 order:3 compound_mapcount:0 compound_pincount:0 flags: 0x9000010200(slab|head|section=18|node=0|zone=0) raw: 0000009000010200 ffffaf807a876040 0000000000000003 ffffaf8007201dc0 raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000 raw: 00000000000007ff page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd2a20(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 1992, ts 319926407700, free_ts 315336525500 __set_page_owner+0x48/0x136 mm/page_owner.c:183 set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook+0xd0/0x10a mm/page_alloc.c:2427 prep_new_page mm/page_alloc.c:2434 [inline] get_page_from_freelist+0x8da/0x12d8 mm/page_alloc.c:4165 __alloc_pages+0x150/0x3b6 mm/page_alloc.c:5389 alloc_pages+0x132/0x2a6 mm/mempolicy.c:2271 alloc_slab_page.constprop.0+0xc2/0xfa mm/slub.c:1799 allocate_slab mm/slub.c:1944 [inline] new_slab+0x76/0x2cc mm/slub.c:2004 ___slab_alloc+0x56e/0x918 mm/slub.c:3018 __slab_alloc.constprop.0+0x50/0x8c mm/slub.c:3105 slab_alloc_node mm/slub.c:3196 [inline] __kmalloc_node_track_caller+0x26c/0x362 mm/slub.c:4957 kmalloc_reserve net/core/skbuff.c:354 [inline] __alloc_skb+0xee/0x2e4 net/core/skbuff.c:426 __napi_alloc_skb+0x72/0x214 net/core/skbuff.c:568 napi_alloc_skb include/linux/skbuff.h:3005 [inline] page_to_skb+0x16e/0x70e drivers/net/virtio_net.c:437 receive_mergeable drivers/net/virtio_net.c:1039 [inline] receive_buf+0xa20/0x3e50 drivers/net/virtio_net.c:1149 virtnet_receive drivers/net/virtio_net.c:1441 [inline] virtnet_poll+0x39c/0x986 drivers/net/virtio_net.c:1550 __napi_poll+0x7c/0x358 net/core/dev.c:6365 page last free stack trace: __reset_page_owner+0x4a/0xea mm/page_owner.c:142 reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1352 [inline] free_pcp_prepare+0x29c/0x45e mm/page_alloc.c:1404 free_unref_page_prepare mm/page_alloc.c:3325 [inline] free_unref_page+0x6a/0x31e mm/page_alloc.c:3404 __put_single_page mm/swap.c:99 [inline] __put_page+0xf2/0x100 mm/swap.c:130 folio_put include/linux/mm.h:1199 [inline] put_page include/linux/mm.h:1237 [inline] anon_pipe_buf_release+0x154/0x19a fs/pipe.c:138 pipe_buf_release include/linux/pipe_fs_i.h:203 [inline] pipe_read+0x3f2/0xa4c fs/pipe.c:323 call_read_iter include/linux/fs.h:2068 [inline] new_sync_read+0x3ae/0x3d8 fs/read_write.c:400 vfs_read+0x2ce/0x324 fs/read_write.c:481 ksys_read+0x1c4/0x224 fs/read_write.c:619 __do_sys_read fs/read_write.c:629 [inline] sys_read+0x28/0x36 fs/read_write.c:627 ret_from_syscall+0x0/0x2 Memory state around the buggy address: ffffaf8010f97880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffffaf8010f97900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffffaf8010f97980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffffaf8010f97a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffffaf8010f97a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000 Oops [#1] Modules linked in: CPU: 0 PID: 3138 Comm: syz-fuzzer Tainted: G B 5.17.0-rc1-syzkaller-00002-g0966d385830d #0 Hardware name: riscv-virtio,qemu (DT) epc : __queue_work+0x242/0xed0 kernel/workqueue.c:1476 ra : __queue_work+0x242/0xed0 kernel/workqueue.c:1476 epc : ffffffff800924a4 ra : ffffffff800924a4 sp : ffffaf8024d078f0 gp : ffffffff85863ac0 tp : ffffaf800e53c8c0 t0 : ffffffff86bcb657 t1 : fffff5ef017b801f t2 : 0000000000000000 s0 : ffffaf8024d07980 s1 : ffffaf805a9d5840 a0 : 0000000000000000 a1 : 0000000000000008 a2 : 0000000000000000 a3 : ffffffff800924a4 a4 : ffffffff85892ec8 a5 : 0000000000000001 a6 : 0000000000f00000 a7 : ffffaf800bdc00ff s2 : 0000000000000000 s3 : ffffaf800bdc00f8 s4 : ffffaf8010f97800 s5 : ffffaf8007229800 s6 : 0000000000000000 s7 : 0000000000000008 s8 : ffffffff83449840 s9 : ffffffff86c1a620 s10: ffffaf8010f979c0 s11: 0000000000000000 t3 : 0000000061736944 t4 : fffff5ef017b801f t5 : fffff5ef017b8020 t6 : ffffaf8024d07338 status: 0000000000000100 badaddr: 0000000000000000 cause: 000000000000000d [] queue_work_on+0xe8/0xfe kernel/workqueue.c:1562 [] queue_work include/linux/workqueue.h:502 [inline] [] nci_cmd_timer+0x52/0x5e net/nfc/nci/core.c:611 [] call_timer_fn+0x164/0x698 kernel/time/timer.c:1421 [] expire_timers kernel/time/timer.c:1466 [inline] [] __run_timers.part.0+0x484/0x4e6 kernel/time/timer.c:1734 [] __run_timers kernel/time/timer.c:1715 [inline] [] run_timer_softirq+0x86/0x100 kernel/time/timer.c:1747 [] __do_softirq+0x274/0x8fc kernel/softirq.c:558 [] do_softirq_own_stack include/asm-generic/softirq_stack.h:10 [inline] [] invoke_softirq kernel/softirq.c:439 [inline] [] __irq_exit_rcu+0x142/0x1f8 kernel/softirq.c:637 [] irq_exit+0x10/0x7a kernel/softirq.c:661 [] generic_handle_arch_irq+0x48/0x54 kernel/irq/handle.c:240 [] ret_from_exception+0x0/0x10 [] skip_context_tracking+0x2a/0x62 ---[ end trace 0000000000000000 ]---