BUG: sleeping function called from invalid context at kernel/locking/mutex.c:580 in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 5607, name: syz-executor.0 preempt_count: 1, expected: 0 RCU nest depth: 0, expected: 0 4 locks held by syz-executor.0/5607: #0: ffff888029552868 (&f->f_pos_lock){+.+.}-{3:3}, at: __fdget_pos+0x254/0x2f0 #1: ffff88807e042460 (sb_writers#13){.+.+}-{0:0}, at: vfs_write+0x27f/0xc50 #2: ffff88807972c3b0 (&sbi->cp_rwsem){.+.+}-{3:3}, at: f2fs_do_write_data_page+0x1003/0x27c0 #3: ffff888073ef3118 (&et->lock){++++}-{2:2}, at: __update_extent_tree_range+0x42f/0x1ea0 Preemption disabled at: [<0000000000000000>] 0x0 CPU: 1 PID: 5607 Comm: syz-executor.0 Not tainted 6.2.0-rc5-syzkaller-00047-g7c46948a6e9c-dirty #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/16/2023 Call Trace: dump_stack_lvl+0x1b5/0x2a0 __might_resched+0x4f6/0x6c0 __mutex_lock_common+0xbf/0x2630 mutex_lock_nested+0x1b/0x20 __update_extent_tree_range+0x138e/0x1ea0 f2fs_update_read_extent_cache+0x41e/0x590 f2fs_outplace_write_data+0x200/0x3d0 f2fs_do_write_data_page+0x1393/0x27c0 f2fs_write_single_data_page+0x14c1/0x2140 f2fs_write_data_pages+0x1948/0x2ed0 do_writepages+0x3a6/0x660 filemap_fdatawrite_wbc+0x125/0x180 file_write_and_wait_range+0x21f/0x320 f2fs_do_sync_file+0x7b6/0x1de0 f2fs_file_write_iter+0x7fc/0x2c20 vfs_write+0x7dd/0xc50 ksys_write+0x17c/0x2a0 do_syscall_64+0x41/0xc0 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7f0f6228c0c9 Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 00 00 90 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 b8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f0f6309c168 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 00007f0f623abf80 RCX: 00007f0f6228c0c9 RDX: 00000000000ffe00 RSI: 0000000020004200 RDI: 0000000000000004 RBP: 00007f0f622e7ae9 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007ffd27f0235f R14: 00007f0f6309c300 R15: 0000000000022000 ============================= [ BUG: Invalid wait context ] 6.2.0-rc5-syzkaller-00047-g7c46948a6e9c-dirty #0 Tainted: G W ----------------------------- syz-executor.0/5607 is trying to lock: ffff88807972cc58 (&eti->extent_tree_lock){+.+.}-{3:3}, at: __update_extent_tree_range+0x138e/0x1ea0 other info that might help us debug this: context-{4:4} 4 locks held by syz-executor.0/5607: #0: ffff888029552868 (&f->f_pos_lock){+.+.}-{3:3}, at: __fdget_pos+0x254/0x2f0 #1: ffff88807e042460 (sb_writers#13){.+.+}-{0:0}, at: vfs_write+0x27f/0xc50 #2: ffff88807972c3b0 (&sbi->cp_rwsem){.+.+}-{3:3}, at: f2fs_do_write_data_page+0x1003/0x27c0 #3: ffff888073ef3118 (&et->lock){++++}-{2:2}, at: __update_extent_tree_range+0x42f/0x1ea0 stack backtrace: CPU: 1 PID: 5607 Comm: syz-executor.0 Tainted: G W 6.2.0-rc5-syzkaller-00047-g7c46948a6e9c-dirty #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/16/2023 Call Trace: dump_stack_lvl+0x1b5/0x2a0 __lock_acquire+0x14b1/0x1f80 lock_acquire+0x20b/0x600 __mutex_lock_common+0x1c2/0x2630 mutex_lock_nested+0x1b/0x20 __update_extent_tree_range+0x138e/0x1ea0 f2fs_update_read_extent_cache+0x41e/0x590 f2fs_outplace_write_data+0x200/0x3d0 f2fs_do_write_data_page+0x1393/0x27c0 f2fs_write_single_data_page+0x14c1/0x2140 f2fs_write_data_pages+0x1948/0x2ed0 do_writepages+0x3a6/0x660 filemap_fdatawrite_wbc+0x125/0x180 file_write_and_wait_range+0x21f/0x320 f2fs_do_sync_file+0x7b6/0x1de0 f2fs_file_write_iter+0x7fc/0x2c20 vfs_write+0x7dd/0xc50 ksys_write+0x17c/0x2a0 do_syscall_64+0x41/0xc0 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7f0f6228c0c9 Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 00 00 90 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 b8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f0f6309c168 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 00007f0f623abf80 RCX: 00007f0f6228c0c9 RDX: 00000000000ffe00 RSI: 0000000020004200 RDI: 0000000000000004 RBP: 00007f0f622e7ae9 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007ffd27f0235f R14: 00007f0f6309c300 R15: 0000000000022000 ================================================================== BUG: KASAN: use-after-free in __try_merge_extent_node+0xbbd/0x10a0 Read of size 4 at addr ffff888073ef30d4 by task syz-executor.0/5607 CPU: 1 PID: 5607 Comm: syz-executor.0 Tainted: G W 6.2.0-rc5-syzkaller-00047-g7c46948a6e9c-dirty #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/16/2023 Call Trace: dump_stack_lvl+0x1b5/0x2a0 print_report+0x163/0x4c0 kasan_report+0xce/0x100 __try_merge_extent_node+0xbbd/0x10a0 __update_extent_tree_range+0x149a/0x1ea0 f2fs_update_read_extent_cache+0x41e/0x590 f2fs_outplace_write_data+0x200/0x3d0 f2fs_do_write_data_page+0x1393/0x27c0 f2fs_write_single_data_page+0x14c1/0x2140 f2fs_write_data_pages+0x1948/0x2ed0 do_writepages+0x3a6/0x660 filemap_fdatawrite_wbc+0x125/0x180 file_write_and_wait_range+0x21f/0x320 f2fs_do_sync_file+0x7b6/0x1de0 f2fs_file_write_iter+0x7fc/0x2c20 vfs_write+0x7dd/0xc50 ksys_write+0x17c/0x2a0 do_syscall_64+0x41/0xc0 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7f0f6228c0c9 Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 00 00 90 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 b8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f0f6309c168 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 00007f0f623abf80 RCX: 00007f0f6228c0c9 RDX: 00000000000ffe00 RSI: 0000000020004200 RDI: 0000000000000004 RBP: 00007f0f622e7ae9 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007ffd27f0235f R14: 00007f0f6309c300 R15: 0000000000022000 Allocated by task 5607: kasan_set_track+0x40/0x70 __kasan_slab_alloc+0x69/0x80 slab_post_alloc_hook+0x68/0x390 kmem_cache_alloc+0x12c/0x280 __grab_extent_tree+0x183/0x400 f2fs_init_extent_tree+0x214/0x450 f2fs_new_inode+0xdb4/0x1090 __f2fs_tmpfile+0xa5/0x380 f2fs_ioc_start_atomic_write+0x419/0x970 __f2fs_ioctl+0x1ace/0xb2b0 __se_sys_ioctl+0xf1/0x160 do_syscall_64+0x41/0xc0 entry_SYSCALL_64_after_hwframe+0x63/0xcd Freed by task 5625: kasan_set_track+0x40/0x70 kasan_save_free_info+0x2b/0x40 ____kasan_slab_free+0xd6/0x120 kmem_cache_free+0x2b5/0x580 __destroy_extent_tree+0x311/0x720 f2fs_destroy_extent_tree+0x17/0x30 f2fs_evict_inode+0x467/0x1650 evict+0x2a4/0x620 f2fs_abort_atomic_write+0xda/0x440 __f2fs_ioctl+0x315c/0xb2b0 __se_sys_ioctl+0xf1/0x160 do_syscall_64+0x41/0xc0 entry_SYSCALL_64_after_hwframe+0x63/0xcd The buggy address belongs to the object at ffff888073ef30d0 which belongs to the cache f2fs_extent_tree of size 144 The buggy address is located 4 bytes inside of 144-byte region [ffff888073ef30d0, ffff888073ef3160) The buggy address belongs to the physical page: page:ffffea0001cfbcc0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x73ef3 flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000000200 ffff88801bc25780 dead000000000122 0000000000000000 raw: 0000000000000000 0000000080130013 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 0, migratetype Reclaimable, gfp_mask 0x112c50(GFP_NOFS|__GFP_NOWARN|__GFP_NORETRY|__GFP_HARDWALL|__GFP_RECLAIMABLE), pid 5607, tgid 5606 (syz-executor.0), ts 91258803693, free_ts 90786584572 get_page_from_freelist+0x3403/0x3580 __alloc_pages+0x291/0x7e0 alloc_slab_page+0x6a/0x160 new_slab+0x84/0x2f0 ___slab_alloc+0xa07/0x1000 kmem_cache_alloc+0x1b0/0x280 __grab_extent_tree+0x183/0x400 f2fs_init_extent_tree+0x214/0x450 f2fs_new_inode+0xdb4/0x1090 f2fs_create+0x197/0x530 path_openat+0x12b9/0x2e30 do_filp_open+0x26d/0x500 do_sys_openat2+0x128/0x4f0 __x64_sys_openat+0x247/0x290 do_syscall_64+0x41/0xc0 entry_SYSCALL_64_after_hwframe+0x63/0xcd page last free stack trace: free_unref_page_prepare+0xf3a/0x1040 free_unref_page+0x37/0x3f0 __unfreeze_partials+0x1b1/0x1f0 put_cpu_partial+0x106/0x170 qlist_free_all+0x22/0x60 kasan_quarantine_reduce+0x15a/0x170 __kasan_slab_alloc+0x23/0x80 slab_post_alloc_hook+0x68/0x390 kmem_cache_alloc_lru+0x127/0x270 __d_alloc+0x31/0x760 d_alloc_cursor+0x44/0xd0 dcache_dir_open+0x3b/0x80 do_dentry_open+0x7f9/0x10f0 path_openat+0x25f4/0x2e30 do_filp_open+0x26d/0x500 do_sys_openat2+0x128/0x4f0 Memory state around the buggy address: ffff888073ef2f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff888073ef3000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >ffff888073ef3080: 00 00 fc fc fc fc fc fc fc fc fa fb fb fb fb fb ^ ffff888073ef3100: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc ffff888073ef3180: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ==================================================================