syzbot


possible deadlock in f2fs_release_file (2)

Status: closed as invalid on 2024/09/05 01:48
Subsystems: f2fs
[Documentation on labels]
Reported-by: syzbot+9aff3b6811f0a00daffa@syzkaller.appspotmail.com
First crash: 31d, last: 31d
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [f2fs?] possible deadlock in f2fs_release_file (2) 1 (2) 2024/09/05 01:48
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in f2fs_release_file f2fs C unreliable done 4 419d 499d 0/27 auto-obsoleted due to no activity on 2023/11/01 18:27

Sample crash report:
F2FS-fs (loop0): Try to recover 1th superblock, ret: 0
F2FS-fs (loop0): Mounted with checkpoint version = 48b305e5
syz.0.98: attempt to access beyond end of device
loop0: rw=2049, sector=45096, nr_sectors = 8 limit=40427
======================================================
WARNING: possible circular locking dependency detected
6.11.0-rc3-next-20240812-syzkaller #0 Not tainted
------------------------------------------------------
syz.0.98/5917 is trying to acquire lock:
ffff88807896ad30 (&sb->s_type->i_mutex_key#26){++++}-{3:3}, at: inode_lock include/linux/fs.h:799 [inline]
ffff88807896ad30 (&sb->s_type->i_mutex_key#26){++++}-{3:3}, at: f2fs_release_file+0x9b/0x100 fs/f2fs/file.c:1940

but task is already holding lock:
ffff88807896b308 (&fi->i_gc_rwsem[WRITE]){++++}-{3:3}, at: f2fs_down_write fs/f2fs/f2fs.h:2196 [inline]
ffff88807896b308 (&fi->i_gc_rwsem[WRITE]){++++}-{3:3}, at: f2fs_commit_atomic_write+0x105/0x1510 fs/f2fs/segment.c:388

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&fi->i_gc_rwsem[WRITE]){++++}-{3:3}:
       lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5762
       down_write+0x99/0x220 kernel/locking/rwsem.c:1579
       f2fs_down_write fs/f2fs/f2fs.h:2196 [inline]
       f2fs_setattr+0xb80/0x12d0 fs/f2fs/file.c:1060
       notify_change+0xb9d/0xe70 fs/attr.c:535
       do_truncate+0x220/0x310 fs/open.c:65
       handle_truncate fs/namei.c:3395 [inline]
       do_open fs/namei.c:3745 [inline]
       path_openat+0x2ced/0x3470 fs/namei.c:3900
       do_filp_open+0x235/0x490 fs/namei.c:3927
       do_sys_openat2+0x13e/0x1d0 fs/open.c:1416
       do_sys_open fs/open.c:1431 [inline]
       __do_sys_creat fs/open.c:1507 [inline]
       __se_sys_creat fs/open.c:1501 [inline]
       __x64_sys_creat+0x123/0x170 fs/open.c:1501
       do_syscall_x64 arch/x86/entry/common.c:52 [inline]
       do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #0 (&sb->s_type->i_mutex_key#26){++++}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3136 [inline]
       check_prevs_add kernel/locking/lockdep.c:3255 [inline]
       validate_chain+0x18e0/0x5900 kernel/locking/lockdep.c:3871
       __lock_acquire+0x137a/0x2040 kernel/locking/lockdep.c:5145
       lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5762
       down_write+0x99/0x220 kernel/locking/rwsem.c:1579
       inode_lock include/linux/fs.h:799 [inline]
       f2fs_release_file+0x9b/0x100 fs/f2fs/file.c:1940
       __fput+0x24a/0x8a0 fs/file_table.c:425
       task_work_run+0x24f/0x310 kernel/task_work.c:228
       get_signal+0x16ad/0x1810 kernel/signal.c:2690
       arch_do_signal_or_restart+0x96/0x830 arch/x86/kernel/signal.c:337
       exit_to_user_mode_loop kernel/entry/common.c:111 [inline]
       exit_to_user_mode_prepare include/linux/entry-common.h:328 [inline]
       __syscall_exit_to_user_mode_work kernel/entry/common.c:207 [inline]
       syscall_exit_to_user_mode+0xc9/0x370 kernel/entry/common.c:218
       do_syscall_64+0x100/0x230 arch/x86/entry/common.c:89
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

other info that might help us debug this:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&fi->i_gc_rwsem[WRITE]);
                               lock(&sb->s_type->i_mutex_key#26);
                               lock(&fi->i_gc_rwsem[WRITE]);
  lock(&sb->s_type->i_mutex_key#26);

 *** DEADLOCK ***

1 lock held by syz.0.98/5917:
 #0: ffff88807896b308 (&fi->i_gc_rwsem[WRITE]){++++}-{3:3}, at: f2fs_down_write fs/f2fs/f2fs.h:2196 [inline]
 #0: ffff88807896b308 (&fi->i_gc_rwsem[WRITE]){++++}-{3:3}, at: f2fs_commit_atomic_write+0x105/0x1510 fs/f2fs/segment.c:388

stack backtrace:
CPU: 0 UID: 0 PID: 5917 Comm: syz.0.98 Not tainted 6.11.0-rc3-next-20240812-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/27/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120
 check_noncircular+0x36a/0x4a0 kernel/locking/lockdep.c:2189
 check_prev_add kernel/locking/lockdep.c:3136 [inline]
 check_prevs_add kernel/locking/lockdep.c:3255 [inline]
 validate_chain+0x18e0/0x5900 kernel/locking/lockdep.c:3871
 __lock_acquire+0x137a/0x2040 kernel/locking/lockdep.c:5145
 lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5762
 down_write+0x99/0x220 kernel/locking/rwsem.c:1579
 inode_lock include/linux/fs.h:799 [inline]
 f2fs_release_file+0x9b/0x100 fs/f2fs/file.c:1940
 __fput+0x24a/0x8a0 fs/file_table.c:425
 task_work_run+0x24f/0x310 kernel/task_work.c:228
 get_signal+0x16ad/0x1810 kernel/signal.c:2690
 arch_do_signal_or_restart+0x96/0x830 arch/x86/kernel/signal.c:337
 exit_to_user_mode_loop kernel/entry/common.c:111 [inline]
 exit_to_user_mode_prepare include/linux/entry-common.h:328 [inline]
 __syscall_exit_to_user_mode_work kernel/entry/common.c:207 [inline]
 syscall_exit_to_user_mode+0xc9/0x370 kernel/entry/common.c:218
 do_syscall_64+0x100/0x230 arch/x86/entry/common.c:89
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f1c8c1779f9
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 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 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f1c8d01f038 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: fffffffffffffffb RBX: 00007f1c8c305f80 RCX: 00007f1c8c1779f9
RDX: 0000000000000000 RSI: 000000000000f502 RDI: 0000000000000004
RBP: 00007f1c8c1e58ee R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f1c8c305f80 R15: 00007ffdbf6238f8
 </TASK>

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/08/12 09:12 linux-next 9e6869691724 6f4edef4 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root possible deadlock in f2fs_release_file
* Struck through repros no longer work on HEAD.