loop3: detected capacity change from 0 to 131072 F2FS-fs (loop3): Wrong segment_count / block_count (2335 > 16384) F2FS-fs (loop3): Can't find valid F2FS filesystem in 2th superblock F2FS-fs (loop3): Mismatch valid blocks 1 vs. 4 ====================================================== WARNING: possible circular locking dependency detected 6.1.0-syzkaller #0 Not tainted ------------------------------------------------------ syz-executor.3/18308 is trying to acquire lock: ffff888076f94088 (&sbi->sb_lock ){++++}-{3:3}, at: f2fs_down_write fs/f2fs/f2fs.h:2205 [inline] ){++++}-{3:3}, at: f2fs_handle_error+0x8e/0x200 fs/f2fs/super.c:3898 but task is already holding lock: ffff88807bd743b8 (&array[i].journal_rwsem){++++}-{3:3}, at: build_sit_entries fs/f2fs/segment.c:4412 [inline] ffff88807bd743b8 (&array[i].journal_rwsem){++++}-{3:3}, at: f2fs_build_segment_manager+0x54d7/0xa670 fs/f2fs/segment.c:5123 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:2401 __f2fs_build_free_nids+0x761/0xe10 fs/f2fs/node.c:2513 f2fs_build_free_nids fs/f2fs/node.c:2528 [inline] f2fs_build_node_manager+0x2007/0x2fb0 fs/f2fs/node.c:3313 f2fs_fill_super+0x3a95/0x77a0 fs/f2fs/super.c:4306 mount_bdev+0x351/0x410 fs/super.c:1401 legacy_get_tree+0x109/0x220 fs/fs_context.c:610 vfs_get_tree+0x8d/0x2f0 fs/super.c:1531 do_new_mount fs/namespace.c:3040 [inline] path_mount+0x132a/0x1e20 fs/namespace.c:3370 do_mount fs/namespace.c:3383 [inline] __do_sys_mount fs/namespace.c:3591 [inline] __se_sys_mount fs/namespace.c:3568 [inline] __x64_sys_mount+0x283/0x300 fs/namespace.c:3568 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:2180 [inline] f2fs_get_node_info+0x1ac/0x1070 fs/f2fs/node.c:560 __write_node_page+0x89f/0x2140 fs/f2fs/node.c:1613 f2fs_sync_node_pages+0x141b/0x2330 fs/f2fs/node.c:2017 block_operations+0x60c/0xc40 fs/f2fs/checkpoint.c:1270 f2fs_write_checkpoint+0x606/0x4c80 fs/f2fs/checkpoint.c:1650 kill_f2fs_super+0x32c/0x3c0 fs/f2fs/super.c:4606 deactivate_locked_super+0x98/0x160 fs/super.c:332 deactivate_super+0xb1/0xd0 fs/super.c:363 cleanup_mnt+0x2ae/0x3d0 fs/namespace.c:1186 task_work_run+0x16f/0x270 kernel/task_work.c:179 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline] exit_to_user_mode_loop kernel/entry/common.c:171 [inline] exit_to_user_mode_prepare+0x23c/0x250 kernel/entry/common.c:203 __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline] syscall_exit_to_user_mode+0x1d/0x50 kernel/entry/common.c:296 do_syscall_64+0x46/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x63/0xcd -> #3 (&sbi->node_change){++++}-{3:3}: down_read+0x9c/0x450 kernel/locking/rwsem.c:1509 f2fs_down_read fs/f2fs/f2fs.h:2180 [inline] f2fs_lock_op fs/f2fs/f2fs.h:2223 [inline] f2fs_do_map_lock+0x4e/0x80 fs/f2fs/data.c:1442 f2fs_vm_page_mkwrite+0x1253/0x1c90 fs/f2fs/file.c:116 do_page_mkwrite+0x19b/0x680 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+0x2280/0x3a40 mm/memory.c:5096 handle_mm_fault+0x1cc/0x780 mm/memory.c:5217 faultin_page mm/gup.c:1009 [inline] __get_user_pages+0x497/0xf10 mm/gup.c:1230 __get_user_pages_locked mm/gup.c:1434 [inline] __get_user_pages_remote+0x18f/0x830 mm/gup.c:2187 pin_user_pages_remote+0x70/0xb0 mm/gup.c:3245 process_vm_rw_single_vec mm/process_vm_access.c:105 [inline] process_vm_rw_core.constprop.0+0x43b/0x980 mm/process_vm_access.c:215 process_vm_rw+0x29c/0x300 mm/process_vm_access.c:283 __do_sys_process_vm_writev mm/process_vm_access.c:303 [inline] __se_sys_process_vm_writev mm/process_vm_access.c:298 [inline] __x64_sys_process_vm_writev+0xe3/0x1b0 mm/process_vm_access.c:298 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#5){++++}-{3:3}: down_read+0x9c/0x450 kernel/locking/rwsem.c:1509 filemap_invalidate_lock_shared include/linux/fs.h:811 [inline] filemap_fault+0xba2/0x2400 mm/filemap.c:3127 f2fs_filemap_fault+0x82/0x3e0 fs/f2fs/file.c:44 __do_fault+0x107/0x600 mm/memory.c:4202 do_shared_fault mm/memory.c:4608 [inline] do_fault mm/memory.c:4686 [inline] handle_pte_fault mm/memory.c:4954 [inline] __handle_mm_fault+0x2200/0x3a40 mm/memory.c:5096 handle_mm_fault+0x1cc/0x780 mm/memory.c:5217 faultin_page mm/gup.c:1009 [inline] __get_user_pages+0x497/0xf10 mm/gup.c:1230 __get_user_pages_locked mm/gup.c:1434 [inline] __get_user_pages_remote+0x18f/0x830 mm/gup.c:2187 pin_user_pages_remote+0x70/0xb0 mm/gup.c:3245 process_vm_rw_single_vec mm/process_vm_access.c:105 [inline] process_vm_rw_core.constprop.0+0x43b/0x980 mm/process_vm_access.c:215 process_vm_rw+0x29c/0x300 mm/process_vm_access.c:283 __do_sys_process_vm_writev mm/process_vm_access.c:303 [inline] __se_sys_process_vm_writev mm/process_vm_access.c:298 [inline] __x64_sys_process_vm_writev+0xe3/0x1b0 mm/process_vm_access.c:298 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 -> #1 (&mm->mmap_lock#2){++++}-{3:3}: __might_fault mm/memory.c:5645 [inline] __might_fault+0x10c/0x180 mm/memory.c:5638 _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:2349 __f2fs_ioctl+0x1755/0xa800 fs/f2fs/file.c:4151 f2fs_ioctl+0x18e/0x220 fs/f2fs/file.c:4224 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:2205 [inline] f2fs_handle_error+0x8e/0x200 fs/f2fs/super.c:3898 check_block_count+0x440/0x4f0 fs/f2fs/segment.h:771 build_sit_entries fs/f2fs/segment.c:4432 [inline] f2fs_build_segment_manager+0x5a30/0xa670 fs/f2fs/segment.c:5123 f2fs_fill_super+0x3a73/0x77a0 fs/f2fs/super.c:4300 mount_bdev+0x351/0x410 fs/super.c:1401 legacy_get_tree+0x109/0x220 fs/fs_context.c:610 vfs_get_tree+0x8d/0x2f0 fs/super.c:1531 do_new_mount fs/namespace.c:3040 [inline] path_mount+0x132a/0x1e20 fs/namespace.c:3370 do_mount fs/namespace.c:3383 [inline] __do_sys_mount fs/namespace.c:3591 [inline] __se_sys_mount fs/namespace.c:3568 [inline] __x64_sys_mount+0x283/0x300 fs/namespace.c:3568 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.3/18308: #0: ffff8880739500e0 (&type->s_umount_key#55/1){+.+.}-{3:3}, at: alloc_super+0x22e/0xb60 fs/super.c:228 #1: ffff88807bd743b8 (&array[i].journal_rwsem){++++}-{3:3}, at: build_sit_entries fs/f2fs/segment.c:4412 [inline] #1: ffff88807bd743b8 (&array[i].journal_rwsem){++++}-{3:3}, at: f2fs_build_segment_manager+0x54d7/0xa670 fs/f2fs/segment.c:5123 stack backtrace: CPU: 1 PID: 18308 Comm: syz-executor.3 Not tainted 6.1.0-syzkaller #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+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:2205 [inline] f2fs_handle_error+0x8e/0x200 fs/f2fs/super.c:3898 check_block_count+0x440/0x4f0 fs/f2fs/segment.h:771 build_sit_entries fs/f2fs/segment.c:4432 [inline] f2fs_build_segment_manager+0x5a30/0xa670 fs/f2fs/segment.c:5123 f2fs_fill_super+0x3a73/0x77a0 fs/f2fs/super.c:4300 mount_bdev+0x351/0x410 fs/super.c:1401 legacy_get_tree+0x109/0x220 fs/fs_context.c:610 vfs_get_tree+0x8d/0x2f0 fs/super.c:1531 do_new_mount fs/namespace.c:3040 [inline] path_mount+0x132a/0x1e20 fs/namespace.c:3370 do_mount fs/namespace.c:3383 [inline] __do_sys_mount fs/namespace.c:3591 [inline] __se_sys_mount fs/namespace.c:3568 [inline] __x64_sys_mount+0x283/0x300 fs/namespace.c:3568 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:0x7fd0bc88d60a 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:00007fd0bd600f88 EFLAGS: 00000202 ORIG_RAX: 00000000000000a5 RAX: ffffffffffffffda RBX: 0000000000010222 RCX: 00007fd0bc88d60a RDX: 0000000020010240 RSI: 0000000020010280 RDI: 00007fd0bd600fe0 RBP: 00007fd0bd601020 R08: 00007fd0bd601020 R09: 0000000001200010 R10: 0000000001200010 R11: 0000000000000202 R12: 0000000020010240 R13: 0000000020010280 R14: 00007fd0bd600fe0 R15: 0000000020000000 F2FS-fs (loop3): Failed to initialize F2FS segment manager (-117)