------------[ cut here ]------------ kernfs_put: syz1/memory.events.local: released with incorrect active_ref 0 WARNING: CPU: 1 PID: 309 at fs/kernfs/dir.c:531 kernfs_put.part.0+0x433/0x540 Modules linked in: CPU: 1 PID: 309 Comm: kworker/1:3 Not tainted 5.19.0-rc5-next-20220705 #1 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014 Workqueue: events kernfs_notify_workfn RIP: 0010:kernfs_put.part.0+0x433/0x540 Code: 03 80 3c 18 00 0f 85 ea 00 00 00 4d 8b 7d 38 e8 73 0b a7 ff 48 8b 14 24 44 89 f1 4c 89 fe 48 c7 c7 e0 58 72 84 e8 93 ac 6c 02 <0f> 0b e9 b9 fc ff ff 48 89 ef e8 0e b3 d9 ff e9 c1 fd ff ff e8 04 RSP: 0018:ffff8880181afbd8 EFLAGS: 00010286 RAX: 0000000000000000 RBX: dffffc0000000000 RCX: 0000000000000000 RDX: ffff88800f991ac0 RSI: ffffffff812bd348 RDI: ffffed1003035f6d RBP: ffff888008e224c0 R08: 0000000000000005 R09: 0000000000000000 R10: 0000000080000000 R11: 0000000000000001 R12: ffff888008e22488 R13: ffff88801a578ae0 R14: 0000000000000000 R15: ffff888008337aa0 FS: 0000000000000000(0000) GS:ffff88806cf00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000000 CR3: 000000003452e000 CR4: 0000000000350ee0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000ffff4ff0 DR7: 0000000000000400 Call Trace: kernfs_put+0x42/0x50 kernfs_notify_workfn+0x417/0x560 process_one_work+0xa0f/0x1690 worker_thread+0x637/0x1250 kthread+0x2ed/0x3a0 ret_from_fork+0x22/0x30 irq event stamp: 1174373 hardirqs last enabled at (1174385): [] __up_console_sem+0x78/0x80 hardirqs last disabled at (1174396): [] __up_console_sem+0x5d/0x80 softirqs last enabled at (1174202): [] __irq_exit_rcu+0x113/0x170 softirqs last disabled at (1174197): [] __irq_exit_rcu+0x113/0x170 ---[ end trace 0000000000000000 ]--- ================================================================== BUG: KASAN: use-after-free in kernfs_notify+0x327/0x350 Read of size 2 at addr ffff888008e22520 by task syz-executor.1/6623 CPU: 1 PID: 6623 Comm: syz-executor.1 Tainted: G W 5.19.0-rc5-next-20220705 #1 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014 Call Trace: dump_stack_lvl+0x8b/0xb3 print_report.cold+0x5e/0x5e1 kasan_report+0xb1/0x1b0 kernfs_notify+0x327/0x350 cgroup_file_notify+0xf5/0x1a0 shrink_node+0x727/0x1d10 do_try_to_free_pages+0x3c7/0x1670 try_to_free_mem_cgroup_pages+0x304/0x880 try_charge_memcg+0x4cd/0x1440 mem_cgroup_charge_skmem+0x7c/0x1b0 sock_setsockopt+0x2080/0x34a0 __sys_setsockopt+0x258/0x2a0 __x64_sys_setsockopt+0xba/0x150 do_syscall_64+0x3b/0x90 entry_SYSCALL_64_after_hwframe+0x46/0xb0 RIP: 0033:0x7fa7852b1b19 Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 bc ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007fa782827188 EFLAGS: 00000246 ORIG_RAX: 0000000000000036 RAX: ffffffffffffffda RBX: 00007fa7853c4f60 RCX: 00007fa7852b1b19 RDX: 0000000000000049 RSI: 0000000000000001 RDI: 0000000000000004 RBP: 00007fa78530bf6d R08: 0000000000000010 R09: 0000000000000000 R10: 0000000020000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007ffdaa9bcd9f R14: 00007fa782827300 R15: 0000000000022000 Allocated by task 294: kasan_save_stack+0x1e/0x40 __kasan_slab_alloc+0x66/0x80 kmem_cache_alloc+0x1b1/0x490 __kernfs_new_node+0xd4/0x8b0 kernfs_new_node+0x93/0x120 __kernfs_create_file+0x51/0x350 cgroup_addrm_files+0x3e2/0x9d0 css_populate_dir+0x19b/0x450 cgroup_apply_control_enable+0x3ae/0xa40 cgroup_mkdir+0x824/0x11f0 kernfs_iop_mkdir+0x149/0x1d0 vfs_mkdir+0x417/0x6a0 do_mkdirat+0x17b/0x2e0 __x64_sys_mkdir+0xf2/0x140 do_syscall_64+0x3b/0x90 entry_SYSCALL_64_after_hwframe+0x46/0xb0 Freed by task 309: kasan_save_stack+0x1e/0x40 kasan_set_track+0x21/0x30 kasan_set_free_info+0x20/0x30 __kasan_slab_free+0x108/0x190 kmem_cache_free+0xfb/0x600 kernfs_put.part.0+0x2c7/0x540 kernfs_put+0x42/0x50 kernfs_notify_workfn+0x417/0x560 process_one_work+0xa0f/0x1690 worker_thread+0x637/0x1250 kthread+0x2ed/0x3a0 ret_from_fork+0x22/0x30 The buggy address belongs to the object at ffff888008e22488 which belongs to the cache kernfs_node_cache of size 168 The buggy address is located 152 bytes inside of 168-byte region [ffff888008e22488, ffff888008e22530) The buggy address belongs to the physical page: page:00000000b8f9054e refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x8e22 flags: 0x100000000000200(slab|node=0|zone=1) raw: 0100000000000200 0000000000000000 dead000000000122 ffff8880080358c0 raw: 0000000000000000 0000000000110011 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff888008e22400: 00 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc ffff888008e22480: fc fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff888008e22500: fb fb fb fb fb fb fc fc fc fc fc fc fc fc 00 00 ^ ffff888008e22580: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff888008e22600: 00 00 00 fc fc fc fc fc fc fc fc 00 00 00 00 00 ==================================================================