F2FS-fs (loop2): Found nat_bits in checkpoint F2FS-fs (loop2): f2fs_check_nid_range: out-of-range nid=2, run fsck to fix. ====================================================== WARNING: possible circular locking dependency detected 6.2.0-syzkaller-18295-ga9b06ec42c0f #0 Not tainted ------------------------------------------------------ syz-executor.2/8979 is trying to acquire lock: ffff0000c0f78088 (&sbi->sb_lock){++++}-{3:3}, at: f2fs_down_write fs/f2fs/f2fs.h:2213 [inline] ffff0000c0f78088 (&sbi->sb_lock){++++}-{3:3}, at: f2fs_handle_error+0xe8/0x23c fs/f2fs/super.c:3926 but task is already holding lock: ffff0000c92f2930 (&nm_i->nat_tree_lock){++++}-{3:3}, at: f2fs_down_read fs/f2fs/f2fs.h:2188 [inline] ffff0000c92f2930 (&nm_i->nat_tree_lock){++++}-{3:3}, at: __f2fs_build_free_nids fs/f2fs/node.c:2483 [inline] ffff0000c92f2930 (&nm_i->nat_tree_lock){++++}-{3:3}, at: f2fs_build_free_nids+0x5b8/0xf14 fs/f2fs/node.c:2531 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #5 (&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+0xa74/0x19f4 fs/f2fs/data.c:2728 f2fs_write_single_data_page+0xd58/0x1874 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+0x1080/0x2450 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 -> #4 (&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+0x2a4/0x1468 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 -> #3 (mapping.invalidate_lock#3){++++}-{3:3}: down_read+0x5c/0x78 kernel/locking/rwsem.c:1509 filemap_invalidate_lock_shared include/linux/fs.h:811 [inline] f2fs_vm_page_mkwrite+0x3c8/0x117c fs/f2fs/file.c:104 do_page_mkwrite+0x144/0x494 mm/memory.c:2943 do_shared_fault mm/memory.c:4582 [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+0x1854/0x3734 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 -> #2 (sb_pagefaults){.+.+}-{0:0}: percpu_down_read include/linux/percpu-rwsem.h:51 [inline] __sb_start_write+0x88/0x2f4 include/linux/fs.h:1814 sb_start_pagefault include/linux/fs.h:1918 [inline] f2fs_vm_page_mkwrite+0x34c/0x117c fs/f2fs/file.c:99 do_page_mkwrite+0x144/0x494 mm/memory.c:2943 do_shared_fault mm/memory.c:4582 [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+0x1854/0x3734 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+0xa240/0xa984 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 f2fs_check_nid_range fs/f2fs/node.c:39 [inline] add_free_nid+0x6f8/0x84c fs/f2fs/node.c:2285 scan_nat_page fs/f2fs/node.c:2387 [inline] __f2fs_build_free_nids fs/f2fs/node.c:2493 [inline] f2fs_build_free_nids+0xac4/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 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.2/8979: #0: ffff0000c94840e0 (&type->s_umount_key#52/1){+.+.}-{3:3}, at: alloc_super+0x1b4/0x824 fs/super.c:228 #1: ffff0000c92f2ac8 (&nm_i->build_lock){+.+.}-{3:3}, at: f2fs_build_free_nids+0xc0/0xf14 fs/f2fs/node.c:2530 #2: ffff0000c92f2930 (&nm_i->nat_tree_lock){++++}-{3:3}, at: f2fs_down_read fs/f2fs/f2fs.h:2188 [inline] #2: ffff0000c92f2930 (&nm_i->nat_tree_lock){++++}-{3:3}, at: __f2fs_build_free_nids fs/f2fs/node.c:2483 [inline] #2: ffff0000c92f2930 (&nm_i->nat_tree_lock){++++}-{3:3}, at: f2fs_build_free_nids+0x5b8/0xf14 fs/f2fs/node.c:2531 stack backtrace: CPU: 1 PID: 8979 Comm: syz-executor.2 Not tainted 6.2.0-syzkaller-18295-ga9b06ec42c0f #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 f2fs_check_nid_range fs/f2fs/node.c:39 [inline] add_free_nid+0x6f8/0x84c fs/f2fs/node.c:2285 scan_nat_page fs/f2fs/node.c:2387 [inline] __f2fs_build_free_nids fs/f2fs/node.c:2493 [inline] f2fs_build_free_nids+0xac4/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 F2FS-fs (loop2): Mounted with checkpoint version = 48b305e4