loop1: detected capacity change from 0 to 40427 F2FS-fs (loop1): Mismatch valid blocks 4 vs. 6 ====================================================== WARNING: possible circular locking dependency detected 6.2.0-rc7-syzkaller-00135-g38c1e0c65865 #0 Not tainted ------------------------------------------------------ syz-executor.1/14521 is trying to acquire lock: ffff88802b4b8088 (&sbi->sb_lock){++++}-{3:3}, at: f2fs_down_write fs/f2fs/f2fs.h:2213 [inline] ffff88802b4b8088 (&sbi->sb_lock){++++}-{3:3}, at: f2fs_handle_error+0xef/0x240 fs/f2fs/super.c:3926 but task is already holding lock: ffff888020de83b8 (&array[i].journal_rwsem){++++}-{3:3}, at: build_sit_entries+0xf0f/0x1c80 fs/f2fs/segment.c:4450 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #5 (&array[i].journal_rwsem){++++}-{3:3}: lock_acquire+0x235/0x630 kernel/locking/lockdep.c:5668 down_read+0x3d/0x50 kernel/locking/rwsem.c:1509 scan_curseg_cache+0xa6/0x410 fs/f2fs/node.c:2404 __f2fs_build_free_nids fs/f2fs/node.c:2516 [inline] f2fs_build_free_nids+0xf13/0x11a0 fs/f2fs/node.c:2531 f2fs_fill_super+0x53fd/0x7c80 fs/f2fs/super.c:4334 mount_bdev+0x271/0x3a0 fs/super.c:1359 legacy_get_tree+0xef/0x190 fs/fs_context.c:610 vfs_get_tree+0x8c/0x270 fs/super.c:1489 do_new_mount+0x28f/0xae0 fs/namespace.c:3145 do_mount fs/namespace.c:3488 [inline] __do_sys_mount fs/namespace.c:3697 [inline] __se_sys_mount+0x2d9/0x3c0 fs/namespace.c:3674 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd -> #4 (&nm_i->nat_tree_lock){++++}-{3:3}: lock_acquire+0x235/0x630 kernel/locking/lockdep.c:5668 down_read+0x3d/0x50 kernel/locking/rwsem.c:1509 f2fs_down_read fs/f2fs/f2fs.h:2188 [inline] f2fs_get_node_info+0xf3/0x12d0 fs/f2fs/node.c:564 __allocate_data_block+0x1b7/0xb70 fs/f2fs/data.c:1430 f2fs_map_blocks+0x1799/0x3b90 fs/f2fs/data.c:1613 f2fs_preallocate_blocks fs/f2fs/file.c:4469 [inline] f2fs_file_write_iter+0x11dc/0x2c20 fs/f2fs/file.c:4672 do_iter_write+0x6ea/0xc50 fs/read_write.c:861 iter_file_splice_write+0x80a/0xfa0 fs/splice.c:686 do_splice_from fs/splice.c:764 [inline] direct_splice_actor+0xe7/0x1c0 fs/splice.c:931 splice_direct_to_actor+0x4c4/0xbd0 fs/splice.c:886 do_splice_direct+0x283/0x3d0 fs/splice.c:974 do_sendfile+0x620/0xff0 fs/read_write.c:1255 __do_sys_sendfile64 fs/read_write.c:1323 [inline] __se_sys_sendfile64+0x17c/0x1e0 fs/read_write.c:1309 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd -> #3 (&sbi->cp_rwsem){++++}-{3:3}: lock_acquire+0x235/0x630 kernel/locking/lockdep.c:5668 down_read+0x3d/0x50 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+0x24e/0xf80 fs/f2fs/file.c:688 f2fs_truncate_blocks+0x10d/0x2f0 fs/f2fs/file.c:751 f2fs_truncate+0x4b6/0x8b0 fs/f2fs/file.c:803 f2fs_file_write_iter+0x2352/0x2c20 fs/f2fs/file.c:4707 do_iter_write+0x6ea/0xc50 fs/read_write.c:861 iter_file_splice_write+0x80a/0xfa0 fs/splice.c:686 do_splice_from fs/splice.c:764 [inline] direct_splice_actor+0xe7/0x1c0 fs/splice.c:931 splice_direct_to_actor+0x4c4/0xbd0 fs/splice.c:886 do_splice_direct+0x283/0x3d0 fs/splice.c:974 do_sendfile+0x620/0xff0 fs/read_write.c:1255 __do_sys_sendfile64 fs/read_write.c:1323 [inline] __se_sys_sendfile64+0x17c/0x1e0 fs/read_write.c:1309 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd -> #2 (mapping.invalidate_lock#5){++++}-{3:3}: lock_acquire+0x235/0x630 kernel/locking/lockdep.c:5668 down_read+0x3d/0x50 kernel/locking/rwsem.c:1509 filemap_invalidate_lock_shared include/linux/fs.h:811 [inline] filemap_fault+0x644/0x1800 mm/filemap.c:3146 f2fs_filemap_fault+0x81/0x3d0 fs/f2fs/file.c:44 __do_fault+0x136/0x500 mm/memory.c:4163 do_read_fault mm/memory.c:4514 [inline] do_fault mm/memory.c:4643 [inline] handle_pte_fault mm/memory.c:4931 [inline] __handle_mm_fault mm/memory.c:5073 [inline] handle_mm_fault+0x3326/0x51e0 mm/memory.c:5219 faultin_page mm/gup.c:926 [inline] __get_user_pages+0x509/0x11e0 mm/gup.c:1153 populate_vma_page_range+0x21b/0x2b0 mm/gup.c:1526 __mm_populate+0x279/0x450 mm/gup.c:1640 mm_populate include/linux/mm.h:2874 [inline] vm_mmap_pgoff+0x22f/0x2e0 mm/util.c:525 ksys_mmap_pgoff+0x4f9/0x6d0 mm/mmap.c:1457 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd -> #1 (&mm->mmap_lock){++++}-{3:3}: lock_acquire+0x235/0x630 kernel/locking/lockdep.c:5668 __might_fault+0xba/0x120 mm/memory.c:5647 _copy_to_user+0x2a/0x130 lib/usercopy.c:29 copy_to_user include/linux/uaccess.h:169 [inline] f2fs_ioc_get_encryption_pwsalt fs/f2fs/file.c:2365 [inline] __f2fs_ioctl+0xaf1d/0xb500 fs/f2fs/file.c:4169 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:870 [inline] __se_sys_ioctl+0xf1/0x160 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x41/0xc0 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+0x166b/0x58e0 kernel/locking/lockdep.c:3831 __lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5055 lock_acquire+0x235/0x630 kernel/locking/lockdep.c:5668 down_write+0x3a/0x60 kernel/locking/rwsem.c:1562 f2fs_down_write fs/f2fs/f2fs.h:2213 [inline] f2fs_handle_error+0xef/0x240 fs/f2fs/super.c:3926 check_block_count+0x35b/0x490 build_sit_entries+0x110f/0x1c80 fs/f2fs/segment.c:4470 f2fs_build_segment_manager+0x201f/0x31d0 fs/f2fs/segment.c:5159 f2fs_fill_super+0x53bf/0x7c80 fs/f2fs/super.c:4328 mount_bdev+0x271/0x3a0 fs/super.c:1359 legacy_get_tree+0xef/0x190 fs/fs_context.c:610 vfs_get_tree+0x8c/0x270 fs/super.c:1489 do_new_mount+0x28f/0xae0 fs/namespace.c:3145 do_mount fs/namespace.c:3488 [inline] __do_sys_mount fs/namespace.c:3697 [inline] __se_sys_mount+0x2d9/0x3c0 fs/namespace.c:3674 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x41/0xc0 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.1/14521: #0: ffff8880409f00e0 (&type->s_umount_key#62/1){+.+.}-{3:3}, at: alloc_super+0x217/0x930 fs/super.c:228 #1: ffff888020de83b8 (&array[i].journal_rwsem){++++}-{3:3}, at: build_sit_entries+0xf0f/0x1c80 fs/f2fs/segment.c:4450 stack backtrace: CPU: 0 PID: 14521 Comm: syz-executor.1 Not tainted 6.2.0-rc7-syzkaller-00135-g38c1e0c65865 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/21/2023 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x1e7/0x2d0 lib/dump_stack.c:106 check_noncircular+0x2fe/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+0x166b/0x58e0 kernel/locking/lockdep.c:3831 __lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5055 lock_acquire+0x235/0x630 kernel/locking/lockdep.c:5668 down_write+0x3a/0x60 kernel/locking/rwsem.c:1562 f2fs_down_write fs/f2fs/f2fs.h:2213 [inline] f2fs_handle_error+0xef/0x240 fs/f2fs/super.c:3926 check_block_count+0x35b/0x490 build_sit_entries+0x110f/0x1c80 fs/f2fs/segment.c:4470 f2fs_build_segment_manager+0x201f/0x31d0 fs/f2fs/segment.c:5159 f2fs_fill_super+0x53bf/0x7c80 fs/f2fs/super.c:4328 mount_bdev+0x271/0x3a0 fs/super.c:1359 legacy_get_tree+0xef/0x190 fs/fs_context.c:610 vfs_get_tree+0x8c/0x270 fs/super.c:1489 do_new_mount+0x28f/0xae0 fs/namespace.c:3145 do_mount fs/namespace.c:3488 [inline] __do_sys_mount fs/namespace.c:3697 [inline] __se_sys_mount+0x2d9/0x3c0 fs/namespace.c:3674 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7f37eea8d62a 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:00007f37ef83af88 EFLAGS: 00000202 ORIG_RAX: 00000000000000a5 RAX: ffffffffffffffda RBX: 00000000000054f1 RCX: 00007f37eea8d62a RDX: 0000000020000040 RSI: 0000000020000080 RDI: 00007f37ef83afe0 RBP: 00007f37ef83b020 R08: 00007f37ef83b020 R09: 0000000000000003 R10: 0000000000000003 R11: 0000000000000202 R12: 0000000020000040 R13: 0000000020000080 R14: 00007f37ef83afe0 R15: 00000000200000c0 F2FS-fs (loop1): Failed to initialize F2FS segment manager (-117)