F2FS-fs (loop4): Mounted with checkpoint version = 48b305e5 F2FS-fs (loop4): f2fs_check_nid_range: out-of-range nid=1, run fsck to fix. ====================================================== WARNING: possible circular locking dependency detected 6.2.0-rc7-syzkaller #0 Not tainted ------------------------------------------------------ syz-executor.4/14332 is trying to acquire lock: ffff8880300d0088 (&sbi->sb_lock){++++}-{3:3}, at: f2fs_handle_error+0xf0/0x250 but task is already holding lock: ffff888075b64930 (&nm_i->nat_tree_lock){++++}-{3:3}, at: f2fs_build_free_nids+0x316/0x1190 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #4 (&nm_i->nat_tree_lock){++++}-{3:3}: lock_acquire+0x20b/0x600 down_read+0x3d/0x50 f2fs_get_node_info+0xf3/0x12d0 f2fs_do_write_data_page+0x10a8/0x27c0 f2fs_write_single_data_page+0x14c1/0x2140 f2fs_write_data_pages+0x1948/0x2ed0 do_writepages+0x3a6/0x660 filemap_fdatawrite_wbc+0x125/0x180 filemap_write_and_wait_range+0x1e5/0x2e0 f2fs_collapse_range+0x314/0x3b0 f2fs_fallocate+0x46f/0x6d0 vfs_fallocate+0x54b/0x6b0 __x64_sys_fallocate+0xbd/0x100 do_syscall_64+0x41/0xc0 entry_SYSCALL_64_after_hwframe+0x63/0xcd -> #3 (mapping.invalidate_lock#7){++++}-{3:3}: lock_acquire+0x20b/0x600 down_read+0x3d/0x50 f2fs_vm_page_mkwrite+0x536/0x1430 do_page_mkwrite+0x1a1/0x600 handle_mm_fault+0x2156/0x51c0 exc_page_fault+0x66a/0x880 asm_exc_page_fault+0x26/0x30 -> #2 (sb_pagefaults){.+.+}-{0:0}: lock_acquire+0x20b/0x600 __sb_start_write+0x58/0x1a0 f2fs_vm_page_mkwrite+0x468/0x1430 do_page_mkwrite+0x1a1/0x600 handle_mm_fault+0x2156/0x51c0 exc_page_fault+0x66a/0x880 asm_exc_page_fault+0x26/0x30 -> #1 (&mm->mmap_lock){++++}-{3:3}: lock_acquire+0x20b/0x600 __might_fault+0xba/0x120 _copy_to_user+0x2a/0x130 __f2fs_ioctl+0xaccd/0xb2b0 __se_sys_ioctl+0xf1/0x160 do_syscall_64+0x41/0xc0 entry_SYSCALL_64_after_hwframe+0x63/0xcd -> #0 (&sbi->sb_lock){++++}-{3:3}: validate_chain+0x166b/0x5860 __lock_acquire+0x125b/0x1f80 lock_acquire+0x20b/0x600 down_write+0x3a/0x60 f2fs_handle_error+0xf0/0x250 f2fs_build_free_nids+0x505/0x1190 f2fs_alloc_nid+0x221/0x740 f2fs_new_inode+0x119/0x1090 f2fs_mkdir+0x127/0x530 vfs_mkdir+0x3ba/0x590 do_mkdirat+0x237/0x4f0 __x64_sys_mkdirat+0x89/0xa0 do_syscall_64+0x41/0xc0 entry_SYSCALL_64_after_hwframe+0x63/0xcd other info that might help us debug this: Chain exists of: &sbi->sb_lock --> mapping.invalidate_lock#7 --> &nm_i->nat_tree_lock Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&nm_i->nat_tree_lock); lock(mapping.invalidate_lock#7); lock(&nm_i->nat_tree_lock); lock(&sbi->sb_lock); *** DEADLOCK *** 4 locks held by syz-executor.4/14332: #0: ffff88801d9c6460 (sb_writers#22){.+.+}-{0:0}, at: mnt_want_write+0x3f/0x90 #1: ffff888037ed0a40 (&type->i_mutex_dir_key#13/1){+.+.}-{3:3}, at: filename_create+0x249/0x500 #2: ffff888075b64ac8 (&nm_i->build_lock){+.+.}-{3:3}, at: f2fs_build_free_nids+0xcc/0x1190 #3: ffff888075b64930 (&nm_i->nat_tree_lock){++++}-{3:3}, at: f2fs_build_free_nids+0x316/0x1190 stack backtrace: CPU: 0 PID: 14332 Comm: syz-executor.4 Not tainted 6.2.0-rc7-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/12/2023 Call Trace: dump_stack_lvl+0x1b5/0x2a0 check_noncircular+0x2d1/0x390 validate_chain+0x166b/0x5860 __lock_acquire+0x125b/0x1f80 lock_acquire+0x20b/0x600 down_write+0x3a/0x60 f2fs_handle_error+0xf0/0x250 f2fs_build_free_nids+0x505/0x1190 f2fs_alloc_nid+0x221/0x740 f2fs_new_inode+0x119/0x1090 f2fs_mkdir+0x127/0x530 vfs_mkdir+0x3ba/0x590 do_mkdirat+0x237/0x4f0 __x64_sys_mkdirat+0x89/0xa0 do_syscall_64+0x41/0xc0 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7effc2e8c0c9 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:00007effc3c76168 EFLAGS: 00000246 ORIG_RAX: 0000000000000102 RAX: ffffffffffffffda RBX: 00007effc2fabf80 RCX: 00007effc2e8c0c9 RDX: 0000000000000000 RSI: 0000000020000000 RDI: ffffffffffffff9c RBP: 00007effc2ee7ae9 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007fffb1fedfaf R14: 00007effc3c76300 R15: 0000000000022000 F2FS-fs (loop4): f2fs_check_nid_range: out-of-range nid=2, run fsck to fix.