syzbot


possible deadlock in f2fs_vm_page_mkwrite

Status: auto-obsoleted due to no activity on 2023/06/27 06:32
Subsystems: f2fs
[Documentation on labels]
Reported-by: syzbot+fb4ca11228cf7fef7938@syzkaller.appspotmail.com
First crash: 428d, last: 363d
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [f2fs?] possible deadlock in f2fs_vm_page_mkwrite 0 (1) 2022/12/28 07:15

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.2.0-syzkaller-12485-gf3a2439f20d9 #0 Not tainted
------------------------------------------------------
syz-executor.5/14654 is trying to acquire lock:
ffff88803b154180 (mapping.invalidate_lock#9){++++}-{3:3}, at: filemap_invalidate_lock_shared include/linux/fs.h:813 [inline]
ffff88803b154180 (mapping.invalidate_lock#9){++++}-{3:3}, at: f2fs_vm_page_mkwrite+0x630/0x1cf0 fs/f2fs/file.c:104

but task is already holding lock:
ffff88807a704558 (sb_pagefaults#3){.+.+}-{0:0}, at: do_page_mkwrite+0x19b/0x680 mm/memory.c:2925

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #5 (sb_pagefaults#3){.+.+}-{0:0}:
       percpu_down_read include/linux/percpu-rwsem.h:51 [inline]
       __sb_start_write include/linux/fs.h:1477 [inline]
       sb_start_pagefault include/linux/fs.h:1581 [inline]
       f2fs_vm_page_mkwrite+0x48a/0x1cf0 fs/f2fs/file.c:99
       do_page_mkwrite+0x19b/0x680 mm/memory.c:2925
       do_shared_fault mm/memory.c:4557 [inline]
       do_fault mm/memory.c:4625 [inline]
       handle_pte_fault mm/memory.c:4909 [inline]
       __handle_mm_fault+0x2242/0x3e60 mm/memory.c:5051
       handle_mm_fault+0x2ba/0x9c0 mm/memory.c:5197
       do_user_addr_fault+0x475/0x1230 arch/x86/mm/fault.c:1407
       handle_page_fault arch/x86/mm/fault.c:1498 [inline]
       exc_page_fault+0x98/0x170 arch/x86/mm/fault.c:1554
       asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:570

-> #4 (&mm->mmap_lock){++++}-{3:3}:
       __might_fault mm/memory.c:5625 [inline]
       __might_fault+0x10c/0x180 mm/memory.c:5618
       _copy_to_user+0x29/0x150 lib/usercopy.c:36
       copy_to_user include/linux/uaccess.h:169 [inline]
       f2fs_ioc_get_encryption_pwsalt fs/f2fs/file.c:2365 [inline]
       __f2fs_ioctl+0x3994/0xa910 fs/f2fs/file.c:4169
       f2fs_ioctl+0x18e/0x220 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]
       __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

-> #3 (&sbi->sb_lock){++++}-{3:3}:
       down_write+0x92/0x200 kernel/locking/rwsem.c:1573
       f2fs_down_write fs/f2fs/f2fs.h:2213 [inline]
       f2fs_handle_error+0x8e/0x220 fs/f2fs/super.c:3920
       f2fs_check_nid_range.part.0+0x4d/0x60 fs/f2fs/node.c:39
       f2fs_check_nid_range fs/f2fs/node.c:2282 [inline]
       add_free_nid.isra.0+0x781/0x940 fs/f2fs/node.c:2289
       scan_nat_page fs/f2fs/node.c:2391 [inline]
       __f2fs_build_free_nids+0x5b5/0xe10 fs/f2fs/node.c:2497
       f2fs_build_free_nids fs/f2fs/node.c:2535 [inline]
       f2fs_build_node_manager+0x2072/0x3000 fs/f2fs/node.c:3320
       f2fs_fill_super+0x39ad/0x8b90 fs/f2fs/super.c:4328
       mount_bdev+0x351/0x410 fs/super.c:1371
       legacy_get_tree+0x109/0x220 fs/fs_context.c:610
       vfs_get_tree+0x8d/0x350 fs/super.c:1501
       do_new_mount fs/namespace.c:3042 [inline]
       path_mount+0x1342/0x1e40 fs/namespace.c:3372
       do_mount fs/namespace.c:3385 [inline]
       __do_sys_mount fs/namespace.c:3594 [inline]
       __se_sys_mount fs/namespace.c:3571 [inline]
       __x64_sys_mount+0x283/0x300 fs/namespace.c:3571
       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 (&nm_i->nat_tree_lock){++++}-{3:3}:
       down_read+0x3d/0x50 kernel/locking/rwsem.c:1520
       f2fs_down_read fs/f2fs/f2fs.h:2188 [inline]
       f2fs_get_node_info+0x1ac/0x1070 fs/f2fs/node.c:564
       f2fs_new_node_page+0x249/0xac0 fs/f2fs/node.c:1295
       f2fs_get_dnode_of_data+0x530/0x2480 fs/f2fs/node.c:810
       f2fs_reserve_block+0x4d/0x430 fs/f2fs/data.c:1199
       f2fs_get_new_data_page+0xfb/0x6b0 fs/f2fs/data.c:1387
       f2fs_add_regular_entry+0x4e9/0xbe0 fs/f2fs/dir.c:754
       f2fs_add_dentry+0x1b5/0x210 fs/f2fs/dir.c:816
       f2fs_do_add_link+0x183/0x270 fs/f2fs/dir.c:855
       f2fs_add_link fs/f2fs/f2fs.h:3564 [inline]
       f2fs_create+0x3c1/0x670 fs/f2fs/namei.c:363
       lookup_open.isra.0+0x105a/0x1400 fs/namei.c:3416
       open_last_lookups fs/namei.c:3484 [inline]
       path_openat+0x975/0x2750 fs/namei.c:3712
       do_filp_open+0x1ba/0x410 fs/namei.c:3742
       do_sys_openat2+0x16d/0x4c0 fs/open.c:1312
       do_sys_open fs/open.c:1328 [inline]
       __do_sys_open fs/open.c:1336 [inline]
       __se_sys_open fs/open.c:1332 [inline]
       __x64_sys_open+0x11d/0x1c0 fs/open.c:1332
       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 (&sbi->cp_rwsem){++++}-{3:3}:
       down_read+0x3d/0x50 kernel/locking/rwsem.c:1520
       f2fs_down_read fs/f2fs/f2fs.h:2188 [inline]
       f2fs_lock_op fs/f2fs/f2fs.h:2231 [inline]
       f2fs_do_truncate_blocks+0x6ae/0x1220 fs/f2fs/file.c:688
       f2fs_truncate_blocks+0x7b/0x310 fs/f2fs/file.c:751
       f2fs_truncate.part.0+0x55e/0x7f0 fs/f2fs/file.c:803
       f2fs_truncate include/linux/fs.h:808 [inline]
       f2fs_setattr+0x1738/0x2090 fs/f2fs/file.c:1010
       notify_change+0xb2c/0x1180 fs/attr.c:482
       do_truncate+0x143/0x200 fs/open.c:66
       handle_truncate fs/namei.c:3219 [inline]
       do_open fs/namei.c:3564 [inline]
       path_openat+0x2083/0x2750 fs/namei.c:3715
       do_filp_open+0x1ba/0x410 fs/namei.c:3742
       do_sys_openat2+0x16d/0x4c0 fs/open.c:1312
       do_sys_open fs/open.c:1328 [inline]
       __do_sys_openat fs/open.c:1344 [inline]
       __se_sys_openat fs/open.c:1339 [inline]
       __x64_sys_openat+0x143/0x1f0 fs/open.c:1339
       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 (mapping.invalidate_lock#9){++++}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3098 [inline]
       check_prevs_add kernel/locking/lockdep.c:3217 [inline]
       validate_chain kernel/locking/lockdep.c:3832 [inline]
       __lock_acquire+0x2ec7/0x5d40 kernel/locking/lockdep.c:5056
       lock_acquire kernel/locking/lockdep.c:5669 [inline]
       lock_acquire+0x1e3/0x670 kernel/locking/lockdep.c:5634
       down_read+0x3d/0x50 kernel/locking/rwsem.c:1520
       filemap_invalidate_lock_shared include/linux/fs.h:813 [inline]
       f2fs_vm_page_mkwrite+0x630/0x1cf0 fs/f2fs/file.c:104
       do_page_mkwrite+0x19b/0x680 mm/memory.c:2925
       do_shared_fault mm/memory.c:4557 [inline]
       do_fault mm/memory.c:4625 [inline]
       handle_pte_fault mm/memory.c:4909 [inline]
       __handle_mm_fault+0x2242/0x3e60 mm/memory.c:5051
       handle_mm_fault+0x2ba/0x9c0 mm/memory.c:5197
       do_user_addr_fault+0x475/0x1230 arch/x86/mm/fault.c:1407
       handle_page_fault arch/x86/mm/fault.c:1498 [inline]
       exc_page_fault+0x98/0x170 arch/x86/mm/fault.c:1554
       asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:570

other info that might help us debug this:

Chain exists of:
  mapping.invalidate_lock#9 --> &mm->mmap_lock --> sb_pagefaults#3

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(sb_pagefaults#3);
                               lock(&mm->mmap_lock);
                               lock(sb_pagefaults#3);
  lock(mapping.invalidate_lock#9);

 *** DEADLOCK ***

2 locks held by syz-executor.5/14654:
 #0: ffff888017e5de18 (&mm->mmap_lock){++++}-{3:3}, at: mmap_read_lock include/linux/mmap_lock.h:117 [inline]
 #0: ffff888017e5de18 (&mm->mmap_lock){++++}-{3:3}, at: do_user_addr_fault+0xa51/0x1230 arch/x86/mm/fault.c:1358
 #1: ffff88807a704558 (sb_pagefaults#3){.+.+}-{0:0}, at: do_page_mkwrite+0x19b/0x680 mm/memory.c:2925

stack backtrace:
CPU: 1 PID: 14654 Comm: syz-executor.5 Not tainted 6.2.0-syzkaller-12485-gf3a2439f20d9 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/16/2023
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xd9/0x150 lib/dump_stack.c:106
 check_noncircular+0x25f/0x2e0 kernel/locking/lockdep.c:2178
 check_prev_add kernel/locking/lockdep.c:3098 [inline]
 check_prevs_add kernel/locking/lockdep.c:3217 [inline]
 validate_chain kernel/locking/lockdep.c:3832 [inline]
 __lock_acquire+0x2ec7/0x5d40 kernel/locking/lockdep.c:5056
 lock_acquire kernel/locking/lockdep.c:5669 [inline]
 lock_acquire+0x1e3/0x670 kernel/locking/lockdep.c:5634
 down_read+0x3d/0x50 kernel/locking/rwsem.c:1520
 filemap_invalidate_lock_shared include/linux/fs.h:813 [inline]
 f2fs_vm_page_mkwrite+0x630/0x1cf0 fs/f2fs/file.c:104
 do_page_mkwrite+0x19b/0x680 mm/memory.c:2925
 do_shared_fault mm/memory.c:4557 [inline]
 do_fault mm/memory.c:4625 [inline]
 handle_pte_fault mm/memory.c:4909 [inline]
 __handle_mm_fault+0x2242/0x3e60 mm/memory.c:5051
 handle_mm_fault+0x2ba/0x9c0 mm/memory.c:5197
 do_user_addr_fault+0x475/0x1230 arch/x86/mm/fault.c:1407
 handle_page_fault arch/x86/mm/fault.c:1498 [inline]
 exc_page_fault+0x98/0x170 arch/x86/mm/fault.c:1554
 asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:570
RIP: 0033:0x7fe6db42bd79
Code: 48 8b 04 24 48 85 c0 74 17 48 8b 54 24 18 48 0f ca 48 89 54 24 18 48 83 f8 01 0f 85 9b 02 00 00 48 8b 44 24 10 48 8b 54 24 18 <48> 89 10 e9 c2 fd ff ff 48 8b 44 24 10 0f b7 10 48 8b 04 24 48 85
RSP: 002b:00007ffe523b90a0 EFLAGS: 00010246
RAX: 0000000020007fc0 RBX: 0000000000000000 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 00005555569d82e8
RBP: 00007ffe523b9198 R08: 0000000000000000 R09: 0000000000000000
R10: 00007fe6db008210 R11: 0000000000000246 R12: 00000000000b7f50
R13: 00007ffe523b91c0 R14: 00007fe6db5abf80 R15: 0000000000000032
 </TASK>

Crashes (21):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/02/27 06:31 upstream f3a2439f20d9 ee50e71c .config console log report info ci-upstream-kasan-gce-root possible deadlock in f2fs_vm_page_mkwrite
2023/02/21 13:44 upstream 89f5349e0673 f949448d .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in f2fs_vm_page_mkwrite
2023/02/16 10:13 upstream 033c40a89f55 38b317a7 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in f2fs_vm_page_mkwrite
2023/02/16 04:19 upstream 033c40a89f55 6be0f1f5 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in f2fs_vm_page_mkwrite
2023/02/11 19:49 upstream 420b2d431d18 93e26d60 .config console log report info ci-upstream-kasan-gce-selinux-root possible deadlock in f2fs_vm_page_mkwrite
2023/02/07 04:33 upstream 05ecb680708a 0a9c11b6 .config console log report info ci2-upstream-fs possible deadlock in f2fs_vm_page_mkwrite
2023/02/01 21:32 upstream c0b67534c95c 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root possible deadlock in f2fs_vm_page_mkwrite
2023/02/01 05:46 upstream c0b67534c95c b68fb8d6 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in f2fs_vm_page_mkwrite
2023/01/29 07:08 upstream c96618275234 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in f2fs_vm_page_mkwrite
2023/01/29 02:04 upstream c96618275234 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in f2fs_vm_page_mkwrite
2023/01/28 05:58 upstream 83abd4d4c4be 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in f2fs_vm_page_mkwrite
2023/01/20 09:48 upstream d368967cb103 dd15ff29 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in f2fs_vm_page_mkwrite
2023/01/18 06:06 upstream 6e50979a9c87 42660d9e .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in f2fs_vm_page_mkwrite
2023/01/17 16:38 upstream 6e50979a9c87 42660d9e .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in f2fs_vm_page_mkwrite
2023/01/13 12:20 upstream c757fc92a3f7 96166539 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in f2fs_vm_page_mkwrite
2023/01/13 05:12 upstream c757fc92a3f7 96166539 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in f2fs_vm_page_mkwrite
2023/01/11 09:20 upstream 7dd4b804e080 1dac8c7a .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root possible deadlock in f2fs_vm_page_mkwrite
2022/12/24 07:13 upstream a27405b2ed9c 9da18ae8 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root possible deadlock in f2fs_vm_page_mkwrite
2023/01/24 22:30 upstream fb6e71db53f3 7374c4e5 .config console log report info ci-qemu-upstream-386 possible deadlock in f2fs_vm_page_mkwrite
2023/02/22 08:55 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci a9b06ec42c0f 42a4d508 .config console log report info ci-upstream-gce-arm64 possible deadlock in f2fs_vm_page_mkwrite
2023/02/18 11:55 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 2d3827b3f393 d02e9a70 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 possible deadlock in f2fs_vm_page_mkwrite
* Struck through repros no longer work on HEAD.