====================================================== WARNING: possible circular locking dependency detected syzkaller #0 Tainted: G L ------------------------------------------------------ syz.3.340/7262 is trying to acquire lock: ffff88806160ebb8 (&ima_iint_mutex_key[depth]){+.+.}-{4:4}, at: process_measurement+0x5ab/0x2360 security/integrity/ima/ima_main.c:319 but task is already holding lock: ffff888027e04478 (sb_writers#6){.+.+}-{0:0}, at: do_open fs/namei.c:4838 [inline] ffff888027e04478 (sb_writers#6){.+.+}-{0:0}, at: path_openat+0x1920/0x23f0 fs/namei.c:5016 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #4 (sb_writers#6){.+.+}-{0:0}: lock_acquire kernel/locking/lockdep.c:5942 [inline] lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5899 percpu_down_read_internal include/linux/percpu-rwsem.h:53 [inline] percpu_down_read_freezable include/linux/percpu-rwsem.h:83 [inline] __sb_start_write include/linux/fs/super.h:19 [inline] sb_start_write include/linux/fs/super.h:125 [inline] mnt_want_write+0x6a/0x420 fs/namespace.c:531 ovl_create_object+0x130/0x3b0 fs/overlayfs/dir.c:715 lookup_open+0xd8a/0x19e0 fs/namei.c:4575 open_last_lookups fs/namei.c:4774 [inline] path_openat+0xe75/0x23f0 fs/namei.c:5013 do_file_open+0x20e/0x430 fs/namei.c:5045 do_sys_openat2+0x163/0x1d0 fs/open.c:1443 do_sys_open fs/open.c:1449 [inline] __do_sys_openat fs/open.c:1465 [inline] __se_sys_openat fs/open.c:1460 [inline] __x64_sys_openat+0x12d/0x210 fs/open.c:1460 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline] do_syscall_64+0x123/0x790 arch/x86/entry/syscall_64.c:84 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #3 (&ovl_i_mutex_dir_key[depth]){++++}-{4:4}: lock_acquire kernel/locking/lockdep.c:5942 [inline] lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5899 down_read+0x94/0x4c0 kernel/locking/rwsem.c:1574 inode_lock_shared include/linux/fs.h:1041 [inline] lookup_slow+0x41/0x80 fs/namei.c:1941 walk_component fs/namei.c:2288 [inline] link_path_walk+0x1449/0x1bd0 fs/namei.c:2662 path_lookupat+0x74/0xc40 fs/namei.c:2818 filename_lookup+0x202/0x590 fs/namei.c:2848 kern_path+0x37/0x50 fs/namei.c:3042 lookup_bdev+0xd8/0x2a0 block/bdev.c:1268 bdev_file_open_by_path+0x82/0x330 block/bdev.c:1123 add_device drivers/mtd/devices/block2mtd.c:279 [inline] block2mtd_setup2.isra.0+0x2f8/0xc60 drivers/mtd/devices/block2mtd.c:459 block2mtd_setup+0xbd/0xd0 drivers/mtd/devices/block2mtd.c:476 param_attr_store+0x199/0x300 kernel/params.c:591 module_attr_store+0x58/0x80 kernel/params.c:906 sysfs_kf_write+0xf2/0x150 fs/sysfs/file.c:145 kernfs_fop_write_iter+0x3e0/0x5f0 fs/kernfs/file.c:345 new_sync_write fs/read_write.c:595 [inline] vfs_write+0x6af/0x1050 fs/read_write.c:687 ksys_write+0x12a/0x250 fs/read_write.c:739 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline] do_syscall_64+0x123/0x790 arch/x86/entry/syscall_64.c:84 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #2 (param_lock){+.+.}-{4:4}: lock_acquire kernel/locking/lockdep.c:5942 [inline] lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5899 __mutex_lock_common kernel/locking/mutex.c:646 [inline] __mutex_lock+0x19f/0x1c10 kernel/locking/mutex.c:821 kernel_param_lock kernel/params.c:604 [inline] param_attr_show+0xe7/0x230 kernel/params.c:572 module_attr_show+0x50/0x80 kernel/params.c:887 sysfs_kf_seq_show+0x217/0x3f0 fs/sysfs/file.c:65 seq_read_iter+0x32f/0x1270 fs/seq_file.c:231 kernfs_fop_read_iter+0x46c/0x610 fs/kernfs/file.c:290 new_sync_read fs/read_write.c:493 [inline] vfs_read+0x82e/0xb40 fs/read_write.c:574 ksys_read+0x12a/0x250 fs/read_write.c:716 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline] do_syscall_64+0x123/0x790 arch/x86/entry/syscall_64.c:84 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #1 (&of->mutex#2){+.+.}-{4:4}: lock_acquire kernel/locking/lockdep.c:5942 [inline] lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5899 __mutex_lock_common kernel/locking/mutex.c:646 [inline] __mutex_lock+0x19f/0x1c10 kernel/locking/mutex.c:821 kernfs_file_read_iter fs/kernfs/file.c:251 [inline] kernfs_fop_read_iter+0x188/0x610 fs/kernfs/file.c:291 __kernel_read+0x397/0xad0 fs/read_write.c:532 integrity_kernel_read+0x7e/0xb0 security/integrity/iint.c:28 ima_calc_file_hash_tfm+0x25e/0x350 security/integrity/ima/ima_crypto.c:222 ima_calc_file_hash+0x1e3/0x380 security/integrity/ima/ima_crypto.c:280 ima_collect_measurement+0x952/0xb30 security/integrity/ima/ima_api.c:300 process_measurement+0xe04/0x2360 security/integrity/ima/ima_main.c:425 ima_file_check+0xbf/0x110 security/integrity/ima/ima_main.c:686 security_file_post_open+0xc4/0x210 security/security.c:2776 do_open fs/namei.c:4853 [inline] path_openat+0x5d0/0x23f0 fs/namei.c:5016 do_file_open+0x20e/0x430 fs/namei.c:5045 do_sys_openat2+0x163/0x1d0 fs/open.c:1443 do_sys_open fs/open.c:1449 [inline] __do_sys_openat fs/open.c:1465 [inline] __se_sys_openat fs/open.c:1460 [inline] __x64_sys_openat+0x12d/0x210 fs/open.c:1460 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline] do_syscall_64+0x123/0x790 arch/x86/entry/syscall_64.c:84 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #0 (&ima_iint_mutex_key[depth]){+.+.}-{4:4}: check_prev_add+0xeb/0xe60 kernel/locking/lockdep.c:3209 check_prevs_add kernel/locking/lockdep.c:3328 [inline] validate_chain kernel/locking/lockdep.c:3952 [inline] __lock_acquire+0x1528/0x1f40 kernel/locking/lockdep.c:5288 lock_acquire kernel/locking/lockdep.c:5942 [inline] lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5899 __mutex_lock_common kernel/locking/mutex.c:646 [inline] __mutex_lock+0x19f/0x1c10 kernel/locking/mutex.c:821 process_measurement+0x5ab/0x2360 security/integrity/ima/ima_main.c:319 ima_file_check+0xbf/0x110 security/integrity/ima/ima_main.c:686 security_file_post_open+0xc4/0x210 security/security.c:2776 do_open fs/namei.c:4853 [inline] path_openat+0x5d0/0x23f0 fs/namei.c:5016 do_file_open+0x20e/0x430 fs/namei.c:5045 do_sys_openat2+0x163/0x1d0 fs/open.c:1443 do_sys_open fs/open.c:1449 [inline] __do_sys_openat fs/open.c:1465 [inline] __se_sys_openat fs/open.c:1460 [inline] __x64_sys_openat+0x12d/0x210 fs/open.c:1460 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline] do_syscall_64+0x123/0x790 arch/x86/entry/syscall_64.c:84 entry_SYSCALL_64_after_hwframe+0x77/0x7f other info that might help us debug this: Chain exists of: &ima_iint_mutex_key[depth] --> &ovl_i_mutex_dir_key[depth] --> sb_writers#6 Possible unsafe locking scenario: CPU0 CPU1 ---- ---- rlock(sb_writers#6); lock(&ovl_i_mutex_dir_key[depth]); lock(sb_writers#6); lock(&ima_iint_mutex_key[depth]); *** DEADLOCK *** locks held by syz.3.340/7262: 1, last CPU#2: #0: ffff888027e04478 (sb_writers#6){.+.+}-{0:0}, at: do_open fs/namei.c:4838 [inline] #0: ffff888027e04478 (sb_writers#6){.+.+}-{0:0}, at: path_openat+0x1920/0x23f0 fs/namei.c:5016 stack backtrace: CPU: 2 UID: 0 PID: 7262 Comm: syz.3.340 Tainted: G L syzkaller #0 PREEMPT(full) Tainted: [L]=SOFTLOCKUP Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 Call Trace: __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x100/0x190 lib/dump_stack.c:120 print_circular_bug.cold+0x178/0x1be kernel/locking/lockdep.c:2087 check_noncircular+0x146/0x160 kernel/locking/lockdep.c:2219 check_prev_add+0xeb/0xe60 kernel/locking/lockdep.c:3209 check_prevs_add kernel/locking/lockdep.c:3328 [inline] validate_chain kernel/locking/lockdep.c:3952 [inline] __lock_acquire+0x1528/0x1f40 kernel/locking/lockdep.c:5288 lock_acquire kernel/locking/lockdep.c:5942 [inline] lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5899 __mutex_lock_common kernel/locking/mutex.c:646 [inline] __mutex_lock+0x19f/0x1c10 kernel/locking/mutex.c:821 process_measurement+0x5ab/0x2360 security/integrity/ima/ima_main.c:319 ima_file_check+0xbf/0x110 security/integrity/ima/ima_main.c:686 security_file_post_open+0xc4/0x210 security/security.c:2776 do_open fs/namei.c:4853 [inline] path_openat+0x5d0/0x23f0 fs/namei.c:5016 do_file_open+0x20e/0x430 fs/namei.c:5045 do_sys_openat2+0x163/0x1d0 fs/open.c:1443 do_sys_open fs/open.c:1449 [inline] __do_sys_openat fs/open.c:1465 [inline] __se_sys_openat fs/open.c:1460 [inline] __x64_sys_openat+0x12d/0x210 fs/open.c:1460 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline] do_syscall_64+0x123/0x790 arch/x86/entry/syscall_64.c:84 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f52ce39fb19 Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 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 e8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f52cf323028 EFLAGS: 00000246 ORIG_RAX: 0000000000000101 RAX: ffffffffffffffda RBX: 00007f52ce625fa0 RCX: 00007f52ce39fb19 RDX: 000000000014b302 RSI: 0000200000000180 RDI: ffffffffffffff9c RBP: 00007f52ce437b70 R08: 0000000000000000 R09: 0000000000000000 R10: 000000000000008c R11: 0000000000000246 R12: 0000000000000000 R13: 00007f52ce626038 R14: 00007f52ce625fa0 R15: 00007ffee4e40cc8