syzbot


possible deadlock in fscrypt_initialize
Status: upstream: reported on 2022/04/21 01:05
Reported-by: syzbot+1a748d0007eeac3ab079@syzkaller.appspotmail.com
First crash: 40d, last: 22d
duplicates (1):
Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
possible deadlock in evict (2) 1 40d 36d 0/22 closed as dup on 2022/04/21 19:37

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
5.18.0-rc5-syzkaller-00028-ga7391ad35724 #0 Not tainted
------------------------------------------------------
syz-executor.0/4919 is trying to acquire lock:
ffffffff8bf382e8 (fscrypt_init_mutex){+.+.}-{3:3}, at: fscrypt_initialize+0x3c/0xa0 fs/crypto/crypto.c:324

but task is already holding lock:
ffff8880432a6990 (jbd2_handle){++++}-{0:0}, at: start_this_handle+0xfb4/0x14a0 fs/jbd2/transaction.c:461

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (jbd2_handle){++++}-{0:0}:
       start_this_handle+0xfe7/0x14a0 fs/jbd2/transaction.c:463
       jbd2__journal_start+0x399/0x930 fs/jbd2/transaction.c:520
       __ext4_journal_start_sb+0x3a8/0x4a0 fs/ext4/ext4_jbd2.c:105
       __ext4_journal_start fs/ext4/ext4_jbd2.h:326 [inline]
       ext4_dirty_inode+0x9d/0x110 fs/ext4/inode.c:5946
       __mark_inode_dirty+0x45b/0xfe0 fs/fs-writeback.c:2367
       mark_inode_dirty_sync include/linux/fs.h:2329 [inline]
       iput.part.0+0x57/0x820 fs/inode.c:1767
       iput+0x58/0x70 fs/inode.c:1760
       dentry_unlink_inode+0x2b1/0x460 fs/dcache.c:401
       __dentry_kill+0x3c0/0x640 fs/dcache.c:607
       shrink_dentry_list+0x23c/0x800 fs/dcache.c:1201
       prune_dcache_sb+0xe7/0x140 fs/dcache.c:1282
       super_cache_scan+0x336/0x590 fs/super.c:104
       do_shrink_slab+0x42d/0xbd0 mm/vmscan.c:774
       shrink_slab+0x17c/0x6f0 mm/vmscan.c:934
       shrink_node_memcgs mm/vmscan.c:3100 [inline]
       shrink_node+0x8b3/0x1df0 mm/vmscan.c:3221
       kswapd_shrink_node mm/vmscan.c:4000 [inline]
       balance_pgdat+0x903/0x1580 mm/vmscan.c:4191
       kswapd+0x7a5/0xf80 mm/vmscan.c:4451
       kthread+0x2e9/0x3a0 kernel/kthread.c:376
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298

-> #1 (fs_reclaim){+.+.}-{0:0}:
       __fs_reclaim_acquire mm/page_alloc.c:4572 [inline]
       fs_reclaim_acquire+0x115/0x160 mm/page_alloc.c:4586
       might_alloc include/linux/sched/mm.h:262 [inline]
       slab_pre_alloc_hook mm/slab.h:722 [inline]
       slab_alloc_node mm/slab.c:3214 [inline]
       kmem_cache_alloc_node_trace+0x48/0x5b0 mm/slab.c:3625
       kmalloc_node include/linux/slab.h:599 [inline]
       kzalloc_node include/linux/slab.h:725 [inline]
       mempool_create_node mm/mempool.c:266 [inline]
       mempool_create+0x4e/0xc0 mm/mempool.c:255
       mempool_create_page_pool include/linux/mempool.h:107 [inline]
       fscrypt_initialize+0x86/0xa0 fs/crypto/crypto.c:330
       fscrypt_setup_encryption_info+0xef/0xf00 fs/crypto/keysetup.c:545
       fscrypt_get_encryption_info+0x34a/0x3f0 fs/crypto/keysetup.c:654
       fscrypt_setup_filename+0x238/0xec0 fs/crypto/fname.c:426
       __fscrypt_prepare_lookup+0x28/0xf0 fs/crypto/hooks.c:102
       fscrypt_prepare_lookup include/linux/fscrypt.h:898 [inline]
       ext4_fname_prepare_lookup+0x2b1/0x330 fs/ext4/ext4.h:2774
       ext4_lookup_entry fs/ext4/namei.c:1694 [inline]
       ext4_lookup fs/ext4/namei.c:1769 [inline]
       ext4_lookup+0x12d/0x730 fs/ext4/namei.c:1760
       __lookup_hash+0x117/0x180 fs/namei.c:1608
       filename_create+0x1d6/0x4a0 fs/namei.c:3703
       do_mkdirat+0x94/0x300 fs/namei.c:3946
       __do_sys_mkdir fs/namei.c:3977 [inline]
       __se_sys_mkdir fs/namei.c:3975 [inline]
       __x64_sys_mkdir+0xf2/0x140 fs/namei.c:3975
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x44/0xae

-> #0 (fscrypt_init_mutex){+.+.}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3065 [inline]
       check_prevs_add kernel/locking/lockdep.c:3188 [inline]
       validate_chain kernel/locking/lockdep.c:3803 [inline]
       __lock_acquire+0x2ac6/0x56c0 kernel/locking/lockdep.c:5029
       lock_acquire kernel/locking/lockdep.c:5641 [inline]
       lock_acquire+0x1ab/0x510 kernel/locking/lockdep.c:5606
       __mutex_lock_common kernel/locking/mutex.c:600 [inline]
       __mutex_lock+0x12f/0x12f0 kernel/locking/mutex.c:733
       fscrypt_initialize+0x3c/0xa0 fs/crypto/crypto.c:324
       fscrypt_setup_encryption_info+0xef/0xf00 fs/crypto/keysetup.c:545
       fscrypt_get_encryption_info+0x34a/0x3f0 fs/crypto/keysetup.c:654
       fscrypt_setup_filename+0x238/0xec0 fs/crypto/fname.c:426
       ext4_fname_setup_filename+0x8d/0x240 fs/ext4/ext4.h:2755
       ext4_find_entry+0x8c/0x170 fs/ext4/namei.c:1674
       __ext4_unlink+0x92/0x920 fs/ext4/namei.c:3155
       ext4_unlink+0x346/0x9e0 fs/ext4/namei.c:3231
       vfs_unlink+0x351/0x920 fs/namei.c:4148
       do_unlinkat+0x3c9/0x650 fs/namei.c:4216
       __do_sys_unlink fs/namei.c:4264 [inline]
       __se_sys_unlink fs/namei.c:4262 [inline]
       __x64_sys_unlink+0xc6/0x110 fs/namei.c:4262
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x44/0xae

other info that might help us debug this:

Chain exists of:
  fscrypt_init_mutex --> fs_reclaim --> jbd2_handle

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(jbd2_handle);
                               lock(fs_reclaim);
                               lock(jbd2_handle);
  lock(fscrypt_init_mutex);

 *** DEADLOCK ***

4 locks held by syz-executor.0/4919:
 #0: ffff888043122460 (sb_writers#5){.+.+}-{0:0}, at: do_unlinkat+0x17f/0x650 fs/namei.c:4195
 #1: ffff88801b1e0640 (&type->i_mutex_dir_key#3/1){+.+.}-{3:3}, at: inode_lock_nested include/linux/fs.h:783 [inline]
 #1: ffff88801b1e0640 (&type->i_mutex_dir_key#3/1){+.+.}-{3:3}, at: do_unlinkat+0x269/0x650 fs/namei.c:4199
 #2: ffff8880604ae440 (&sb->s_type->i_mutex_key#8){++++}-{3:3}, at: inode_lock include/linux/fs.h:748 [inline]
 #2: ffff8880604ae440 (&sb->s_type->i_mutex_key#8){++++}-{3:3}, at: vfs_unlink+0xd5/0x920 fs/namei.c:4137
 #3: ffff8880432a6990 (jbd2_handle){++++}-{0:0}, at: start_this_handle+0xfb4/0x14a0 fs/jbd2/transaction.c:461

stack backtrace:
CPU: 0 PID: 4919 Comm: syz-executor.0 Not tainted 5.18.0-rc5-syzkaller-00028-ga7391ad35724 #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.14.0-2 04/01/2014
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 check_noncircular+0x25f/0x2e0 kernel/locking/lockdep.c:2145
 check_prev_add kernel/locking/lockdep.c:3065 [inline]
 check_prevs_add kernel/locking/lockdep.c:3188 [inline]
 validate_chain kernel/locking/lockdep.c:3803 [inline]
 __lock_acquire+0x2ac6/0x56c0 kernel/locking/lockdep.c:5029
 lock_acquire kernel/locking/lockdep.c:5641 [inline]
 lock_acquire+0x1ab/0x510 kernel/locking/lockdep.c:5606
 __mutex_lock_common kernel/locking/mutex.c:600 [inline]
 __mutex_lock+0x12f/0x12f0 kernel/locking/mutex.c:733
 fscrypt_initialize+0x3c/0xa0 fs/crypto/crypto.c:324
 fscrypt_setup_encryption_info+0xef/0xf00 fs/crypto/keysetup.c:545
 fscrypt_get_encryption_info+0x34a/0x3f0 fs/crypto/keysetup.c:654
 fscrypt_setup_filename+0x238/0xec0 fs/crypto/fname.c:426
 ext4_fname_setup_filename+0x8d/0x240 fs/ext4/ext4.h:2755
 ext4_find_entry+0x8c/0x170 fs/ext4/namei.c:1674
 __ext4_unlink+0x92/0x920 fs/ext4/namei.c:3155
 ext4_unlink+0x346/0x9e0 fs/ext4/namei.c:3231
 vfs_unlink+0x351/0x920 fs/namei.c:4148
 do_unlinkat+0x3c9/0x650 fs/namei.c:4216
 __do_sys_unlink fs/namei.c:4264 [inline]
 __se_sys_unlink fs/namei.c:4262 [inline]
 __x64_sys_unlink+0xc6/0x110 fs/namei.c:4262
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7f765b288a27
Code: 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 b8 57 00 00 00 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:00007ffcc5265728 EFLAGS: 00000206 ORIG_RAX: 0000000000000057
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f765b288a27
RDX: 00007ffcc5265760 RSI: 00007ffcc5265760 RDI: 00007ffcc52657f0
RBP: 00007ffcc52657f0 R08: 0000000000000001 R09: 00007ffcc52655c0
R10: 00005555555bd8c3 R11: 0000000000000206 R12: 00007f765b2e21f8
R13: 00007ffcc52668f0 R14: 00005555555bd850 R15: 00007ffcc52679f0
 </TASK>

Crashes (2):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-qemu-upstream 2022/05/05 13:01 upstream a7391ad35724 b3f09415 .config log report info possible deadlock in fscrypt_initialize
ci-qemu-upstream 2022/04/17 01:01 upstream 90ea17a9e27b 8bcc32a6 .config log report info possible deadlock in fscrypt_initialize