syzbot


possible deadlock in fscrypt_initialize (2)

Status: closed as dup on 2023/11/27 21:45
Subsystems: fscrypt
[Documentation on labels]
Reported-by: syzbot+3a3b5221ffafba7d5204@syzkaller.appspotmail.com
First crash: 458d, last: 398d
Duplicate of
Title Repro Cause bisect Fix bisect Count Last Reported
possible deadlock in start_this_handle (4) fscrypt ext4 48 3d01h 455d
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [fscrypt?] possible deadlock in fscrypt_initialize (2) 2 (3) 2023/11/27 21:45
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in fscrypt_initialize fscrypt 10 459d 769d 22/26 fixed on 2023/02/24 13:50

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.3.0-syzkaller-00436-g173ea743bf7a #0 Not tainted
------------------------------------------------------
syz-executor.2/7821 is trying to acquire lock:
ffffffff8c96a0a8 (fscrypt_init_mutex){+.+.}-{3:3}, at: fscrypt_initialize+0x40/0xa0 fs/crypto/crypto.c:326

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

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 (jbd2_handle){++++}-{0:0}:
       start_this_handle+0xfe7/0x14e0 fs/jbd2/transaction.c:463
       jbd2__journal_start+0x390/0x850 fs/jbd2/transaction.c:520
       __ext4_journal_start_sb+0x411/0x5d0 fs/ext4/ext4_jbd2.c:111
       ext4_sample_last_mounted fs/ext4/file.c:851 [inline]
       ext4_file_open+0x618/0xbf0 fs/ext4/file.c:880
       do_dentry_open+0x6cc/0x13f0 fs/open.c:920
       do_open fs/namei.c:3560 [inline]
       path_openat+0x1baa/0x2750 fs/namei.c:3715
       do_filp_open+0x1ba/0x410 fs/namei.c:3742
       do_sys_openat2+0x16d/0x4c0 fs/open.c:1356
       do_sys_open fs/open.c:1372 [inline]
       __do_sys_openat fs/open.c:1388 [inline]
       __se_sys_openat fs/open.c:1383 [inline]
       __x64_sys_openat+0x143/0x1f0 fs/open.c:1383
       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

-> #2 (sb_internal){.+.+}-{0:0}:
       percpu_down_read include/linux/percpu-rwsem.h:51 [inline]
       __sb_start_write include/linux/fs.h:1477 [inline]
       sb_start_intwrite include/linux/fs.h:1599 [inline]
       ext4_evict_inode+0x114b/0x1ca0 fs/ext4/inode.c:240
       evict+0x2ed/0x6b0 fs/inode.c:665
       iput_final fs/inode.c:1748 [inline]
       iput.part.0+0x50a/0x740 fs/inode.c:1774
       iput+0x5c/0x80 fs/inode.c:1764
       dentry_unlink_inode+0x2b1/0x460 fs/dcache.c:401
       __dentry_kill+0x3c0/0x640 fs/dcache.c:607
       shrink_dentry_list+0x12c/0x4f0 fs/dcache.c:1201
       prune_dcache_sb+0xeb/0x150 fs/dcache.c:1282
       super_cache_scan+0x33a/0x590 fs/super.c:104
       do_shrink_slab+0x428/0xaa0 mm/vmscan.c:853
       shrink_slab_memcg mm/vmscan.c:922 [inline]
       shrink_slab+0x388/0x660 mm/vmscan.c:1001
       shrink_one+0x502/0x810 mm/vmscan.c:5343
       shrink_many mm/vmscan.c:5394 [inline]
       lru_gen_shrink_node mm/vmscan.c:5511 [inline]
       shrink_node+0x2064/0x35f0 mm/vmscan.c:6459
       kswapd_shrink_node mm/vmscan.c:7262 [inline]
       balance_pgdat+0xa02/0x1ac0 mm/vmscan.c:7452
       kswapd+0x677/0xd60 mm/vmscan.c:7712
       kthread+0x33e/0x440 kernel/kthread.c:379
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308

-> #1 (fs_reclaim){+.+.}-{0:0}:
       __fs_reclaim_acquire mm/page_alloc.c:4717 [inline]
       fs_reclaim_acquire+0x11d/0x160 mm/page_alloc.c:4731
       might_alloc include/linux/sched/mm.h:271 [inline]
       slab_pre_alloc_hook mm/slab.h:728 [inline]
       slab_alloc_node mm/slab.c:3241 [inline]
       __kmem_cache_alloc_node+0x3b/0x3f0 mm/slab.c:3541
       kmalloc_node_trace+0x21/0xd0 mm/slab_common.c:1074
       kmalloc_node include/linux/slab.h:606 [inline]
       kzalloc_node include/linux/slab.h:731 [inline]
       mempool_create_node mm/mempool.c:272 [inline]
       mempool_create+0x52/0xc0 mm/mempool.c:261
       mempool_create_page_pool include/linux/mempool.h:112 [inline]
       fscrypt_initialize+0x8a/0xa0 fs/crypto/crypto.c:332
       fscrypt_setup_encryption_info+0xef/0xeb0 fs/crypto/keysetup.c:563
       fscrypt_get_encryption_info+0x375/0x450 fs/crypto/keysetup.c:668
       fscrypt_setup_filename+0x23c/0xec0 fs/crypto/fname.c:458
       __fscrypt_prepare_lookup+0x2c/0xf0 fs/crypto/hooks.c:100
       fscrypt_prepare_lookup include/linux/fscrypt.h:935 [inline]
       ext4_fname_prepare_lookup+0x1be/0x200 fs/ext4/crypto.c:46
       ext4_lookup_entry fs/ext4/namei.c:1744 [inline]
       ext4_lookup fs/ext4/namei.c:1819 [inline]
       ext4_lookup+0x131/0x700 fs/ext4/namei.c:1810
       lookup_open.isra.0+0x944/0x1400 fs/namei.c:3394
       open_last_lookups fs/namei.c:3484 [inline]
       path_openat+0x975/0x2750 fs/namei.c:3712
       do_filp_open+0x1ba/0x410 fs/namei.c:3742
       do_sys_openat2+0x16d/0x4c0 fs/open.c:1356
       do_sys_open fs/open.c:1372 [inline]
       __do_sys_creat fs/open.c:1448 [inline]
       __se_sys_creat fs/open.c:1442 [inline]
       __x64_sys_creat+0xcd/0x120 fs/open.c:1442
       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 (fscrypt_init_mutex){+.+.}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3108 [inline]
       check_prevs_add kernel/locking/lockdep.c:3227 [inline]
       validate_chain kernel/locking/lockdep.c:3842 [inline]
       __lock_acquire+0x2f21/0x5df0 kernel/locking/lockdep.c:5074
       lock_acquire kernel/locking/lockdep.c:5691 [inline]
       lock_acquire+0x1b1/0x520 kernel/locking/lockdep.c:5656
       __mutex_lock_common kernel/locking/mutex.c:603 [inline]
       __mutex_lock+0x12f/0x1350 kernel/locking/mutex.c:747
       fscrypt_initialize+0x40/0xa0 fs/crypto/crypto.c:326
       fscrypt_setup_encryption_info+0xef/0xeb0 fs/crypto/keysetup.c:563
       fscrypt_get_encryption_info+0x375/0x450 fs/crypto/keysetup.c:668
       fscrypt_setup_filename+0x23c/0xec0 fs/crypto/fname.c:458
       ext4_fname_setup_filename+0x8c/0x110 fs/ext4/crypto.c:28
       ext4_add_entry+0x3aa/0xe30 fs/ext4/namei.c:2379
       ext4_rename+0x1a6a/0x2790 fs/ext4/namei.c:3915
       ext4_rename2+0x1c7/0x270 fs/ext4/namei.c:4200
       vfs_rename+0xef6/0x17a0 fs/namei.c:4772
       do_renameat2+0xb62/0xc90 fs/namei.c:4923
       __do_sys_renameat2 fs/namei.c:4956 [inline]
       __se_sys_renameat2 fs/namei.c:4953 [inline]
       __x64_sys_renameat2+0xe8/0x120 fs/namei.c:4953
       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

other info that might help us debug this:

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

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  rlock(jbd2_handle);
                               lock(sb_internal);
                               lock(jbd2_handle);
  lock(fscrypt_init_mutex);

 *** DEADLOCK ***

6 locks held by syz-executor.2/7821:
 #0: ffff8880203ba460 (sb_writers#5){.+.+}-{0:0}, at: do_renameat2+0x37f/0xc90 fs/namei.c:4859
 #1: ffff8880203ba748 (&type->s_vfs_rename_key#2){+.+.}-{3:3}, at: lock_rename+0x58/0x280 fs/namei.c:2995
 #2: ffff88802adb8880 (&type->i_mutex_dir_key#3/1){+.+.}-{3:3}, at: inode_lock_nested include/linux/fs.h:793 [inline]
 #2: ffff88802adb8880 (&type->i_mutex_dir_key#3/1){+.+.}-{3:3}, at: lock_rename+0xa4/0x280 fs/namei.c:2999
 #3: ffff888029b56600 (&type->i_mutex_dir_key#3/2){+.+.}-{3:3}, at: inode_lock_nested include/linux/fs.h:793 [inline]
 #3: ffff888029b56600 (&type->i_mutex_dir_key#3/2){+.+.}-{3:3}, at: lock_rename+0xd8/0x280 fs/namei.c:3000
 #4: ffff88800fda8440 (&sb->s_type->i_mutex_key#7/4){+.+.}-{3:3}, at: inode_lock_nested include/linux/fs.h:793 [inline]
 #4: ffff88800fda8440 (&sb->s_type->i_mutex_key#7/4){+.+.}-{3:3}, at: lock_two_nondirectories+0xd5/0x110 fs/inode.c:1124
 #5: ffff88801c02a990 (jbd2_handle){++++}-{0:0}, at: start_this_handle+0xfb4/0x14e0 fs/jbd2/transaction.c:461

stack backtrace:
CPU: 3 PID: 7821 Comm: syz-executor.2 Not tainted 6.3.0-syzkaller-00436-g173ea743bf7a #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+0xd9/0x150 lib/dump_stack.c:106
 check_noncircular+0x25f/0x2e0 kernel/locking/lockdep.c:2188
 check_prev_add kernel/locking/lockdep.c:3108 [inline]
 check_prevs_add kernel/locking/lockdep.c:3227 [inline]
 validate_chain kernel/locking/lockdep.c:3842 [inline]
 __lock_acquire+0x2f21/0x5df0 kernel/locking/lockdep.c:5074
 lock_acquire kernel/locking/lockdep.c:5691 [inline]
 lock_acquire+0x1b1/0x520 kernel/locking/lockdep.c:5656
 __mutex_lock_common kernel/locking/mutex.c:603 [inline]
 __mutex_lock+0x12f/0x1350 kernel/locking/mutex.c:747
 fscrypt_initialize+0x40/0xa0 fs/crypto/crypto.c:326
 fscrypt_setup_encryption_info+0xef/0xeb0 fs/crypto/keysetup.c:563
 fscrypt_get_encryption_info+0x375/0x450 fs/crypto/keysetup.c:668
 fscrypt_setup_filename+0x23c/0xec0 fs/crypto/fname.c:458
 ext4_fname_setup_filename+0x8c/0x110 fs/ext4/crypto.c:28
 ext4_add_entry+0x3aa/0xe30 fs/ext4/namei.c:2379
 ext4_rename+0x1a6a/0x2790 fs/ext4/namei.c:3915
 ext4_rename2+0x1c7/0x270 fs/ext4/namei.c:4200
 vfs_rename+0xef6/0x17a0 fs/namei.c:4772
 do_renameat2+0xb62/0xc90 fs/namei.c:4923
 __do_sys_renameat2 fs/namei.c:4956 [inline]
 __se_sys_renameat2 fs/namei.c:4953 [inline]
 __x64_sys_renameat2+0xe8/0x120 fs/namei.c:4953
 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
RIP: 0033:0x7fd320e8c169
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fd321cd9168 EFLAGS: 00000246 ORIG_RAX: 000000000000013c
RAX: ffffffffffffffda RBX: 00007fd320fabf80 RCX: 00007fd320e8c169
RDX: 0000000000000003 RSI: 0000000020000080 RDI: 0000000000000004
RBP: 00007fd320ee7ca1 R08: 0000000000000004 R09: 0000000000000000
R10: 00000000200000c0 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffee98d16cf R14: 00007fd321cd9300 R15: 0000000000022000
 </TASK>

Crashes (63):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/04/25 15:54 upstream 173ea743bf7a 65320f8e .config console log report info ci-qemu-upstream possible deadlock in fscrypt_initialize
2023/04/20 12:50 upstream cb0856346a60 5ed6c74d .config console log report info ci-qemu-upstream possible deadlock in fscrypt_initialize
2023/04/18 23:36 upstream af67688dca57 d931e9f0 .config console log report info ci-qemu-upstream possible deadlock in fscrypt_initialize
2023/04/18 17:59 upstream 6a8f57ae2eb0 d931e9f0 .config console log report info ci-qemu-upstream possible deadlock in fscrypt_initialize
2023/04/17 04:55 upstream 6a8f57ae2eb0 ec410564 .config console log report info ci-qemu-upstream possible deadlock in fscrypt_initialize
2023/04/15 22:46 upstream a7a55e27ad72 ec410564 .config console log report info ci-qemu-upstream possible deadlock in fscrypt_initialize
2023/04/14 15:13 upstream 44149752e998 ec410564 .config console log report info ci-qemu-upstream possible deadlock in fscrypt_initialize
2023/04/11 20:34 upstream 2c40519251d6 49faf98d .config console log report info ci-qemu-upstream possible deadlock in fscrypt_initialize
2023/04/09 13:33 upstream cdc9718d5e59 71147e29 .config console log report info ci-qemu-upstream possible deadlock in fscrypt_initialize
2023/04/08 10:36 upstream aa318c48808c 71147e29 .config console log report info ci-qemu-upstream possible deadlock in fscrypt_initialize
2023/04/03 09:03 upstream 7e364e56293b 41147e3e .config console log report info ci-qemu-upstream possible deadlock in fscrypt_initialize
2023/04/02 04:58 upstream 00c7b5f4ddc5 f325deb0 .config console log report info ci-qemu-upstream possible deadlock in fscrypt_initialize
2023/03/31 11:47 upstream 62bad54b26db f325deb0 .config console log report info ci-qemu-upstream possible deadlock in fscrypt_initialize
2023/03/28 00:44 upstream 3a93e40326c8 47f3aaf1 .config console log report info ci-qemu-upstream possible deadlock in fscrypt_initialize
2023/03/27 23:30 upstream 3a93e40326c8 47f3aaf1 .config console log report info ci-qemu-upstream possible deadlock in fscrypt_initialize
2023/03/27 11:40 upstream 197b6b60ae7b f8f96aa9 .config console log report info ci-qemu-upstream possible deadlock in fscrypt_initialize
2023/03/26 20:43 upstream 0ec57cfa721f fbf0499a .config console log report info ci-qemu-upstream possible deadlock in fscrypt_initialize
2023/03/25 06:48 upstream e76db6e50c85 fbf0499a .config console log report info ci-qemu-upstream possible deadlock in fscrypt_initialize
2023/03/24 12:40 upstream 1e760fa3596e f94b4a29 .config console log report info ci-qemu-upstream possible deadlock in fscrypt_initialize
2023/03/19 00:00 upstream 534293368afa 7939252e .config console log report info ci-qemu-upstream possible deadlock in fscrypt_initialize
2023/03/18 03:19 upstream cb80b960ce44 7939252e .config console log report info ci-qemu-upstream possible deadlock in fscrypt_initialize
2023/04/26 10:41 upstream 4173cf6fb6b7 7560799c .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/04/24 23:53 upstream 1a0beef98b58 65320f8e .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/04/24 20:44 upstream 1a0beef98b58 c778c7f4 .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/04/24 00:44 upstream 457391b03803 2b32bd34 .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/04/22 19:05 upstream 2caeeb9d4a1b 2b32bd34 .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/04/17 20:37 upstream 6a8f57ae2eb0 436577a9 .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/04/17 13:46 upstream 6a8f57ae2eb0 c6ec7083 .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/04/16 14:17 upstream 3e7bb4f24617 ec410564 .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/04/16 00:19 upstream a7a55e27ad72 ec410564 .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/04/14 20:53 upstream 95abc817ab3a ec410564 .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/04/14 19:40 upstream 95abc817ab3a ec410564 .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/04/08 01:18 upstream aa318c48808c 71147e29 .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/04/05 21:55 upstream 99ddf2254feb 8b834965 .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/04/03 19:33 upstream 148341f0a2f5 7db618d0 .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/04/01 13:47 upstream 7b50567bdcad f325deb0 .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/03/27 10:25 upstream 197b6b60ae7b f8f96aa9 .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/03/26 19:53 upstream 18940c888c85 fbf0499a .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/03/25 19:35 upstream 65aca32efdcb fbf0499a .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/03/25 04:18 upstream e76db6e50c85 fbf0499a .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/03/24 15:44 upstream 1e760fa3596e ee89d73c .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/03/24 00:03 upstream 9fd6ba5420ba f94b4a29 .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/03/23 19:26 upstream 9fd6ba5420ba f94b4a29 .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/03/22 14:05 upstream a1effab7a3a3 d846e076 .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/03/21 13:07 upstream 17214b70a159 03fb9538 .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/03/20 19:27 upstream 7d31677bb7b1 7939252e .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/03/19 01:42 upstream 534293368afa 7939252e .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/03/19 00:07 upstream 534293368afa 7939252e .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/03/18 09:21 upstream 478a351ce0d6 7939252e .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/03/16 22:32 upstream 0ddc84d2dd43 18b58603 .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/03/15 23:44 upstream 9c1bec9c0b08 18b58603 .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/03/14 19:35 upstream 4979bf866825 0d5c4377 .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/03/14 11:52 upstream fc89d7fb499b 0d5c4377 .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/03/14 06:31 upstream fc89d7fb499b 026e2200 .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/03/13 09:16 upstream eeac8ede1755 5205ef30 .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/03/12 22:47 upstream 134231664868 5205ef30 .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/03/03 04:17 upstream a9a01e1238cf f8902b57 .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/03/01 12:07 upstream c0927a7a5391 ef65e6cb .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/03/01 09:37 upstream c0927a7a5391 ef65e6cb .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/03/01 02:21 upstream c0927a7a5391 95aee97a .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
2023/02/25 14:52 upstream 489fa31ea873 630c6bc9 .config console log report info ci-qemu-upstream-386 possible deadlock in fscrypt_initialize
* Struck through repros no longer work on HEAD.