loop5: detected capacity change from 0 to 131072 F2FS-fs (loop5): Disable nat_bits due to incorrect cp_ver (9621037545273099749, 1067266233009637) F2FS-fs (loop5): f2fs_check_nid_range: out-of-range nid=2, run fsck to fix. ====================================================== WARNING: possible circular locking dependency detected 6.1.0-syzkaller-03225-g764822972d64 #0 Not tainted ------------------------------------------------------ syz-executor.5/1418 is trying to acquire lock: ffff88803178c088 (&sbi->sb_lock){++++}-{3:3}, at: f2fs_down_write fs/f2fs/f2fs.h:2205 [inline] ffff88803178c088 (&sbi->sb_lock){++++}-{3:3}, at: f2fs_handle_error+0xe6/0x230 fs/f2fs/super.c:3898 but task is already holding lock: ffff888034bf3930 (&nm_i->nat_tree_lock){++++}-{3:3}, at: f2fs_down_read fs/f2fs/f2fs.h:2180 [inline] ffff888034bf3930 (&nm_i->nat_tree_lock){++++}-{3:3}, at: __f2fs_build_free_nids fs/f2fs/node.c:2480 [inline] ffff888034bf3930 (&nm_i->nat_tree_lock){++++}-{3:3}, at: f2fs_build_free_nids+0x758/0x11a0 fs/f2fs/node.c:2528 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #3 (&nm_i->nat_tree_lock){++++}-{3:3}: lock_acquire+0x1a7/0x400 kernel/locking/lockdep.c:5668 down_read+0x39/0x50 kernel/locking/rwsem.c:1509 f2fs_down_read fs/f2fs/f2fs.h:2180 [inline] f2fs_get_node_info+0x100/0x1720 fs/f2fs/node.c:560 __allocate_data_block+0x1c0/0xb70 fs/f2fs/data.c:1425 f2fs_map_blocks+0x177c/0x38c0 fs/f2fs/data.c:1608 f2fs_preallocate_blocks fs/f2fs/file.c:4451 [inline] f2fs_file_write_iter+0xfb4/0x23c0 fs/f2fs/file.c:4654 do_iter_write+0x6f0/0xc50 fs/read_write.c:861 iter_file_splice_write+0x830/0xff0 fs/splice.c:686 do_splice_from fs/splice.c:764 [inline] direct_splice_actor+0xe6/0x1c0 fs/splice.c:931 splice_direct_to_actor+0x4e4/0xc00 fs/splice.c:886 do_splice_direct+0x2a0/0x3f0 fs/splice.c:974 do_sendfile+0x641/0xfd0 fs/read_write.c:1255 __do_sys_sendfile64 fs/read_write.c:1323 [inline] __se_sys_sendfile64+0x178/0x1e0 fs/read_write.c:1309 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd -> #2 (&sbi->cp_rwsem){++++}-{3:3}: lock_acquire+0x1a7/0x400 kernel/locking/lockdep.c:5668 down_read+0x39/0x50 kernel/locking/rwsem.c:1509 f2fs_down_read fs/f2fs/f2fs.h:2180 [inline] f2fs_lock_op fs/f2fs/f2fs.h:2223 [inline] f2fs_convert_inline_inode+0x572/0x840 fs/f2fs/inline.c:219 f2fs_vm_page_mkwrite+0x2f5/0x13a0 fs/f2fs/file.c:79 do_page_mkwrite+0x19e/0x5e0 mm/memory.c:2977 do_shared_fault mm/memory.c:4618 [inline] do_fault mm/memory.c:4686 [inline] handle_pte_fault mm/memory.c:4954 [inline] __handle_mm_fault mm/memory.c:5096 [inline] handle_mm_fault+0x1c83/0x3660 mm/memory.c:5217 do_user_addr_fault+0x69b/0xcb0 arch/x86/mm/fault.c:1428 handle_page_fault arch/x86/mm/fault.c:1519 [inline] exc_page_fault+0x7a/0x120 arch/x86/mm/fault.c:1575 asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:570 __put_user_nocheck_4+0x3/0x11 __sys_socketpair+0x182/0x710 net/socket.c:1685 __do_sys_socketpair net/socket.c:1751 [inline] __se_sys_socketpair net/socket.c:1748 [inline] __x64_sys_socketpair+0x97/0xb0 net/socket.c:1748 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd -> #1 (&mm->mmap_lock#2){++++}-{3:3}: lock_acquire+0x1a7/0x400 kernel/locking/lockdep.c:5668 __might_fault+0xb2/0x110 mm/memory.c:5645 _copy_to_user+0x26/0x130 lib/usercopy.c:29 copy_to_user include/linux/uaccess.h:169 [inline] f2fs_ioc_get_encryption_pwsalt fs/f2fs/file.c:2349 [inline] __f2fs_ioctl+0xb8ff/0xbfb0 fs/f2fs/file.c:4151 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:870 [inline] __se_sys_ioctl+0xfb/0x170 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd -> #0 (&sbi->sb_lock){++++}-{3:3}: check_prev_add kernel/locking/lockdep.c:3097 [inline] check_prevs_add kernel/locking/lockdep.c:3216 [inline] validate_chain+0x184a/0x6470 kernel/locking/lockdep.c:3831 __lock_acquire+0x1292/0x1f60 kernel/locking/lockdep.c:5055 lock_acquire+0x1a7/0x400 kernel/locking/lockdep.c:5668 down_write+0x9c/0x270 kernel/locking/rwsem.c:1562 f2fs_down_write fs/f2fs/f2fs.h:2205 [inline] f2fs_handle_error+0xe6/0x230 fs/f2fs/super.c:3898 scan_nat_page fs/f2fs/node.c:2384 [inline] __f2fs_build_free_nids fs/f2fs/node.c:2490 [inline] f2fs_build_free_nids+0xb9c/0x11a0 fs/f2fs/node.c:2528 f2fs_fill_super+0x566b/0x7b50 fs/f2fs/super.c:4306 mount_bdev+0x26c/0x3a0 fs/super.c:1359 legacy_get_tree+0xea/0x180 fs/fs_context.c:610 vfs_get_tree+0x88/0x270 fs/super.c:1489 do_new_mount+0x289/0xad0 fs/namespace.c:3145 do_mount fs/namespace.c:3488 [inline] __do_sys_mount fs/namespace.c:3697 [inline] __se_sys_mount+0x2e3/0x3d0 fs/namespace.c:3674 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd other info that might help us debug this: Chain exists of: &sbi->sb_lock --> &sbi->cp_rwsem --> &nm_i->nat_tree_lock Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&nm_i->nat_tree_lock); lock(&sbi->cp_rwsem); lock(&nm_i->nat_tree_lock); lock(&sbi->sb_lock); *** DEADLOCK *** 3 locks held by syz-executor.5/1418: #0: ffff88807a5520e0 (&type->s_umount_key#59/1){+.+.}-{3:3}, at: alloc_super+0x212/0x920 fs/super.c:228 #1: ffff888034bf3ac8 (&nm_i->build_lock){+.+.}-{3:3}, at: f2fs_build_free_nids+0xc0/0x11a0 fs/f2fs/node.c:2527 #2: ffff888034bf3930 (&nm_i->nat_tree_lock){++++}-{3:3}, at: f2fs_down_read fs/f2fs/f2fs.h:2180 [inline] #2: ffff888034bf3930 (&nm_i->nat_tree_lock){++++}-{3:3}, at: __f2fs_build_free_nids fs/f2fs/node.c:2480 [inline] #2: ffff888034bf3930 (&nm_i->nat_tree_lock){++++}-{3:3}, at: f2fs_build_free_nids+0x758/0x11a0 fs/f2fs/node.c:2528 stack backtrace: CPU: 0 PID: 1418 Comm: syz-executor.5 Not tainted 6.1.0-syzkaller-03225-g764822972d64 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106 check_noncircular+0x2f9/0x3b0 kernel/locking/lockdep.c:2177 check_prev_add kernel/locking/lockdep.c:3097 [inline] check_prevs_add kernel/locking/lockdep.c:3216 [inline] validate_chain+0x184a/0x6470 kernel/locking/lockdep.c:3831 __lock_acquire+0x1292/0x1f60 kernel/locking/lockdep.c:5055 lock_acquire+0x1a7/0x400 kernel/locking/lockdep.c:5668 down_write+0x9c/0x270 kernel/locking/rwsem.c:1562 f2fs_down_write fs/f2fs/f2fs.h:2205 [inline] f2fs_handle_error+0xe6/0x230 fs/f2fs/super.c:3898 scan_nat_page fs/f2fs/node.c:2384 [inline] __f2fs_build_free_nids fs/f2fs/node.c:2490 [inline] f2fs_build_free_nids+0xb9c/0x11a0 fs/f2fs/node.c:2528 f2fs_fill_super+0x566b/0x7b50 fs/f2fs/super.c:4306 mount_bdev+0x26c/0x3a0 fs/super.c:1359 legacy_get_tree+0xea/0x180 fs/fs_context.c:610 vfs_get_tree+0x88/0x270 fs/super.c:1489 do_new_mount+0x289/0xad0 fs/namespace.c:3145 do_mount fs/namespace.c:3488 [inline] __do_sys_mount fs/namespace.c:3697 [inline] __se_sys_mount+0x2e3/0x3d0 fs/namespace.c:3674 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7fddf928d60a Code: 48 c7 c2 b8 ff ff ff f7 d8 64 89 02 b8 ff ff ff ff eb d2 e8 b8 04 00 00 0f 1f 84 00 00 00 00 00 49 89 ca b8 a5 00 00 00 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:00007fddf9f1af88 EFLAGS: 00000202 ORIG_RAX: 00000000000000a5 RAX: ffffffffffffffda RBX: 00000000000105fc RCX: 00007fddf928d60a RDX: 0000000020010600 RSI: 0000000020000000 RDI: 00007fddf9f1afe0 RBP: 00007fddf9f1b020 R08: 00007fddf9f1b020 R09: 0000000000000800 R10: 0000000000000800 R11: 0000000000000202 R12: 0000000020010600 R13: 0000000020000000 R14: 00007fddf9f1afe0 R15: 0000000020000100 F2FS-fs (loop5): Mounted with checkpoint version = 48b305e5