syzbot


possible deadlock in __f2fs_ioctl

Status: auto-obsoleted due to no activity on 2024/03/17 16:22
Reported-by: syzbot+63ecc02174a03203a89f@syzkaller.appspotmail.com
First crash: 348d, last: 348d
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in __f2fs_ioctl (2) f2fs 84 627d 674d 0/28 auto-obsoleted due to no activity on 2023/06/02 19:31
upstream possible deadlock in __f2fs_ioctl f2fs 17 680d 713d 22/28 fixed on 2023/01/11 16:14

Sample crash report:
F2FS-fs (loop5): Try to recover 1th superblock, ret: 0
F2FS-fs (loop5): Mounted with checkpoint version = 753bd00b
======================================================
WARNING: possible circular locking dependency detected
5.15.142-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.5/10615 is trying to acquire lock:
ffff888024e83928 (&mm->mmap_lock){++++}-{3:3}, at: __might_fault+0x91/0x110 mm/memory.c:5323

but task is already holding lock:
ffff8880a1f0c088 (&sbi->sb_lock){++++}-{3:3}, at: f2fs_ioc_get_encryption_pwsalt fs/f2fs/file.c:2356 [inline]
ffff8880a1f0c088 (&sbi->sb_lock){++++}-{3:3}, at: __f2fs_ioctl+0x37b7/0xc8a0 fs/f2fs/file.c:4156

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #4 (&sbi->sb_lock){++++}-{3:3}:
       lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
       down_write+0x97/0x170 kernel/locking/rwsem.c:1541
       update_sb_metadata+0x85/0x9a0 fs/f2fs/gc.c:1943
       f2fs_resize_fs+0x87b/0xd10 fs/f2fs/gc.c:2097
       f2fs_ioc_resize_fs fs/f2fs/file.c:3255 [inline]
       __f2fs_ioctl+0x42f6/0xc8a0 fs/f2fs/file.c:4190
       vfs_ioctl fs/ioctl.c:51 [inline]
       __do_sys_ioctl fs/ioctl.c:874 [inline]
       __se_sys_ioctl+0xf1/0x160 fs/ioctl.c:860
       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+0x61/0xcb

-> #3 (&sbi->cp_global_sem){+.+.}-{3:3}:
       lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
       down_write+0x97/0x170 kernel/locking/rwsem.c:1541
       f2fs_write_checkpoint+0x343/0x1b50 fs/f2fs/checkpoint.c:1641
       __write_checkpoint_sync fs/f2fs/checkpoint.c:1771 [inline]
       __checkpoint_and_complete_reqs+0xd6/0x3b0 fs/f2fs/checkpoint.c:1790
       issue_checkpoint_thread+0xd6/0x260 fs/f2fs/checkpoint.c:1821
       kthread+0x3f6/0x4f0 kernel/kthread.c:319
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298

-> #2 (&sbi->gc_lock){+.+.}-{3:3}:
       lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
       down_write+0x97/0x170 kernel/locking/rwsem.c:1541
       f2fs_issue_checkpoint+0x2c8/0x4c0 fs/f2fs/checkpoint.c:1860
       sync_filesystem+0x1bc/0x220 fs/sync.c:66
       freeze_super+0x16b/0x420 fs/super.c:1711
       f2fs_resize_fs+0x690/0xd10 fs/f2fs/gc.c:2071
       f2fs_ioc_resize_fs fs/f2fs/file.c:3255 [inline]
       __f2fs_ioctl+0x42f6/0xc8a0 fs/f2fs/file.c:4190
       vfs_ioctl fs/ioctl.c:51 [inline]
       __do_sys_ioctl fs/ioctl.c:874 [inline]
       __se_sys_ioctl+0xf1/0x160 fs/ioctl.c:860
       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+0x61/0xcb

-> #1 (sb_pagefaults#3){++++}-{0:0}:
       lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
       percpu_down_read include/linux/percpu-rwsem.h:51 [inline]
       __sb_start_write+0x5a/0x1c0 include/linux/fs.h:1785
       sb_start_pagefault include/linux/fs.h:1884 [inline]
       f2fs_vm_page_mkwrite+0x43d/0xe20 fs/f2fs/file.c:98
       do_page_mkwrite+0x1a9/0x440 mm/memory.c:2892
       do_shared_fault mm/memory.c:4298 [inline]
       do_fault mm/memory.c:4366 [inline]
       handle_pte_fault mm/memory.c:4621 [inline]
       __handle_mm_fault mm/memory.c:4756 [inline]
       handle_mm_fault+0x2803/0x5950 mm/memory.c:4854
       do_user_addr_fault arch/x86/mm/fault.c:1397 [inline]
       handle_page_fault arch/x86/mm/fault.c:1485 [inline]
       exc_page_fault+0x271/0x740 arch/x86/mm/fault.c:1541
       asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:568

-> #0 (&mm->mmap_lock){++++}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3053 [inline]
       check_prevs_add kernel/locking/lockdep.c:3172 [inline]
       validate_chain+0x1649/0x5930 kernel/locking/lockdep.c:3788
       __lock_acquire+0x1295/0x1ff0 kernel/locking/lockdep.c:5012
       lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
       __might_fault+0xb4/0x110 mm/memory.c:5324
       _copy_to_user+0x28/0x130 lib/usercopy.c:35
       copy_to_user include/linux/uaccess.h:200 [inline]
       f2fs_ioc_get_encryption_pwsalt fs/f2fs/file.c:2371 [inline]
       __f2fs_ioctl+0xc16f/0xc8a0 fs/f2fs/file.c:4156
       vfs_ioctl fs/ioctl.c:51 [inline]
       __do_sys_ioctl fs/ioctl.c:874 [inline]
       __se_sys_ioctl+0xf1/0x160 fs/ioctl.c:860
       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+0x61/0xcb

other info that might help us debug this:

Chain exists of:
  &mm->mmap_lock --> &sbi->cp_global_sem --> &sbi->sb_lock

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&sbi->sb_lock);
                               lock(&sbi->cp_global_sem);
                               lock(&sbi->sb_lock);
  lock(&mm->mmap_lock);

 *** DEADLOCK ***

2 locks held by syz-executor.5/10615:
 #0: ffff888038f72460 (sb_writers#25){++++}-{0:0}, at: mnt_want_write_file+0x5a/0x1f0 fs/namespace.c:421
 #1: ffff8880a1f0c088 (&sbi->sb_lock){++++}-{3:3}, at: f2fs_ioc_get_encryption_pwsalt fs/f2fs/file.c:2356 [inline]
 #1: ffff8880a1f0c088 (&sbi->sb_lock){++++}-{3:3}, at: __f2fs_ioctl+0x37b7/0xc8a0 fs/f2fs/file.c:4156

stack backtrace:
CPU: 1 PID: 10615 Comm: syz-executor.5 Not tainted 5.15.142-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/10/2023
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 check_noncircular+0x2f8/0x3b0 kernel/locking/lockdep.c:2133
 check_prev_add kernel/locking/lockdep.c:3053 [inline]
 check_prevs_add kernel/locking/lockdep.c:3172 [inline]
 validate_chain+0x1649/0x5930 kernel/locking/lockdep.c:3788
 __lock_acquire+0x1295/0x1ff0 kernel/locking/lockdep.c:5012
 lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
 __might_fault+0xb4/0x110 mm/memory.c:5324
 _copy_to_user+0x28/0x130 lib/usercopy.c:35
 copy_to_user include/linux/uaccess.h:200 [inline]
 f2fs_ioc_get_encryption_pwsalt fs/f2fs/file.c:2371 [inline]
 __f2fs_ioctl+0xc16f/0xc8a0 fs/f2fs/file.c:4156
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:874 [inline]
 __se_sys_ioctl+0xf1/0x160 fs/ioctl.c:860
 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+0x61/0xcb
RIP: 0033:0x7fa6c148bba9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 20 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 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fa6bfa0d0c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007fa6c15aaf80 RCX: 00007fa6c148bba9
RDX: 0000000020007f80 RSI: 0000000040106614 RDI: 0000000000000004
RBP: 00007fa6c14d747a R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 000000000000000b R14: 00007fa6c15aaf80 R15: 00007fff38e83058
 </TASK>

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/12/08 16:21 linux-5.15.y 8a1d809b0545 28b24332 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in __f2fs_ioctl
* Struck through repros no longer work on HEAD.