====================================================== WARNING: possible circular locking dependency detected 6.2.0-rc5-syzkaller-00013-g2475bf0250de #0 Not tainted ------------------------------------------------------ syz-executor.3/10827 is trying to acquire lock: ffff8880469a83b0 (&sbi->cp_rwsem){++++}-{3:3}, at: f2fs_down_read fs/f2fs/f2fs.h:2188 [inline] ffff8880469a83b0 (&sbi->cp_rwsem){++++}-{3:3}, at: f2fs_lock_op fs/f2fs/f2fs.h:2231 [inline] ffff8880469a83b0 (&sbi->cp_rwsem){++++}-{3:3}, at: f2fs_convert_inline_inode+0x55f/0x820 fs/f2fs/inline.c:219 but task is already holding lock: ffff8880773912d8 (&mm->mmap_lock){++++}-{3:3}, at: mmap_read_lock+0x17/0x50 include/linux/mmap_lock.h:117 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #4 (&mm->mmap_lock){++++}-{3:3}: lock_acquire+0x182/0x3c0 kernel/locking/lockdep.c:5668 __might_fault+0xb2/0x110 mm/memory.c:5647 _copy_to_user+0x26/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+0xaf72/0xb540 fs/f2fs/file.c:4169 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:870 [inline] __se_sys_ioctl+0xfb/0x170 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd -> #3 (&sbi->sb_lock){++++}-{3:3}: lock_acquire+0x182/0x3c0 kernel/locking/lockdep.c:5668 down_write+0x9c/0x270 kernel/locking/rwsem.c:1562 f2fs_down_write fs/f2fs/f2fs.h:2213 [inline] f2fs_handle_error+0xe0/0x230 fs/f2fs/super.c:3926 check_block_count+0x35d/0x490 build_sit_entries+0x1216/0x1e40 fs/f2fs/segment.c:4470 f2fs_build_segment_manager+0x1c2d/0x2a70 fs/f2fs/segment.c:5159 f2fs_fill_super+0x4a23/0x6ee0 fs/f2fs/super.c:4328 mount_bdev+0x26c/0x3a0 fs/super.c:1359 legacy_get_tree+0xea/0x180 fs/fs_context.c:610 vfs_get_tree+0x88/0x270 fs/super.c:1489 do_new_mount+0x289/0xad0 fs/namespace.c:3145 do_mount fs/namespace.c:3488 [inline] __do_sys_mount fs/namespace.c:3697 [inline] __se_sys_mount+0x2d3/0x3c0 fs/namespace.c:3674 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd -> #2 (&array[i].journal_rwsem){++++}-{3:3}: lock_acquire+0x182/0x3c0 kernel/locking/lockdep.c:5668 down_read+0x39/0x50 kernel/locking/rwsem.c:1509 scan_curseg_cache+0xa6/0x420 fs/f2fs/node.c:2404 __f2fs_build_free_nids fs/f2fs/node.c:2516 [inline] f2fs_build_free_nids+0xf07/0x1190 fs/f2fs/node.c:2531 f2fs_fill_super+0x4a5f/0x6ee0 fs/f2fs/super.c:4334 mount_bdev+0x26c/0x3a0 fs/super.c:1359 legacy_get_tree+0xea/0x180 fs/fs_context.c:610 vfs_get_tree+0x88/0x270 fs/super.c:1489 do_new_mount+0x289/0xad0 fs/namespace.c:3145 do_mount fs/namespace.c:3488 [inline] __do_sys_mount fs/namespace.c:3697 [inline] __se_sys_mount+0x2d3/0x3c0 fs/namespace.c:3674 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd -> #1 (&nm_i->nat_tree_lock){++++}-{3:3}: lock_acquire+0x182/0x3c0 kernel/locking/lockdep.c:5668 down_read+0x39/0x50 kernel/locking/rwsem.c:1509 f2fs_down_read fs/f2fs/f2fs.h:2188 [inline] f2fs_get_node_info+0x100/0x1720 fs/f2fs/node.c:564 f2fs_new_node_page+0x402/0xea0 fs/f2fs/node.c:1295 f2fs_get_dnode_of_data+0x5b0/0x1da0 fs/f2fs/node.c:810 f2fs_reserve_block+0x50/0x240 fs/f2fs/data.c:1199 f2fs_get_new_data_page+0x180/0x7b0 fs/f2fs/data.c:1387 f2fs_add_regular_entry+0x687/0xea0 fs/f2fs/dir.c:754 f2fs_add_dentry fs/f2fs/dir.c:816 [inline] f2fs_do_add_link+0x2a7/0x470 fs/f2fs/dir.c:855 f2fs_add_link fs/f2fs/f2fs.h:3564 [inline] f2fs_mkdir+0x2ec/0x520 fs/f2fs/namei.c:767 vfs_mkdir+0x3b3/0x590 fs/namei.c:4036 do_mkdirat+0x25b/0x530 fs/namei.c:4061 __do_sys_mkdir fs/namei.c:4081 [inline] __se_sys_mkdir fs/namei.c:4079 [inline] __x64_sys_mkdir+0x6a/0x80 fs/namei.c:4079 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd -> #0 (&sbi->cp_rwsem){++++}-{3:3}: check_prev_add kernel/locking/lockdep.c:3097 [inline] check_prevs_add kernel/locking/lockdep.c:3216 [inline] validate_chain+0x1898/0x6ae0 kernel/locking/lockdep.c:3831 __lock_acquire+0x1292/0x1f60 kernel/locking/lockdep.c:5055 lock_acquire+0x182/0x3c0 kernel/locking/lockdep.c:5668 down_read+0x39/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_convert_inline_inode+0x55f/0x820 fs/f2fs/inline.c:219 f2fs_vm_page_mkwrite+0x2d8/0x1350 fs/f2fs/file.c:79 do_page_mkwrite+0x19e/0x5e0 mm/memory.c:2947 do_shared_fault mm/memory.c:4579 [inline] do_fault mm/memory.c:4647 [inline] handle_pte_fault mm/memory.c:4931 [inline] __handle_mm_fault mm/memory.c:5073 [inline] handle_mm_fault+0x1952/0x26b0 mm/memory.c:5219 do_user_addr_fault+0x69b/0xcb0 arch/x86/mm/fault.c:1428 handle_page_fault arch/x86/mm/fault.c:1519 [inline] exc_page_fault+0x7a/0x110 arch/x86/mm/fault.c:1575 asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:570 other info that might help us debug this: Chain exists of: &sbi->cp_rwsem --> &sbi->sb_lock --> &mm->mmap_lock Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&mm->mmap_lock); lock(&sbi->sb_lock); lock(&mm->mmap_lock); lock(&sbi->cp_rwsem); *** DEADLOCK *** 1 lock held by syz-executor.3/10827: #0: ffff8880773912d8 (&mm->mmap_lock){++++}-{3:3}, at: mmap_read_lock+0x17/0x50 include/linux/mmap_lock.h:117 stack backtrace: CPU: 0 PID: 10827 Comm: syz-executor.3 Not tainted 6.2.0-rc5-syzkaller-00013-g2475bf0250de #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+0x1b1/0x290 lib/dump_stack.c:106 check_noncircular+0x2cc/0x390 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+0x1898/0x6ae0 kernel/locking/lockdep.c:3831 __lock_acquire+0x1292/0x1f60 kernel/locking/lockdep.c:5055 lock_acquire+0x182/0x3c0 kernel/locking/lockdep.c:5668 down_read+0x39/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_convert_inline_inode+0x55f/0x820 fs/f2fs/inline.c:219 f2fs_vm_page_mkwrite+0x2d8/0x1350 fs/f2fs/file.c:79 do_page_mkwrite+0x19e/0x5e0 mm/memory.c:2947 do_shared_fault mm/memory.c:4579 [inline] do_fault mm/memory.c:4647 [inline] handle_pte_fault mm/memory.c:4931 [inline] __handle_mm_fault mm/memory.c:5073 [inline] handle_mm_fault+0x1952/0x26b0 mm/memory.c:5219 do_user_addr_fault+0x69b/0xcb0 arch/x86/mm/fault.c:1428 handle_page_fault arch/x86/mm/fault.c:1519 [inline] exc_page_fault+0x7a/0x110 arch/x86/mm/fault.c:1575 asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:570 RIP: 0033:0x7fce66e86cad Code: 0f 11 5f 30 0f 11 64 17 f0 0f 11 6c 17 e0 0f 11 74 17 d0 0f 11 7c 17 c0 c3 0f 10 06 0f 10 4e 10 0f 10 54 16 f0 0f 10 5c 16 e0 <0f> 11 07 0f 11 4f 10 0f 11 54 17 f0 0f 11 5c 17 e0 c3 48 39 f7 0f RSP: 002b:00007ffe9c5082f8 EFLAGS: 00010283 RAX: 0000000020000040 RBX: 0000000000000000 RCX: 00007fce66a00000 RDX: 0000000000000025 RSI: 00007fce66a058e8 RDI: 0000000020000040 RBP: 00007ffe9c5083b8 R08: 00007fce66e00000 R09: 00007fce66a00000 R10: 00007fce66a058d0 R11: 0000000000000246 R12: 000000000006ca33 R13: 00007ffe9c5083e0 R14: 00007fce66fabf80 R15: 0000000000000032