Kernel bug: KASAN: slab-use-after-free Read in fserror_worker
Subsystem: xfs
Status: open

Crash report:
==================================================================
BUG: KASAN: slab-use-after-free in inode_state_read_once include/linux/fs.h:884 [inline]
BUG: KASAN: slab-use-after-free in iput+0x3a7/0xe80 fs/inode.c:1977
Read of size 4 at addr ffff88800ba8efb8 by task kworker/0:2/54

CPU: 0 UID: 0 PID: 54 Comm: kworker/0:2 Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
Workqueue: events fserror_worker
Call Trace:
 <TASK>
 dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120
 print_address_description mm/kasan/report.c:378 [inline]
 print_report+0xba/0x230 mm/kasan/report.c:482
 kasan_report+0x117/0x150 mm/kasan/report.c:595
 inode_state_read_once include/linux/fs.h:884 [inline]
 iput+0x3a7/0xe80 fs/inode.c:1977
 fserror_worker+0x230/0x350 fs/fserror.c:69
 process_one_work kernel/workqueue.c:3257 [inline]
 process_scheduled_works+0xaec/0x17a0 kernel/workqueue.c:3340
 worker_thread+0xda6/0x1360 kernel/workqueue.c:3421
 kthread+0x388/0x470 kernel/kthread.c:467
 ret_from_fork+0x51e/0xb90 arch/x86/kernel/process.c:158
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:246
 </TASK>

Allocated by task 5498:
 kasan_save_stack mm/kasan/common.c:57 [inline]
 kasan_save_track+0x3e/0x80 mm/kasan/common.c:78
 unpoison_slab_object mm/kasan/common.c:340 [inline]
 __kasan_slab_alloc+0x6c/0x80 mm/kasan/common.c:366
 kasan_slab_alloc include/linux/kasan.h:253 [inline]
 slab_post_alloc_hook mm/slub.c:4953 [inline]
 slab_alloc_node mm/slub.c:5263 [inline]
 kmem_cache_alloc_lru_noprof+0x35f/0x6c0 mm/slub.c:5282
 xfs_inode_alloc+0x7e/0x710 fs/xfs/xfs_icache.c:97
 xfs_iget_cache_miss fs/xfs/xfs_icache.c:635 [inline]
 xfs_iget+0xa85/0x2ce0 fs/xfs/xfs_icache.c:799
 xfs_lookup+0x321/0x630 fs/xfs/xfs_inode.c:553
 xfs_vn_lookup+0x130/0x200 fs/xfs/xfs_iops.c:327
 __lookup_slow+0x2b7/0x410 fs/namei.c:1916
 lookup_slow+0x53/0x70 fs/namei.c:1933
 ovl_lookup_positive_unlocked fs/overlayfs/namei.c:210 [inline]
 ovl_lookup_single+0x32f/0xea0 fs/overlayfs/namei.c:254
 ovl_lookup_layer+0x377/0x450 fs/overlayfs/namei.c:359
 ovl_lookup_layers fs/overlayfs/namei.c:1103 [inline]
 ovl_lookup+0x5f2/0x1c80 fs/overlayfs/namei.c:1397
 lookup_one_qstr_excl+0x131/0x360 fs/namei.c:1805
 __start_renaming+0x1db/0x410 fs/namei.c:3862
 filename_renameat2+0x38c/0x9c0 fs/namei.c:6119
 __do_sys_renameat2 fs/namei.c:6173 [inline]
 __se_sys_renameat2+0x5a/0x2c0 fs/namei.c:6168
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0x14d/0xf80 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Freed by task 5498:
 kasan_save_stack mm/kasan/common.c:57 [inline]
 kasan_save_track+0x3e/0x80 mm/kasan/common.c:78
 kasan_save_free_info+0x46/0x50 mm/kasan/generic.c:584
 poison_slab_object mm/kasan/common.c:253 [inline]
 __kasan_slab_free+0x5c/0x80 mm/kasan/common.c:285
 kasan_slab_free include/linux/kasan.h:235 [inline]
 slab_free_hook mm/slub.c:2540 [inline]
 slab_free mm/slub.c:6674 [inline]
 kmem_cache_free+0x195/0x610 mm/slub.c:6789
 rcu_do_batch kernel/rcu/tree.c:2617 [inline]
 rcu_core+0x7cd/0x1070 kernel/rcu/tree.c:2869
 handle_softirqs+0x22a/0x7c0 kernel/softirq.c:622
 __do_softirq kernel/softirq.c:656 [inline]
 invoke_softirq kernel/softirq.c:496 [inline]
 __irq_exit_rcu+0x5f/0x150 kernel/softirq.c:723
 irq_exit_rcu+0x9/0x30 kernel/softirq.c:739
 instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1056 [inline]
 sysvec_apic_timer_interrupt+0xa6/0xc0 arch/x86/kernel/apic/apic.c:1056
 asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:697

Last potentially related work creation:
 kasan_save_stack+0x3e/0x60 mm/kasan/common.c:57
 kasan_record_aux_stack+0xbd/0xd0 mm/kasan/generic.c:556
 __call_rcu_common kernel/rcu/tree.c:3131 [inline]
 call_rcu+0xee/0x890 kernel/rcu/tree.c:3251
 xfs_iget_cache_miss fs/xfs/xfs_icache.c:740 [inline]
 xfs_iget+0xb01/0x2ce0 fs/xfs/xfs_icache.c:799
 xfs_lookup+0x321/0x630 fs/xfs/xfs_inode.c:553
 xfs_vn_lookup+0x130/0x200 fs/xfs/xfs_iops.c:327
 __lookup_slow+0x2b7/0x410 fs/namei.c:1916
 lookup_slow+0x53/0x70 fs/namei.c:1933
 ovl_lookup_positive_unlocked fs/overlayfs/namei.c:210 [inline]
 ovl_lookup_single+0x32f/0xea0 fs/overlayfs/namei.c:254
 ovl_lookup_layer+0x377/0x450 fs/overlayfs/namei.c:359
 ovl_lookup_layers fs/overlayfs/namei.c:1103 [inline]
 ovl_lookup+0x5f2/0x1c80 fs/overlayfs/namei.c:1397
 lookup_one_qstr_excl+0x131/0x360 fs/namei.c:1805
 __start_renaming+0x1db/0x410 fs/namei.c:3862
 filename_renameat2+0x38c/0x9c0 fs/namei.c:6119
 __do_sys_renameat2 fs/namei.c:6173 [inline]
 __se_sys_renameat2+0x5a/0x2c0 fs/namei.c:6168
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0x14d/0xf80 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

The buggy address belongs to the object at ffff88800ba8ed00
 which belongs to the cache xfs_inode of size 1784
The buggy address is located 696 bytes inside of
 freed 1784-byte region [ffff88800ba8ed00, ffff88800ba8f3f8)

The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0xba8c
head: order:2 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
memcg:ffff8880125ab781
flags: 0xfff00000000040(head|node=0|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 00fff00000000040 ffff88803139da00 dead000000000122 0000000000000000
raw: 0000000000000000 0000000080080008 00000000f5000000 ffff8880125ab781
head: 00fff00000000040 ffff88803139da00 dead000000000122 0000000000000000
head: 0000000000000000 0000000080080008 00000000f5000000 ffff8880125ab781
head: 00fff00000000002 ffffea00002ea301 00000000ffffffff 00000000ffffffff
head: ffffffffffffffff 0000000000000000 00000000ffffffff 0000000000000004
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 2, migratetype Reclaimable, gfp_mask 0xd2050(__GFP_RECLAIMABLE|__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 5498, tgid 5497 (syz.0.17), ts 109700745240, free_ts 106973924123
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x228/0x280 mm/page_alloc.c:1884
 prep_new_page mm/page_alloc.c:1892 [inline]
 get_page_from_freelist+0x24dc/0x2580 mm/page_alloc.c:3945
 __alloc_frozen_pages_noprof+0x18d/0x380 mm/page_alloc.c:5240
 alloc_pages_mpol+0x232/0x4a0 mm/mempolicy.c:2486
 alloc_slab_page mm/slub.c:3075 [inline]
 allocate_slab+0x86/0x3a0 mm/slub.c:3248
 new_slab mm/slub.c:3302 [inline]
 ___slab_alloc+0xd90/0x1790 mm/slub.c:4656
 __slab_alloc+0x65/0x100 mm/slub.c:4779
 __slab_alloc_node mm/slub.c:4855 [inline]
 slab_alloc_node mm/slub.c:5251 [inline]
 kmem_cache_alloc_lru_noprof+0x3ed/0x6c0 mm/slub.c:5282
 xfs_inode_alloc+0x7e/0x710 fs/xfs/xfs_icache.c:97
 xfs_iget_cache_miss fs/xfs/xfs_icache.c:635 [inline]
 xfs_iget+0xa85/0x2ce0 fs/xfs/xfs_icache.c:799
 xfs_icreate+0xbe/0x170 fs/xfs/xfs_inode.c:600
 xfs_create+0x648/0xae0 fs/xfs/xfs_inode.c:721
 xfs_generic_create+0x410/0xb30 fs/xfs/xfs_iops.c:216
 xfs_vn_mkdir+0x37/0x50 fs/xfs/xfs_iops.c:309
 vfs_mkdir+0x413/0x630 fs/namei.c:5233
 filename_mkdirat+0x285/0x510 fs/namei.c:5266
page last free pid 5456 tgid 5456 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 free_pages_prepare mm/page_alloc.c:1433 [inline]
 __free_frozen_pages+0xbf8/0xd70 mm/page_alloc.c:2973
 discard_slab mm/slub.c:3346 [inline]
 __put_partials+0x146/0x170 mm/slub.c:3886
 __slab_free+0x294/0x320 mm/slub.c:5956
 qlink_free mm/kasan/quarantine.c:163 [inline]
 qlist_free_all+0x97/0x100 mm/kasan/quarantine.c:179
 kasan_quarantine_reduce+0x148/0x160 mm/kasan/quarantine.c:286
 __kasan_slab_alloc+0x22/0x80 mm/kasan/common.c:350
 kasan_slab_alloc include/linux/kasan.h:253 [inline]
 slab_post_alloc_hook mm/slub.c:4953 [inline]
 slab_alloc_node mm/slub.c:5263 [inline]
 kmem_cache_alloc_node_noprof+0x427/0x6f0 mm/slub.c:5315
 __alloc_skb+0x1d7/0x390 net/core/skbuff.c:679
 alloc_skb include/linux/skbuff.h:1383 [inline]
 nlmsg_new include/net/netlink.h:1055 [inline]
 netlink_ack+0x146/0xa50 net/netlink/af_netlink.c:2487
 netlink_rcv_skb+0x2b6/0x4b0 net/netlink/af_netlink.c:2556
 netlink_unicast_kernel net/netlink/af_netlink.c:1318 [inline]
 netlink_unicast+0x80f/0x9b0 net/netlink/af_netlink.c:1344
 netlink_sendmsg+0x813/0xb40 net/netlink/af_netlink.c:1894
 sock_sendmsg_nosec net/socket.c:727 [inline]
 __sock_sendmsg net/socket.c:742 [inline]
 __sys_sendto+0x709/0x7a0 net/socket.c:2206
 __do_sys_sendto net/socket.c:2213 [inline]
 __se_sys_sendto net/socket.c:2209 [inline]
 __x64_sys_sendto+0xde/0x100 net/socket.c:2209
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0x14d/0xf80 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Memory state around the buggy address:
 ffff88800ba8ee80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88800ba8ef00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88800ba8ef80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                        ^
 ffff88800ba8f000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88800ba8f080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================