F2FS-fs (loop2): Can't find valid F2FS filesystem in 1th superblock F2FS-fs (loop2): invalid crc value F2FS-fs (loop2): Mismatch valid blocks 1 vs. 3 ====================================================== WARNING: possible circular locking dependency detected 6.2.0-rc7-syzkaller-00018-g0983f6bf2bfc #0 Not tainted ------------------------------------------------------ syz-executor.2/21071 is trying to acquire lock: ffff88807cd38088 (&sbi->sb_lock){++++}-{3:3}, at: f2fs_down_write fs/f2fs/f2fs.h:2213 [inline] ffff88807cd38088 (&sbi->sb_lock){++++}-{3:3}, at: f2fs_handle_error+0x8e/0x200 fs/f2fs/super.c:3926 but task is already holding lock: ffff88803d95e3b8 (&array[i].journal_rwsem){++++}-{3:3}, at: build_sit_entries fs/f2fs/segment.c:4450 [inline] ffff88803d95e3b8 (&array[i].journal_rwsem){++++}-{3:3}, at: f2fs_build_segment_manager+0x5241/0xa5d0 fs/f2fs/segment.c:5159 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #5 (&array[i].journal_rwsem){++++}-{3:3}: down_read+0x9c/0x450 kernel/locking/rwsem.c:1509 scan_curseg_cache+0xa7/0x3b0 fs/f2fs/node.c:2404 __f2fs_build_free_nids+0x761/0xe10 fs/f2fs/node.c:2516 f2fs_build_free_nids fs/f2fs/node.c:2531 [inline] f2fs_build_node_manager+0x2007/0x2fb0 fs/f2fs/node.c:3316 f2fs_fill_super+0x3ade/0x7680 fs/f2fs/super.c:4334 mount_bdev+0x351/0x410 fs/super.c:1359 legacy_get_tree+0x109/0x220 fs/fs_context.c:610 vfs_get_tree+0x8d/0x2f0 fs/super.c:1489 do_new_mount fs/namespace.c:3145 [inline] path_mount+0x132a/0x1e20 fs/namespace.c:3475 do_mount fs/namespace.c:3488 [inline] __do_sys_mount fs/namespace.c:3697 [inline] __se_sys_mount fs/namespace.c:3674 [inline] __x64_sys_mount+0x283/0x300 fs/namespace.c:3674 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd -> #4 (&nm_i->nat_tree_lock){++++}-{3:3}: down_read+0x9c/0x450 kernel/locking/rwsem.c:1509 f2fs_down_read fs/f2fs/f2fs.h:2188 [inline] f2fs_get_node_info+0x1ac/0x1070 fs/f2fs/node.c:564 f2fs_new_node_page+0x249/0xac0 fs/f2fs/node.c:1295 f2fs_get_dnode_of_data+0x530/0x2480 fs/f2fs/node.c:810 f2fs_reserve_block+0x4d/0x430 fs/f2fs/data.c:1199 f2fs_get_new_data_page+0xfb/0x6b0 fs/f2fs/data.c:1387 f2fs_add_regular_entry+0x4e9/0xbd0 fs/f2fs/dir.c:754 f2fs_add_dentry+0x1b5/0x210 fs/f2fs/dir.c:816 f2fs_do_add_link+0x183/0x270 fs/f2fs/dir.c:855 f2fs_add_link fs/f2fs/f2fs.h:3564 [inline] f2fs_mkdir+0x387/0x630 fs/f2fs/namei.c:767 vfs_mkdir+0x48d/0x740 fs/namei.c:4036 do_mkdirat+0x27b/0x2f0 fs/namei.c:4061 __do_sys_mkdir fs/namei.c:4081 [inline] __se_sys_mkdir fs/namei.c:4079 [inline] __x64_sys_mkdir+0xf6/0x140 fs/namei.c:4079 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd -> #3 (&sbi->cp_rwsem){++++}-{3:3}: down_read+0x9c/0x450 kernel/locking/rwsem.c:1509 f2fs_down_read fs/f2fs/f2fs.h:2188 [inline] f2fs_lock_op fs/f2fs/f2fs.h:2231 [inline] f2fs_do_truncate_blocks+0x6ae/0x11e0 fs/f2fs/file.c:688 f2fs_truncate_blocks+0x7b/0x310 fs/f2fs/file.c:751 f2fs_truncate.part.0+0x498/0x7c0 fs/f2fs/file.c:803 f2fs_truncate include/linux/fs.h:806 [inline] f2fs_setattr+0x1b00/0x2350 fs/f2fs/file.c:1010 notify_change+0xca7/0x1420 fs/attr.c:482 do_truncate+0x143/0x200 fs/open.c:65 handle_truncate fs/namei.c:3216 [inline] do_open fs/namei.c:3561 [inline] path_openat+0x2157/0x2a50 fs/namei.c:3714 do_filp_open+0x1ba/0x410 fs/namei.c:3741 do_sys_openat2+0x16d/0x4c0 fs/open.c:1310 do_sys_open fs/open.c:1326 [inline] __do_sys_openat fs/open.c:1342 [inline] __se_sys_openat fs/open.c:1337 [inline] __x64_sys_openat+0x143/0x1f0 fs/open.c:1337 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd -> #2 (mapping.invalidate_lock#7){++++}-{3:3}: down_read+0x9c/0x450 kernel/locking/rwsem.c:1509 filemap_invalidate_lock_shared include/linux/fs.h:811 [inline] filemap_fault+0xb99/0x23f0 mm/filemap.c:3146 f2fs_filemap_fault+0x82/0x3e0 fs/f2fs/file.c:44 __do_fault+0x107/0x600 mm/memory.c:4163 do_shared_fault mm/memory.c:4569 [inline] do_fault mm/memory.c:4647 [inline] handle_pte_fault mm/memory.c:4931 [inline] __handle_mm_fault+0x236e/0x3c90 mm/memory.c:5073 handle_mm_fault+0x1b6/0x850 mm/memory.c:5219 do_user_addr_fault+0x475/0x1210 arch/x86/mm/fault.c:1428 handle_page_fault arch/x86/mm/fault.c:1519 [inline] exc_page_fault+0x98/0x170 arch/x86/mm/fault.c:1575 asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:570 -> #1 (&mm->mmap_lock){++++}-{3:3}: __might_fault mm/memory.c:5647 [inline] __might_fault+0x10c/0x180 mm/memory.c:5640 _copy_to_user+0x29/0x150 lib/usercopy.c:29 copy_to_user include/linux/uaccess.h:169 [inline] f2fs_ioc_get_encryption_pwsalt+0x2b2/0x370 fs/f2fs/file.c:2365 __f2fs_ioctl+0x29f1/0xaaf0 fs/f2fs/file.c:4169 f2fs_ioctl+0x18e/0x220 fs/f2fs/file.c:4242 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:870 [inline] __se_sys_ioctl fs/ioctl.c:856 [inline] __x64_sys_ioctl+0x197/0x210 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x39/0xb0 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 kernel/locking/lockdep.c:3831 [inline] __lock_acquire+0x2a43/0x56d0 kernel/locking/lockdep.c:5055 lock_acquire kernel/locking/lockdep.c:5668 [inline] lock_acquire+0x1e3/0x630 kernel/locking/lockdep.c:5633 down_write+0x94/0x220 kernel/locking/rwsem.c:1562 f2fs_down_write fs/f2fs/f2fs.h:2213 [inline] f2fs_handle_error+0x8e/0x200 fs/f2fs/super.c:3926 check_block_count+0x440/0x4f0 fs/f2fs/segment.h:765 build_sit_entries fs/f2fs/segment.c:4470 [inline] f2fs_build_segment_manager+0x5577/0xa5d0 fs/f2fs/segment.c:5159 f2fs_fill_super+0x3aba/0x7680 fs/f2fs/super.c:4328 mount_bdev+0x351/0x410 fs/super.c:1359 legacy_get_tree+0x109/0x220 fs/fs_context.c:610 vfs_get_tree+0x8d/0x2f0 fs/super.c:1489 do_new_mount fs/namespace.c:3145 [inline] path_mount+0x132a/0x1e20 fs/namespace.c:3475 do_mount fs/namespace.c:3488 [inline] __do_sys_mount fs/namespace.c:3697 [inline] __se_sys_mount fs/namespace.c:3674 [inline] __x64_sys_mount+0x283/0x300 fs/namespace.c:3674 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x39/0xb0 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 --> &nm_i->nat_tree_lock --> &array[i].journal_rwsem Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&array[i].journal_rwsem); lock(&nm_i->nat_tree_lock); lock(&array[i].journal_rwsem); lock(&sbi->sb_lock); *** DEADLOCK *** 2 locks held by syz-executor.2/21071: #0: ffff88803d37e0e0 (&type->s_umount_key#52/1){+.+.}-{3:3}, at: alloc_super+0x22e/0xb60 fs/super.c:228 #1: ffff88803d95e3b8 (&array[i].journal_rwsem){++++}-{3:3}, at: build_sit_entries fs/f2fs/segment.c:4450 [inline] #1: ffff88803d95e3b8 (&array[i].journal_rwsem){++++}-{3:3}, at: f2fs_build_segment_manager+0x5241/0xa5d0 fs/f2fs/segment.c:5159 stack backtrace: CPU: 0 PID: 21071 Comm: syz-executor.2 Not tainted 6.2.0-rc7-syzkaller-00018-g0983f6bf2bfc #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/12/2023 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xd1/0x138 lib/dump_stack.c:106 check_noncircular+0x25f/0x2e0 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 kernel/locking/lockdep.c:3831 [inline] __lock_acquire+0x2a43/0x56d0 kernel/locking/lockdep.c:5055 lock_acquire kernel/locking/lockdep.c:5668 [inline] lock_acquire+0x1e3/0x630 kernel/locking/lockdep.c:5633 down_write+0x94/0x220 kernel/locking/rwsem.c:1562 f2fs_down_write fs/f2fs/f2fs.h:2213 [inline] f2fs_handle_error+0x8e/0x200 fs/f2fs/super.c:3926 check_block_count+0x440/0x4f0 fs/f2fs/segment.h:765 build_sit_entries fs/f2fs/segment.c:4470 [inline] f2fs_build_segment_manager+0x5577/0xa5d0 fs/f2fs/segment.c:5159 f2fs_fill_super+0x3aba/0x7680 fs/f2fs/super.c:4328 mount_bdev+0x351/0x410 fs/super.c:1359 legacy_get_tree+0x109/0x220 fs/fs_context.c:610 vfs_get_tree+0x8d/0x2f0 fs/super.c:1489 do_new_mount fs/namespace.c:3145 [inline] path_mount+0x132a/0x1e20 fs/namespace.c:3475 do_mount fs/namespace.c:3488 [inline] __do_sys_mount fs/namespace.c:3697 [inline] __se_sys_mount fs/namespace.c:3674 [inline] __x64_sys_mount+0x283/0x300 fs/namespace.c:3674 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7f0b1ce8d62a 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:00007f0b1b9fdf88 EFLAGS: 00000202 ORIG_RAX: 00000000000000a5 RAX: ffffffffffffffda RBX: 0000000000007e73 RCX: 00007f0b1ce8d62a RDX: 00000000200000c0 RSI: 0000000020000080 RDI: 00007f0b1b9fdfe0 RBP: 00007f0b1b9fe020 R08: 00007f0b1b9fe020 R09: 0000000000000010 R10: 0000000000000010 R11: 0000000000000202 R12: 00000000200000c0 R13: 0000000020000080 R14: 00007f0b1b9fdfe0 R15: 0000000020000100 F2FS-fs (loop2): Failed to initialize F2FS segment manager (-117)