syzbot


possible deadlock in f2fs_release_file

Status: auto-obsoleted due to no activity on 2023/11/01 18:27
Subsystems: f2fs
[Documentation on labels]
Reported-by: syzbot+e5b81eaab292e00e7d98@syzkaller.appspotmail.com
First crash: 359d, last: 278d
Cause bisection: introduced by (bisect log) [no-op commit]:
commit 45c548cc5baa047e59865bec5dfa0bd36b48ff17
Author: Yassine Oudjana <y.oudjana@protonmail.com>
Date: Thu Oct 21 13:24:25 2021 +0000

  dt-bindings: interconnect: Combine SDM660 bindings into RPM schema

Crash: no output from test machine (log)
Repro: C syz .config
  
Fix bisection: fixed by (bisect log) :
commit 5079e1c0c879311668b77075de3e701869804adf
Author: Chao Yu <chao@kernel.org>
Date: Fri Jun 2 08:36:05 2023 +0000

  f2fs: avoid dead loop in f2fs_issue_checkpoint()

  
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [f2fs?] possible deadlock in f2fs_release_file 0 (3) 2023/09/30 02:42
Last patch testing requests (4)
Created Duration User Patch Repo Result
2023/11/01 18:04 22m retest repro upstream OK log
2023/09/29 04:48 25m retest repro upstream report log
2023/08/23 14:31 25m retest repro upstream report log
2023/06/17 13:47 30m hdanton@sina.com patch https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git b6dad5178cea report log
Fix bisection attempts (2)
Created Duration User Patch Repo Result
2023/09/29 20:23 6h17m bisect fix upstream job log (1)
2023/07/20 21:29 2h32m bisect fix upstream job log (0) log
Cause bisection attempts (2)
Created Duration User Patch Repo Result
2023/09/22 23:20 9h44m bisect upstream job log (1) log
2023/06/16 15:15 7h37m bisect upstream job log (1) log
marked invalid by nogikh@google.com

Sample crash report:
syz-executor278: attempt to access beyond end of device
loop1: rw=2049, sector=81568, nr_sectors = 352 limit=63271
======================================================
WARNING: possible circular locking dependency detected
6.4.0-rc6-syzkaller-00037-gb6dad5178cea #0 Not tainted
------------------------------------------------------
syz-executor278/6432 is trying to acquire lock:
ffff888065251300 (&sb->s_type->i_mutex_key#15){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:775 [inline]
ffff888065251300 (&sb->s_type->i_mutex_key#15){+.+.}-{3:3}, at: f2fs_release_file fs/f2fs/file.c:1866 [inline]
ffff888065251300 (&sb->s_type->i_mutex_key#15){+.+.}-{3:3}, at: f2fs_release_file+0xca/0x100 fs/f2fs/file.c:1856

but task is already holding lock:
ffff88807b2f8448 (&sbi->node_write){++++}-{3:3}, at: f2fs_down_read fs/f2fs/f2fs.h:2087 [inline]
ffff88807b2f8448 (&sbi->node_write){++++}-{3:3}, at: f2fs_write_single_data_page+0x166e/0x19d0 fs/f2fs/data.c:2842

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&sbi->node_write){++++}-{3:3}:
       __lock_release kernel/locking/lockdep.c:5419 [inline]
       lock_release+0x33c/0x670 kernel/locking/lockdep.c:5725
       up_write+0x2a/0x520 kernel/locking/rwsem.c:1625
       f2fs_up_write fs/f2fs/f2fs.h:2122 [inline]
       block_operations+0xca4/0xe80 fs/f2fs/checkpoint.c:1288
       f2fs_write_checkpoint+0x5fa/0x4b40 fs/f2fs/checkpoint.c:1651
       __write_checkpoint_sync fs/f2fs/checkpoint.c:1768 [inline]
       __checkpoint_and_complete_reqs+0xea/0x350 fs/f2fs/checkpoint.c:1787
       issue_checkpoint_thread+0xe3/0x250 fs/f2fs/checkpoint.c:1818
       kthread+0x344/0x440 kernel/kthread.c:379
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308

-> #1 (&sbi->cp_rwsem){++++}-{3:3}:
       down_read+0x9c/0x480 kernel/locking/rwsem.c:1520
       f2fs_down_read fs/f2fs/f2fs.h:2087 [inline]
       f2fs_lock_op fs/f2fs/f2fs.h:2130 [inline]
       f2fs_convert_inline_inode+0x47b/0x8e0 fs/f2fs/inline.c:218
       f2fs_preallocate_blocks fs/f2fs/file.c:4480 [inline]
       f2fs_file_write_iter+0x1a1f/0x24d0 fs/f2fs/file.c:4712
       call_write_iter include/linux/fs.h:1868 [inline]
       do_iter_readv_writev+0x20b/0x3b0 fs/read_write.c:735
       do_iter_write+0x185/0x7e0 fs/read_write.c:860
       vfs_writev+0x1aa/0x670 fs/read_write.c:933
       do_pwritev+0x1b6/0x270 fs/read_write.c:1030
       __do_sys_pwritev2 fs/read_write.c:1089 [inline]
       __se_sys_pwritev2 fs/read_write.c:1080 [inline]
       __x64_sys_pwritev2+0xef/0x150 fs/read_write.c:1080
       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 (&sb->s_type->i_mutex_key#15){+.+.}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3113 [inline]
       check_prevs_add kernel/locking/lockdep.c:3232 [inline]
       validate_chain kernel/locking/lockdep.c:3847 [inline]
       __lock_acquire+0x2fcd/0x5f30 kernel/locking/lockdep.c:5088
       lock_acquire kernel/locking/lockdep.c:5705 [inline]
       lock_acquire+0x1b1/0x520 kernel/locking/lockdep.c:5670
       down_write+0x92/0x200 kernel/locking/rwsem.c:1573
       inode_lock include/linux/fs.h:775 [inline]
       f2fs_release_file fs/f2fs/file.c:1866 [inline]
       f2fs_release_file+0xca/0x100 fs/f2fs/file.c:1856
       __fput+0x27c/0xa90 fs/file_table.c:321
       task_work_run+0x16f/0x270 kernel/task_work.c:179
       exit_task_work include/linux/task_work.h:38 [inline]
       do_exit+0xaa3/0x29b0 kernel/exit.c:874
       do_group_exit+0xd4/0x2a0 kernel/exit.c:1024
       get_signal+0x2318/0x25b0 kernel/signal.c:2876
       arch_do_signal_or_restart+0x79/0x5c0 arch/x86/kernel/signal.c:306
       exit_to_user_mode_loop kernel/entry/common.c:168 [inline]
       exit_to_user_mode_prepare+0x11f/0x240 kernel/entry/common.c:204
       __syscall_exit_to_user_mode_work kernel/entry/common.c:286 [inline]
       syscall_exit_to_user_mode+0x1d/0x50 kernel/entry/common.c:297
       do_syscall_64+0x46/0xb0 arch/x86/entry/common.c:86
       entry_SYSCALL_64_after_hwframe+0x63/0xcd

other info that might help us debug this:

Chain exists of:
  &sb->s_type->i_mutex_key#15 --> &sbi->cp_rwsem --> &sbi->node_write

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  rlock(&sbi->node_write);
                               lock(&sbi->cp_rwsem);
                               lock(&sbi->node_write);
  lock(&sb->s_type->i_mutex_key#15);

 *** DEADLOCK ***

1 lock held by syz-executor278/6432:
 #0: ffff88807b2f8448 (&sbi->node_write){++++}-{3:3}, at: f2fs_down_read fs/f2fs/f2fs.h:2087 [inline]
 #0: ffff88807b2f8448 (&sbi->node_write){++++}-{3:3}, at: f2fs_write_single_data_page+0x166e/0x19d0 fs/f2fs/data.c:2842

stack backtrace:
CPU: 1 PID: 6432 Comm: syz-executor278 Not tainted 6.4.0-rc6-syzkaller-00037-gb6dad5178cea #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/27/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:2188
 check_prev_add kernel/locking/lockdep.c:3113 [inline]
 check_prevs_add kernel/locking/lockdep.c:3232 [inline]
 validate_chain kernel/locking/lockdep.c:3847 [inline]
 __lock_acquire+0x2fcd/0x5f30 kernel/locking/lockdep.c:5088
 lock_acquire kernel/locking/lockdep.c:5705 [inline]
 lock_acquire+0x1b1/0x520 kernel/locking/lockdep.c:5670
 down_write+0x92/0x200 kernel/locking/rwsem.c:1573
 inode_lock include/linux/fs.h:775 [inline]
 f2fs_release_file fs/f2fs/file.c:1866 [inline]
 f2fs_release_file+0xca/0x100 fs/f2fs/file.c:1856
 __fput+0x27c/0xa90 fs/file_table.c:321
 task_work_run+0x16f/0x270 kernel/task_work.c:179
 exit_task_work include/linux/task_work.h:38 [inline]
 do_exit+0xaa3/0x29b0 kernel/exit.c:874
 do_group_exit+0xd4/0x2a0 kernel/exit.c:1024
 get_signal+0x2318/0x25b0 kernel/signal.c:2876
 arch_do_signal_or_restart+0x79/0x5c0 arch/x86/kernel/signal.c:306
 exit_to_user_mode_loop kernel/entry/common.c:168 [inline]
 exit_to_user_mode_prepare+0x11f/0x240 kernel/entry/common.c:204
 __syscall_exit_to_user_mode_work kernel/entry/common.c:286 [inline]
 syscall_exit_to_user_mode+0x1d/0x50 kernel/entry/common.c:297
 do_syscall_64+0x46/0xb0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7fedb69cb649
Code: Unable to access opcode bytes at 0x7fedb69cb61f.
RSP: 002b:00007fedb6977308 EFLAGS: 00000246 ORIG_RAX: 0000000000000148
RAX: fffffffffffffffb RBX: 00007fedb6a587a8 RCX: 00007fedb69cb649
RDX: 0000000000000001 RSI: 0000000020000240 RDI: 0000000000000004
RBP: 00007fedb6a587a0 R08: 0000000000000000 R09: 0000000000000003
R10: 0000000000001400 R11: 0000000000000246 R12: 6f6f6c2f7665642f
R13: 00007fffd688275f R14: 00007fedb6977400 R15: 0000000000022000
 </TASK>

Crashes (4):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/06/16 00:40 upstream b6dad5178cea 757d26ed .config strace log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci-upstream-kasan-gce-root possible deadlock in f2fs_release_file
2023/06/15 08:37 upstream b6dad5178cea 76decb82 .config console log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci-upstream-kasan-gce-root possible deadlock in f2fs_release_file
2023/05/01 10:06 upstream 58390c8ce1bd 62df2017 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in f2fs_release_file
2023/04/30 23:16 upstream 58390c8ce1bd 62df2017 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in f2fs_release_file
* Struck through repros no longer work on HEAD.