syzbot


possible deadlock in f2fs_ioc_get_encryption_pwsalt

Status: auto-obsoleted due to no activity on 2023/06/25 23:46
Subsystems: f2fs
[Documentation on labels]
Reported-by: syzbot+883ded0ab581cc190f58@syzkaller.appspotmail.com
First crash: 462d, last: 387d
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] possible deadlock in f2fs_ioc_get_encryption_pwsalt 0 (1) 2022/12/17 00:46

Sample crash report:
F2FS-fs (loop4): Mounted with checkpoint version = 753bd00b
======================================================
WARNING: possible circular locking dependency detected
6.2.0-syzkaller-10827-g489fa31ea873 #0 Not tainted
------------------------------------------------------
syz-executor.4/24152 is trying to acquire lock:
ffff88807b684d18 (&mm->mmap_lock){++++}-{3:3}, at: __might_fault+0xa9/0x180 mm/memory.c:5624

but task is already holding lock:
ffff888038f5c088 (&sbi->sb_lock){++++}-{3:3}, at: f2fs_down_write fs/f2fs/f2fs.h:2213 [inline]
ffff888038f5c088 (&sbi->sb_lock){++++}-{3:3}, at: f2fs_ioc_get_encryption_pwsalt+0x174/0x370 fs/f2fs/file.c:2350

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #5 (&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
       check_block_count+0x440/0x4f0 fs/f2fs/segment.h:765
       build_sit_entries fs/f2fs/segment.c:4470 [inline]
       f2fs_build_segment_manager+0x5600/0xa940 fs/f2fs/segment.c:5159
       f2fs_fill_super+0x398b/0x8b90 fs/f2fs/super.c:4322
       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

-> #4 (&array[i].journal_rwsem){++++}-{3:3}:
       down_read+0x3d/0x50 kernel/locking/rwsem.c:1520
       scan_curseg_cache+0xa7/0x3b0 fs/f2fs/node.c:2408
       __f2fs_build_free_nids+0x761/0xe10 fs/f2fs/node.c:2520
       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

-> #3 (&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
       __write_node_page+0x89f/0x2160 fs/f2fs/node.c:1617
       f2fs_sync_node_pages+0x13f7/0x22d0 fs/f2fs/node.c:2024
       block_operations+0x60c/0xc40 fs/f2fs/checkpoint.c:1278
       f2fs_write_checkpoint+0x606/0x4cb0 fs/f2fs/checkpoint.c:1658
       __write_checkpoint_sync fs/f2fs/checkpoint.c:1775 [inline]
       f2fs_issue_checkpoint+0x308/0x470 fs/f2fs/checkpoint.c:1872
       f2fs_sync_fs+0x244/0x4e0 fs/f2fs/super.c:1663
       f2fs_create+0x4c8/0x670 fs/f2fs/namei.c:373
       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_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

-> #2 (&sbi->node_change){++++}-{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_map_lock+0x4e/0x80 fs/f2fs/data.c:1464
       f2fs_vm_page_mkwrite+0x1293/0x1cf0 fs/f2fs/file.c:116
       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
       faultin_page mm/gup.c:925 [inline]
       __get_user_pages+0x4da/0xf30 mm/gup.c:1147
       __get_user_pages_locked mm/gup.c:1445 [inline]
       __gup_longterm_locked+0x89d/0x2420 mm/gup.c:2079
       pin_user_pages_remote+0x101/0x160 mm/gup.c:3122
       process_vm_rw_single_vec mm/process_vm_access.c:105 [inline]
       process_vm_rw_core.constprop.0+0x43b/0x990 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 (mapping.invalidate_lock#4){++++}-{3:3}:
       down_read+0x3d/0x50 kernel/locking/rwsem.c:1520
       filemap_invalidate_lock_shared include/linux/fs.h:813 [inline]
       filemap_fault+0xb99/0x2450 mm/filemap.c:3274
       f2fs_filemap_fault+0x82/0x400 fs/f2fs/file.c:44
       __do_fault+0x107/0x600 mm/memory.c:4141
       do_shared_fault mm/memory.c:4547 [inline]
       do_fault mm/memory.c:4625 [inline]
       handle_pte_fault mm/memory.c:4909 [inline]
       __handle_mm_fault+0x21c2/0x3e60 mm/memory.c:5051
       handle_mm_fault+0x2ba/0x9c0 mm/memory.c:5197
       faultin_page mm/gup.c:925 [inline]
       __get_user_pages+0x4da/0xf30 mm/gup.c:1147
       __get_user_pages_locked mm/gup.c:1381 [inline]
       __gup_longterm_locked+0x720/0x2420 mm/gup.c:2079
       pin_user_pages_remote+0x101/0x160 mm/gup.c:3122
       process_vm_rw_single_vec mm/process_vm_access.c:105 [inline]
       process_vm_rw_core.constprop.0+0x43b/0x990 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

-> #0 (&mm->mmap_lock){++++}-{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
       __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+0x2b2/0x370 fs/f2fs/file.c:2365
       __f2fs_ioctl+0x29db/0xabf0 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

other info that might help us debug this:

Chain exists of:
  &mm->mmap_lock --> &array[i].journal_rwsem --> &sbi->sb_lock

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&sbi->sb_lock);
                               lock(&array[i].journal_rwsem);
                               lock(&sbi->sb_lock);
  lock(&mm->mmap_lock);

 *** DEADLOCK ***

2 locks held by syz-executor.4/24152:
 #0: ffff88807b1a2460 (sb_writers#17){.+.+}-{0:0}, at: f2fs_ioc_get_encryption_pwsalt+0x136/0x370 fs/f2fs/file.c:2346
 #1: ffff888038f5c088 (&sbi->sb_lock){++++}-{3:3}, at: f2fs_down_write fs/f2fs/f2fs.h:2213 [inline]
 #1: ffff888038f5c088 (&sbi->sb_lock){++++}-{3:3}, at: f2fs_ioc_get_encryption_pwsalt+0x174/0x370 fs/f2fs/file.c:2350

stack backtrace:
CPU: 0 PID: 24152 Comm: syz-executor.4 Not tainted 6.2.0-syzkaller-10827-g489fa31ea873 #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
 __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+0x2b2/0x370 fs/f2fs/file.c:2365
 __f2fs_ioctl+0x29db/0xabf0 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
RIP: 0033:0x7f53aa68c0f9
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:00007f53ab3d0168 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f53aa7abf80 RCX: 00007f53aa68c0f9
RDX: 0000000000000000 RSI: 0000000040106614 RDI: 0000000000000004
RBP: 00007f53aa6e7ae9 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007fff55a4a95f R14: 00007f53ab3d0300 R15: 0000000000022000
 </TASK>

Crashes (21):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/02/25 23:46 upstream 489fa31ea873 ee50e71c .config console log report info ci-upstream-kasan-gce-selinux-root possible deadlock in f2fs_ioc_get_encryption_pwsalt
2023/02/15 06:41 upstream 82eac0c830b7 1d6b4af7 .config console log report info ci-upstream-kasan-gce-root possible deadlock in f2fs_ioc_get_encryption_pwsalt
2023/02/14 06:33 upstream f6feea56f66d 93ae7e0a .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root possible deadlock in f2fs_ioc_get_encryption_pwsalt
2023/02/12 02:58 upstream d12aca5c0cee 93e26d60 .config console log report info ci-upstream-kasan-gce-root possible deadlock in f2fs_ioc_get_encryption_pwsalt
2023/02/11 11:45 upstream 420b2d431d18 93e26d60 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root possible deadlock in f2fs_ioc_get_encryption_pwsalt
2023/02/08 01:01 upstream 513c1a3d3f19 15c3d445 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root possible deadlock in f2fs_ioc_get_encryption_pwsalt
2023/02/05 06:50 upstream 95078069c1e7 be607b78 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root possible deadlock in f2fs_ioc_get_encryption_pwsalt
2023/02/05 04:37 upstream 95078069c1e7 be607b78 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root possible deadlock in f2fs_ioc_get_encryption_pwsalt
2023/02/04 04:11 upstream 7b753a909f42 1b2f701a .config console log report info ci-upstream-kasan-gce-selinux-root possible deadlock in f2fs_ioc_get_encryption_pwsalt
2023/02/04 00:48 upstream 7b753a909f42 1b2f701a .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root possible deadlock in f2fs_ioc_get_encryption_pwsalt
2023/02/04 00:16 upstream 7b753a909f42 1b2f701a .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root possible deadlock in f2fs_ioc_get_encryption_pwsalt
2023/02/02 18:55 upstream 9f266ccaa2f5 16d19e30 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root possible deadlock in f2fs_ioc_get_encryption_pwsalt
2023/02/02 05:04 upstream 9f266ccaa2f5 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root possible deadlock in f2fs_ioc_get_encryption_pwsalt
2023/02/01 21:38 upstream c0b67534c95c 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root possible deadlock in f2fs_ioc_get_encryption_pwsalt
2023/01/28 18:33 upstream 5af6ce704936 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root possible deadlock in f2fs_ioc_get_encryption_pwsalt
2023/01/25 23:05 upstream 948ef7bb70c4 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root possible deadlock in f2fs_ioc_get_encryption_pwsalt
2023/01/25 21:25 upstream 948ef7bb70c4 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root possible deadlock in f2fs_ioc_get_encryption_pwsalt
2023/01/22 03:35 upstream f67144022885 559a440a .config console log report info ci-upstream-kasan-gce-root possible deadlock in f2fs_ioc_get_encryption_pwsalt
2023/01/14 23:55 upstream 97ec4d559d93 a63719e7 .config console log report info ci-upstream-kasan-gce-root possible deadlock in f2fs_ioc_get_encryption_pwsalt
2022/12/13 00:39 upstream 830b3c68c1fb 67be1ae7 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root possible deadlock in f2fs_ioc_get_encryption_pwsalt
2022/12/14 08:51 linux-next 663397d1b469 f6511626 .config console log report info ci-upstream-linux-next-kasan-gce-root possible deadlock in f2fs_ioc_get_encryption_pwsalt
* Struck through repros no longer work on HEAD.