syzbot


possible deadlock in ext4_evict_inode (2)

Status: upstream: reported on 2022/09/21 09:25
Reported-by: syzbot+b6ad7e348919e233ee7f@syzkaller.appspotmail.com
First crash: 76d, last: 14d
similar bugs (1):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in ext4_evict_inode syz error error 38 1513d 1552d 17/24 fixed on 2020/05/22 17:31

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.1.0-rc6-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.2/11252 is trying to acquire lock:
ffff88814b33e650 (sb_internal){.+.+}-{0:0}, at: __sb_start_write include/linux/fs.h:1826 [inline]
ffff88814b33e650 (sb_internal){.+.+}-{0:0}, at: sb_start_intwrite include/linux/fs.h:1948 [inline]
ffff88814b33e650 (sb_internal){.+.+}-{0:0}, at: ext4_evict_inode+0x4b7/0x1010 fs/ext4/inode.c:240

but task is already holding lock:
ffff88814b340b98 (&sbi->s_writepages_rwsem){++++}-{0:0}, at: ext4_ext_migrate+0x2e9/0x1310 fs/ext4/migrate.c:437

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 (&sbi->s_writepages_rwsem){++++}-{0:0}:
       lock_acquire+0x182/0x3c0 kernel/locking/lockdep.c:5668
       percpu_down_write+0x50/0x300 kernel/locking/percpu-rwsem.c:227
       ext4_ind_migrate+0x262/0x730 fs/ext4/migrate.c:624
       ext4_ioctl_setflags fs/ext4/ioctl.c:695 [inline]
       ext4_fileattr_set+0xe60/0x17f0 fs/ext4/ioctl.c:1003
       vfs_fileattr_set+0x8be/0xd20 fs/ioctl.c:696
       ioctl_setflags fs/ioctl.c:728 [inline]
       do_vfs_ioctl+0x1d26/0x29a0 fs/ioctl.c:839
       __do_sys_ioctl fs/ioctl.c:868 [inline]
       __se_sys_ioctl+0x83/0x170 fs/ioctl.c:856
       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+0x63/0xcd

-> #2 (&sb->s_type->i_mutex_key#8){++++}-{3:3}:
       lock_acquire+0x182/0x3c0 kernel/locking/lockdep.c:5668
       down_read+0x39/0x50 kernel/locking/rwsem.c:1509
       inode_lock_shared include/linux/fs.h:766 [inline]
       ext4_bmap+0x55/0x410 fs/ext4/inode.c:3164
       bmap+0xa1/0xd0 fs/inode.c:1798
       jbd2_journal_bmap fs/jbd2/journal.c:977 [inline]
       __jbd2_journal_erase fs/jbd2/journal.c:1789 [inline]
       jbd2_journal_flush+0x5d0/0xca0 fs/jbd2/journal.c:2492
       ext4_ioctl_checkpoint fs/ext4/ioctl.c:1081 [inline]
       __ext4_ioctl fs/ext4/ioctl.c:1586 [inline]
       ext4_ioctl+0x31ba/0x5430 fs/ext4/ioctl.c:1606
       vfs_ioctl fs/ioctl.c:51 [inline]
       __do_sys_ioctl fs/ioctl.c:870 [inline]
       __se_sys_ioctl+0xfb/0x170 fs/ioctl.c:856
       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+0x63/0xcd

-> #1 (&journal->j_checkpoint_mutex){+.+.}-{3:3}:
       lock_acquire+0x182/0x3c0 kernel/locking/lockdep.c:5668
       __mutex_lock_common+0x1bd/0x26e0 kernel/locking/mutex.c:603
       mutex_lock_io_nested+0x43/0x60 kernel/locking/mutex.c:833
       __jbd2_log_wait_for_space+0x21d/0x6f0 fs/jbd2/checkpoint.c:110
       add_transaction_credits+0x916/0xbd0 fs/jbd2/transaction.c:298
       start_this_handle+0x744/0x1670 fs/jbd2/transaction.c:422
       jbd2__journal_start+0x2ca/0x5b0 fs/jbd2/transaction.c:520
       __ext4_journal_start_sb+0x111/0x1d0 fs/ext4/ext4_jbd2.c:105
       __ext4_journal_start fs/ext4/ext4_jbd2.h:326 [inline]
       ext4_evict_inode+0x8e7/0x1010 fs/ext4/inode.c:251
       evict+0x2a4/0x620 fs/inode.c:664
       do_unlinkat+0x4f2/0x940 fs/namei.c:4326
       __do_sys_unlink fs/namei.c:4367 [inline]
       __se_sys_unlink fs/namei.c:4365 [inline]
       __x64_sys_unlink+0x45/0x50 fs/namei.c:4365
       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+0x63/0xcd

-> #0 (sb_internal){.+.+}-{0:0}:
       check_prev_add kernel/locking/lockdep.c:3097 [inline]
       check_prevs_add kernel/locking/lockdep.c:3216 [inline]
       validate_chain+0x1898/0x6ae0 kernel/locking/lockdep.c:3831
       __lock_acquire+0x1292/0x1f60 kernel/locking/lockdep.c:5055
       lock_acquire+0x182/0x3c0 kernel/locking/lockdep.c:5668
       percpu_down_read+0x44/0x190 include/linux/percpu-rwsem.h:51
       __sb_start_write include/linux/fs.h:1826 [inline]
       sb_start_intwrite include/linux/fs.h:1948 [inline]
       ext4_evict_inode+0x4b7/0x1010 fs/ext4/inode.c:240
       evict+0x2a4/0x620 fs/inode.c:664
       ext4_ext_migrate+0x100b/0x1310 fs/ext4/migrate.c:587
       __ext4_ioctl fs/ext4/ioctl.c:1388 [inline]
       ext4_ioctl+0x1b95/0x5430 fs/ext4/ioctl.c:1606
       vfs_ioctl fs/ioctl.c:51 [inline]
       __do_sys_ioctl fs/ioctl.c:870 [inline]
       __se_sys_ioctl+0xfb/0x170 fs/ioctl.c:856
       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+0x63/0xcd

other info that might help us debug this:

Chain exists of:
  sb_internal --> &sb->s_type->i_mutex_key#8 --> &sbi->s_writepages_rwsem

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&sbi->s_writepages_rwsem);
                               lock(&sb->s_type->i_mutex_key#8);
                               lock(&sbi->s_writepages_rwsem);
  lock(sb_internal);

 *** DEADLOCK ***

3 locks held by syz-executor.2/11252:
 #0: ffff88814b33e460 (sb_writers#4){.+.+}-{0:0}, at: mnt_want_write_file+0x5a/0x1f0 fs/namespace.c:437
 #1: ffff88805742e850 (&sb->s_type->i_mutex_key#8){++++}-{3:3}, at: inode_lock include/linux/fs.h:756 [inline]
 #1: ffff88805742e850 (&sb->s_type->i_mutex_key#8){++++}-{3:3}, at: __ext4_ioctl fs/ext4/ioctl.c:1387 [inline]
 #1: ffff88805742e850 (&sb->s_type->i_mutex_key#8){++++}-{3:3}, at: ext4_ioctl+0x1b8d/0x5430 fs/ext4/ioctl.c:1606
 #2: ffff88814b340b98 (&sbi->s_writepages_rwsem){++++}-{0:0}, at: ext4_ext_migrate+0x2e9/0x1310 fs/ext4/migrate.c:437

stack backtrace:
CPU: 0 PID: 11252 Comm: syz-executor.2 Not tainted 6.1.0-rc6-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1b1/0x28e lib/dump_stack.c:106
 check_noncircular+0x2cc/0x390 kernel/locking/lockdep.c:2177
 check_prev_add kernel/locking/lockdep.c:3097 [inline]
 check_prevs_add kernel/locking/lockdep.c:3216 [inline]
 validate_chain+0x1898/0x6ae0 kernel/locking/lockdep.c:3831
 __lock_acquire+0x1292/0x1f60 kernel/locking/lockdep.c:5055
 lock_acquire+0x182/0x3c0 kernel/locking/lockdep.c:5668
 percpu_down_read+0x44/0x190 include/linux/percpu-rwsem.h:51
 __sb_start_write include/linux/fs.h:1826 [inline]
 sb_start_intwrite include/linux/fs.h:1948 [inline]
 ext4_evict_inode+0x4b7/0x1010 fs/ext4/inode.c:240
 evict+0x2a4/0x620 fs/inode.c:664
 ext4_ext_migrate+0x100b/0x1310 fs/ext4/migrate.c:587
 __ext4_ioctl fs/ext4/ioctl.c:1388 [inline]
 ext4_ioctl+0x1b95/0x5430 fs/ext4/ioctl.c:1606
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:870 [inline]
 __se_sys_ioctl+0xfb/0x170 fs/ioctl.c:856
 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+0x63/0xcd
RIP: 0033:0x7f3b7dc8c189
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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f3b7e9bc168 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f3b7ddabf80 RCX: 00007f3b7dc8c189
RDX: 0000000000000000 RSI: 0000000000006609 RDI: 0000000000000003
RBP: 00007f3b7dce7b01 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffd5e23afbf R14: 00007f3b7e9bc300 R15: 0000000000022000
 </TASK>

Crashes (9):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci2-upstream-fs 2022/11/22 02:42 upstream eb7081409f94 1c576c23 .config log report info possible deadlock in ext4_evict_inode
ci2-upstream-fs 2022/10/04 21:20 upstream 4fe89d07dcc2 eab8f949 .config log report info possible deadlock in ext4_evict_inode
ci2-upstream-fs 2022/10/04 10:23 upstream 4fe89d07dcc2 978d1f19 .config log report info possible deadlock in ext4_evict_inode
ci2-upstream-fs 2022/10/03 21:52 upstream 4fe89d07dcc2 feb56351 .config log report info possible deadlock in ext4_evict_inode
ci2-upstream-fs 2022/10/03 20:24 upstream 4fe89d07dcc2 feb56351 .config log report info possible deadlock in ext4_evict_inode
ci2-upstream-fs 2022/09/24 16:50 upstream bf682942cd26 0042f2b4 .config log report info possible deadlock in ext4_evict_inode
ci2-upstream-fs 2022/09/23 23:33 upstream bf682942cd26 0042f2b4 .config log report info possible deadlock in ext4_evict_inode
ci2-upstream-fs 2022/09/21 03:32 upstream 60891ec99e14 c4b8ccfd .config log report info possible deadlock in ext4_evict_inode
ci-upstream-gce-arm64 2022/10/25 10:28 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci bbed346d5a96 45645420 .config log report info possible deadlock in ext4_evict_inode
* Struck through repros no longer work on HEAD.