F2FS-fs (loop3): Mismatch valid blocks 0 vs. 1 ====================================================== WARNING: possible circular locking dependency detected 6.2.0-syzkaller-18300-g2ebd1fbb946d #0 Not tainted ------------------------------------------------------ syz-executor.3/1363 is trying to acquire lock: ffff0000caf5c088 (&sbi->sb_lock){++++}-{3:3}, at: f2fs_down_write fs/f2fs/f2fs.h:2213 [inline] ffff0000caf5c088 (&sbi->sb_lock){++++}-{3:3}, at: f2fs_handle_error+0xe8/0x23c fs/f2fs/super.c:3926 but task is already holding lock: ffff0000d950e3b8 (&array[i].journal_rwsem){++++}-{3:3}, at: build_sit_entries+0xc70/0x172c 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}: down_read+0x5c/0x78 kernel/locking/rwsem.c:1509 scan_curseg_cache+0x8c/0x330 fs/f2fs/node.c:2404 __f2fs_build_free_nids fs/f2fs/node.c:2516 [inline] f2fs_build_free_nids+0xcc4/0xf14 fs/f2fs/node.c:2531 f2fs_build_node_manager+0x13ec/0x1b08 fs/f2fs/node.c:3316 f2fs_fill_super+0x4368/0x633c fs/f2fs/super.c:4334 mount_bdev+0x26c/0x368 fs/super.c:1359 f2fs_mount+0x44/0x58 fs/f2fs/super.c:4608 legacy_get_tree+0xd4/0x16c fs/fs_context.c:610 vfs_get_tree+0x90/0x274 fs/super.c:1489 do_new_mount+0x25c/0x8c8 fs/namespace.c:3145 path_mount+0x590/0xe58 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] __arm64_sys_mount+0x45c/0x594 fs/namespace.c:3674 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline] invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142 do_el0_svc+0x64/0x198 arch/arm64/kernel/syscall.c:193 el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655 el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:591 -> #4 (&nm_i->nat_tree_lock){++++}-{3:3}: down_read+0x5c/0x78 kernel/locking/rwsem.c:1509 f2fs_down_read fs/f2fs/f2fs.h:2188 [inline] f2fs_get_node_info+0xd4/0xda4 fs/f2fs/node.c:564 f2fs_do_write_data_page+0x94c/0x1130 fs/f2fs/data.c:2728 f2fs_write_single_data_page+0xd84/0x16f8 fs/f2fs/data.c:2863 f2fs_write_cache_pages fs/f2fs/data.c:3115 [inline] __f2fs_write_data_pages fs/f2fs/data.c:3265 [inline] f2fs_write_data_pages+0x1230/0x2308 fs/f2fs/data.c:3292 do_writepages+0x2e8/0x56c mm/page-writeback.c:2581 filemap_fdatawrite_wbc+0x124/0x174 mm/filemap.c:388 __filemap_fdatawrite_range mm/filemap.c:421 [inline] file_write_and_wait_range+0x1bc/0x2ac mm/filemap.c:777 f2fs_do_sync_file+0x638/0x19a4 fs/f2fs/file.c:275 f2fs_sync_file+0x110/0x15c fs/f2fs/file.c:393 vfs_fsync_range+0x168/0x188 fs/sync.c:188 generic_write_sync include/linux/fs.h:2885 [inline] f2fs_file_write_iter+0x694/0x2898 fs/f2fs/file.c:4721 call_write_iter include/linux/fs.h:2189 [inline] new_sync_write fs/read_write.c:491 [inline] vfs_write+0x610/0x914 fs/read_write.c:584 ksys_write+0x15c/0x26c fs/read_write.c:637 __do_sys_write fs/read_write.c:649 [inline] __se_sys_write fs/read_write.c:646 [inline] __arm64_sys_write+0x7c/0x90 fs/read_write.c:646 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline] invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142 do_el0_svc+0x64/0x198 arch/arm64/kernel/syscall.c:193 el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655 el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:591 -> #3 (&sbi->cp_rwsem){++++}-{3:3}: down_read+0x5c/0x78 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+0x29c/0x1268 fs/f2fs/file.c:688 f2fs_truncate_blocks+0xec/0x2a8 fs/f2fs/file.c:751 f2fs_truncate+0x4d8/0x9f8 fs/f2fs/file.c:803 f2fs_setattr+0x924/0xdf8 fs/f2fs/file.c:1010 notify_change+0xc24/0xec0 fs/attr.c:482 do_truncate+0x1c0/0x28c fs/open.c:65 handle_truncate fs/namei.c:3216 [inline] do_open fs/namei.c:3561 [inline] path_openat+0x1fa4/0x2578 fs/namei.c:3714 do_filp_open+0x1bc/0x3cc fs/namei.c:3741 do_sys_openat2+0x128/0x3d8 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] __arm64_sys_openat+0x1f0/0x240 fs/open.c:1337 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline] invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142 do_el0_svc+0x64/0x198 arch/arm64/kernel/syscall.c:193 el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655 el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:591 -> #2 (mapping.invalidate_lock#7){++++}-{3:3}: down_read+0x5c/0x78 kernel/locking/rwsem.c:1509 filemap_invalidate_lock_shared include/linux/fs.h:811 [inline] filemap_fault+0x58c/0xf7c mm/filemap.c:3147 f2fs_filemap_fault+0x84/0x5a8 fs/f2fs/file.c:44 __do_fault+0x11c/0x3d8 mm/memory.c:4166 do_shared_fault mm/memory.c:4572 [inline] do_fault mm/memory.c:4650 [inline] handle_pte_fault mm/memory.c:4934 [inline] __handle_mm_fault mm/memory.c:5076 [inline] handle_mm_fault+0x1954/0x3f4c mm/memory.c:5222 __do_page_fault arch/arm64/mm/fault.c:512 [inline] do_page_fault+0x634/0xac4 arch/arm64/mm/fault.c:612 do_translation_fault+0x94/0xc8 arch/arm64/mm/fault.c:695 do_mem_abort+0x74/0x200 arch/arm64/mm/fault.c:831 el0_da+0x70/0x184 arch/arm64/kernel/entry-common.c:515 el0t_64_sync_handler+0xcc/0xf0 arch/arm64/kernel/entry-common.c:658 el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:591 -> #1 (&mm->mmap_lock){++++}-{3:3}: __might_fault+0xc4/0x124 mm/memory.c:5650 _copy_to_user include/linux/uaccess.h:143 [inline] copy_to_user include/linux/uaccess.h:169 [inline] f2fs_ioc_get_encryption_pwsalt fs/f2fs/file.c:2365 [inline] __f2fs_ioctl+0xa0d4/0xa880 fs/f2fs/file.c:4169 f2fs_ioctl+0x130/0x1a0 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] __arm64_sys_ioctl+0x14c/0x1c8 fs/ioctl.c:856 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline] invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142 do_el0_svc+0x64/0x198 arch/arm64/kernel/syscall.c:193 el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655 el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:591 -> #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+0x3338/0x764c kernel/locking/lockdep.c:5055 lock_acquire+0x2e8/0x8c0 kernel/locking/lockdep.c:5668 down_write+0x5c/0x88 kernel/locking/rwsem.c:1562 f2fs_down_write fs/f2fs/f2fs.h:2213 [inline] f2fs_handle_error+0xe8/0x23c fs/f2fs/super.c:3926 check_block_count+0x2b0/0x3a0 build_sit_entries+0xde0/0x172c fs/f2fs/segment.c:4470 f2fs_build_segment_manager+0x1414/0x1e98 fs/f2fs/segment.c:5159 f2fs_fill_super+0x4330/0x633c fs/f2fs/super.c:4328 mount_bdev+0x26c/0x368 fs/super.c:1359 f2fs_mount+0x44/0x58 fs/f2fs/super.c:4608 legacy_get_tree+0xd4/0x16c fs/fs_context.c:610 vfs_get_tree+0x90/0x274 fs/super.c:1489 do_new_mount+0x25c/0x8c8 fs/namespace.c:3145 path_mount+0x590/0xe58 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] __arm64_sys_mount+0x45c/0x594 fs/namespace.c:3674 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline] invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142 do_el0_svc+0x64/0x198 arch/arm64/kernel/syscall.c:193 el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655 el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:591 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.3/1363: #0: ffff0000db3e00e0 (&type->s_umount_key#99/1){+.+.}-{3:3}, at: alloc_super+0x1b4/0x824 fs/super.c:228 #1: ffff0000d950e3b8 (&array[i].journal_rwsem){++++}-{3:3}, at: build_sit_entries+0xc70/0x172c fs/f2fs/segment.c:4450 stack backtrace: CPU: 0 PID: 1363 Comm: syz-executor.3 Not tainted 6.2.0-syzkaller-18300-g2ebd1fbb946d #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/21/2023 Call trace: dump_backtrace+0x1c8/0x1f4 arch/arm64/kernel/stacktrace.c:158 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:165 __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xd0/0x124 lib/dump_stack.c:106 dump_stack+0x1c/0x28 lib/dump_stack.c:113 print_circular_bug+0x150/0x1b8 kernel/locking/lockdep.c:2055 check_noncircular+0x2cc/0x378 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+0x3338/0x764c kernel/locking/lockdep.c:5055 lock_acquire+0x2e8/0x8c0 kernel/locking/lockdep.c:5668 down_write+0x5c/0x88 kernel/locking/rwsem.c:1562 f2fs_down_write fs/f2fs/f2fs.h:2213 [inline] f2fs_handle_error+0xe8/0x23c fs/f2fs/super.c:3926 check_block_count+0x2b0/0x3a0 build_sit_entries+0xde0/0x172c fs/f2fs/segment.c:4470 f2fs_build_segment_manager+0x1414/0x1e98 fs/f2fs/segment.c:5159 f2fs_fill_super+0x4330/0x633c fs/f2fs/super.c:4328 mount_bdev+0x26c/0x368 fs/super.c:1359 f2fs_mount+0x44/0x58 fs/f2fs/super.c:4608 legacy_get_tree+0xd4/0x16c fs/fs_context.c:610 vfs_get_tree+0x90/0x274 fs/super.c:1489 do_new_mount+0x25c/0x8c8 fs/namespace.c:3145 path_mount+0x590/0xe58 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] __arm64_sys_mount+0x45c/0x594 fs/namespace.c:3674 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline] invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142 do_el0_svc+0x64/0x198 arch/arm64/kernel/syscall.c:193 el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655 el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:591 F2FS-fs (loop3): Failed to initialize F2FS segment manager (-117)