================================================================== BUG: KASAN: use-after-free in __queue_work+0x10e/0xed0 kernel/workqueue.c:1454 Read of size 4 at addr ffffaf800c3ce9c0 by task syz-executor.1/2057 CPU: 1 PID: 2057 Comm: syz-executor.1 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 [] raw_spin_rq_unlock_irq kernel/sched/sched.h:1330 [inline] [] finish_lock_switch kernel/sched/core.c:4746 [inline] [] finish_task_switch.isra.0+0x152/0x420 kernel/sched/core.c:4864 Allocated by task 8190: 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 6235: 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_periodic_work+0x688/0x7c2 net/core/neighbour.c:970 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 ffffaf800c3ce800 which belongs to the cache kmalloc-1k of size 1024 The buggy address is located 448 bytes inside of 1024-byte region [ffffaf800c3ce800, ffffaf800c3cec00) The buggy address belongs to the page: page:ffffaf807a9ba040 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffffaf800c3cf800 pfn:0x8c5c8 head:ffffaf807a9ba040 order:3 compound_mapcount:0 compound_pincount:0 flags: 0x8800010200(slab|head|section=17|node=0|zone=0) raw: 0000008800010200 ffffaf807a9e3388 ffffaf807aa42008 ffffaf8007201dc0 raw: ffffaf800c3cf800 000000000010000e 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 0xd2040(__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 1840, ts 134611246800, free_ts 134553213500 __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+0x25a/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] slab_alloc mm/slub.c:3238 [inline] __kmalloc+0x268/0x318 mm/slub.c:4420 kmalloc include/linux/slab.h:586 [inline] kzalloc include/linux/slab.h:715 [inline] tomoyo_init_log+0xd00/0x14cc security/tomoyo/audit.c:275 tomoyo_supervisor+0x250/0xc1e security/tomoyo/common.c:2097 tomoyo_audit_env_log security/tomoyo/environ.c:36 [inline] tomoyo_env_perm+0x164/0x184 security/tomoyo/environ.c:63 tomoyo_environ security/tomoyo/domain.c:672 [inline] tomoyo_find_next_domain+0xdaa/0x1192 security/tomoyo/domain.c:879 tomoyo_bprm_check_security security/tomoyo/tomoyo.c:101 [inline] tomoyo_bprm_check_security+0xdc/0x136 security/tomoyo/tomoyo.c:91 security_bprm_check+0x44/0x96 security/security.c:866 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 free_the_page mm/page_alloc.c:706 [inline] __free_pages+0xe2/0x112 mm/page_alloc.c:5474 __free_slab+0x122/0x27c mm/slub.c:2028 free_slab mm/slub.c:2043 [inline] discard_slab+0x4c/0x7a mm/slub.c:2049 __unfreeze_partials+0x16a/0x18e mm/slub.c:2536 put_cpu_partial+0xf6/0x162 mm/slub.c:2612 __slab_free+0x166/0x29c mm/slub.c:3378 do_slab_free mm/slub.c:3497 [inline] ___cache_free+0x17c/0x354 mm/slub.c:3516 qlink_free mm/kasan/quarantine.c:157 [inline] qlist_free_all+0x7c/0x132 mm/kasan/quarantine.c:176 kasan_quarantine_reduce+0x14c/0x1c8 mm/kasan/quarantine.c:283 __kasan_slab_alloc+0x5c/0x98 mm/kasan/common.c:446 kasan_slab_alloc include/linux/kasan.h:260 [inline] slab_post_alloc_hook mm/slab.h:732 [inline] slab_alloc_node mm/slub.c:3230 [inline] slab_alloc mm/slub.c:3238 [inline] __kmalloc+0x156/0x318 mm/slub.c:4420 kmalloc include/linux/slab.h:586 [inline] tomoyo_add_entry security/tomoyo/common.c:2031 [inline] tomoyo_supervisor+0x31a/0xc1e security/tomoyo/common.c:2103 tomoyo_audit_env_log security/tomoyo/environ.c:36 [inline] tomoyo_env_perm+0x164/0x184 security/tomoyo/environ.c:63 Memory state around the buggy address: ffffaf800c3ce880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffffaf800c3ce900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffffaf800c3ce980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffffaf800c3cea00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffffaf800c3cea80: 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: 1 PID: 2057 Comm: syz-executor.1 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 : ffffaf80108bb3c0 gp : ffffffff85863ac0 tp : ffffaf800af99840 t0 : ffffffff86bcb657 t1 : fffff5ef019a181f t2 : 0000000000000000 s0 : ffffaf80108bb450 s1 : ffffaf805a9f1840 a0 : 0000000000000000 a1 : 0000000000000008 a2 : 0000000000000000 a3 : ffffffff800924a4 a4 : ffffffff85892ec8 a5 : 0000000000000001 a6 : 0000000000f00000 a7 : ffffaf800cd0c0ff s2 : 0000000000000000 s3 : ffffaf800cd0c0f8 s4 : ffffaf800c3ce800 s5 : ffffaf8007229800 s6 : 0000000000000001 s7 : 0000000000000008 s8 : ffffffff83449840 s9 : ffffffff86c1a620 s10: ffffaf800c3ce9c0 s11: 0000000000000000 t3 : 0000000061736944 t4 : fffff5ef019a181f t5 : fffff5ef019a1820 t6 : ffffaf80108badf8 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 [] raw_spin_rq_unlock_irq kernel/sched/sched.h:1330 [inline] [] finish_lock_switch kernel/sched/core.c:4746 [inline] [] finish_task_switch.isra.0+0x152/0x420 kernel/sched/core.c:4864 ---[ end trace 0000000000000000 ]---