====================================================== WARNING: possible circular locking dependency detected 6.2.0-rc6-syzkaller-00011-gc0b67534c95c #0 Not tainted ------------------------------------------------------ syz-executor.4/15457 is trying to acquire lock: ffff88801286e198 (&mm->mmap_lock){++++}-{3:3}, at: __might_fault+0x8f/0x110 mm/memory.c:5646 but task is already holding lock: ffff8880665bc088 (&sbi->sb_lock){++++}-{3:3}, at: f2fs_down_write fs/f2fs/f2fs.h:2213 [inline] ffff8880665bc088 (&sbi->sb_lock){++++}-{3:3}, at: f2fs_ioc_get_encryption_pwsalt fs/f2fs/file.c:2350 [inline] ffff8880665bc088 (&sbi->sb_lock){++++}-{3:3}, at: __f2fs_ioctl+0x365c/0xb650 fs/f2fs/file.c:4169 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #5 (&sbi->sb_lock){++++}-{3:3}: lock_acquire+0x1a7/0x400 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+0xe6/0x230 fs/f2fs/super.c:3926 scan_nat_page fs/f2fs/node.c:2387 [inline] __f2fs_build_free_nids fs/f2fs/node.c:2493 [inline] f2fs_build_free_nids+0xb9c/0x11a0 fs/f2fs/node.c:2531 f2fs_fill_super+0x5986/0x7e70 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+0x2e3/0x3d0 fs/namespace.c:3674 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd -> #4 (&nm_i->nat_tree_lock){++++}-{3:3}: lock_acquire+0x1a7/0x400 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 __write_node_page+0x7c5/0x20d0 fs/f2fs/node.c:1616 f2fs_sync_node_pages+0x11da/0x19d0 fs/f2fs/node.c:2020 block_operations fs/f2fs/checkpoint.c:1275 [inline] f2fs_write_checkpoint+0xeae/0x1d60 fs/f2fs/checkpoint.c:1655 __write_checkpoint_sync fs/f2fs/checkpoint.c:1772 [inline] __checkpoint_and_complete_reqs+0xd1/0x3a0 fs/f2fs/checkpoint.c:1791 issue_checkpoint_thread+0xdc/0x290 fs/f2fs/checkpoint.c:1822 kthread+0x266/0x300 kernel/kthread.c:376 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308 -> #3 (&sbi->node_change){++++}-{3:3}: lock_acquire+0x1a7/0x400 kernel/locking/lockdep.c:5668 down_read+0x39/0x50 kernel/locking/rwsem.c:1509 f2fs_vm_page_mkwrite+0x6d6/0x13a0 fs/f2fs/file.c:116 do_page_mkwrite+0x19e/0x5e0 mm/memory.c:2947 wp_page_shared+0x15e/0x380 mm/memory.c:3295 handle_pte_fault mm/memory.c:4949 [inline] __handle_mm_fault mm/memory.c:5073 [inline] handle_mm_fault+0x1b89/0x26c0 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/0x120 arch/x86/mm/fault.c:1575 asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:570 -> #2 (mapping.invalidate_lock#4){++++}-{3:3}: lock_acquire+0x1a7/0x400 kernel/locking/lockdep.c:5668 down_read+0x39/0x50 kernel/locking/rwsem.c:1509 filemap_invalidate_lock_shared include/linux/fs.h:811 [inline] f2fs_vm_page_mkwrite+0x511/0x13a0 fs/f2fs/file.c:104 do_page_mkwrite+0x19e/0x5e0 mm/memory.c:2947 wp_page_shared+0x15e/0x380 mm/memory.c:3295 handle_pte_fault mm/memory.c:4949 [inline] __handle_mm_fault mm/memory.c:5073 [inline] handle_mm_fault+0x1b89/0x26c0 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/0x120 arch/x86/mm/fault.c:1575 asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:570 -> #1 (sb_pagefaults#2){.+.+}-{0:0}: lock_acquire+0x1a7/0x400 kernel/locking/lockdep.c:5668 percpu_down_read include/linux/percpu-rwsem.h:51 [inline] __sb_start_write+0x5c/0x1b0 include/linux/fs.h:1814 sb_start_pagefault include/linux/fs.h:1918 [inline] f2fs_vm_page_mkwrite+0x44e/0x13a0 fs/f2fs/file.c:99 do_page_mkwrite+0x19e/0x5e0 mm/memory.c:2947 wp_page_shared+0x15e/0x380 mm/memory.c:3295 handle_pte_fault mm/memory.c:4949 [inline] __handle_mm_fault mm/memory.c:5073 [inline] handle_mm_fault+0x1b89/0x26c0 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/0x120 arch/x86/mm/fault.c:1575 asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:570 -> #0 (&mm->mmap_lock){++++}-{3:3}: check_prev_add kernel/locking/lockdep.c:3097 [inline] check_prevs_add kernel/locking/lockdep.c:3216 [inline] validate_chain+0x184a/0x6470 kernel/locking/lockdep.c:3831 __lock_acquire+0x1292/0x1f60 kernel/locking/lockdep.c:5055 lock_acquire+0x1a7/0x400 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+0xb072/0xb650 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+0x2b/0x70 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd other info that might help us debug this: Chain exists of: &mm->mmap_lock --> &nm_i->nat_tree_lock --> &sbi->sb_lock Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&sbi->sb_lock); lock(&nm_i->nat_tree_lock); lock(&sbi->sb_lock); lock(&mm->mmap_lock); *** DEADLOCK *** 2 locks held by syz-executor.4/15457: #0: ffff88807afec460 (sb_writers#15){.+.+}-{0:0}, at: mnt_want_write_file+0x5a/0x1f0 fs/namespace.c:552 #1: ffff8880665bc088 (&sbi->sb_lock){++++}-{3:3}, at: f2fs_down_write fs/f2fs/f2fs.h:2213 [inline] #1: ffff8880665bc088 (&sbi->sb_lock){++++}-{3:3}, at: f2fs_ioc_get_encryption_pwsalt fs/f2fs/file.c:2350 [inline] #1: ffff8880665bc088 (&sbi->sb_lock){++++}-{3:3}, at: __f2fs_ioctl+0x365c/0xb650 fs/f2fs/file.c:4169 stack backtrace: CPU: 0 PID: 15457 Comm: syz-executor.4 Not tainted 6.2.0-rc6-syzkaller-00011-gc0b67534c95c #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+0x1e3/0x2d0 lib/dump_stack.c:106 check_noncircular+0x2f9/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+0x184a/0x6470 kernel/locking/lockdep.c:3831 __lock_acquire+0x1292/0x1f60 kernel/locking/lockdep.c:5055 lock_acquire+0x1a7/0x400 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+0xb072/0xb650 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+0x2b/0x70 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7fb92aa8c0c9 Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 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:00007fb92b7a6168 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 00007fb92ababf80 RCX: 00007fb92aa8c0c9 RDX: 0000000000000000 RSI: 0000000040106614 RDI: 0000000000000005 RBP: 00007fb92aae7ae9 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007ffe0adc066f R14: 00007fb92b7a6300 R15: 0000000000022000