====================================================== WARNING: possible circular locking dependency detected 6.12.0-rc4-syzkaller-00047-gc2ee9f594da8 #0 Not tainted ------------------------------------------------------ syz.3.1971/9791 is trying to acquire lock: ffff88802e2eba98 (&mm->mmap_lock){++++}-{3:3}, at: mmap_read_lock_killable include/linux/mmap_lock.h:153 [inline] ffff88802e2eba98 (&mm->mmap_lock){++++}-{3:3}, at: get_mmap_lock_carefully mm/memory.c:6112 [inline] ffff88802e2eba98 (&mm->mmap_lock){++++}-{3:3}, at: lock_mm_and_find_vma+0x3a9/0x6a0 mm/memory.c:6163 but task is already holding lock: ffff888055545e38 (&sb->s_type->i_mutex_key#12){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:815 [inline] ffff888055545e38 (&sb->s_type->i_mutex_key#12){+.+.}-{3:3}, at: shmem_file_write_iter+0x86/0x140 mm/shmem.c:3206 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #1 (&sb->s_type->i_mutex_key#12){+.+.}-{3:3}: down_write+0x93/0x200 kernel/locking/rwsem.c:1577 inode_lock include/linux/fs.h:815 [inline] process_measurement+0x39c/0x2370 security/integrity/ima/ima_main.c:250 ima_file_mmap+0x146/0x1d0 security/integrity/ima/ima_main.c:455 security_mmap_file+0x8bd/0x990 security/security.c:2979 __do_sys_remap_file_pages+0x526/0x900 mm/mmap.c:1702 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #0 (&mm->mmap_lock){++++}-{3:3}: check_prev_add kernel/locking/lockdep.c:3161 [inline] check_prevs_add kernel/locking/lockdep.c:3280 [inline] validate_chain kernel/locking/lockdep.c:3904 [inline] __lock_acquire+0x250b/0x3ce0 kernel/locking/lockdep.c:5202 lock_acquire.part.0+0x11b/0x380 kernel/locking/lockdep.c:5825 down_read_killable+0x9d/0x380 kernel/locking/rwsem.c:1547 mmap_read_lock_killable include/linux/mmap_lock.h:153 [inline] get_mmap_lock_carefully mm/memory.c:6112 [inline] lock_mm_and_find_vma+0x3a9/0x6a0 mm/memory.c:6163 do_user_addr_fault+0x2b5/0x13f0 arch/x86/mm/fault.c:1361 handle_page_fault arch/x86/mm/fault.c:1481 [inline] exc_page_fault+0x5c/0xc0 arch/x86/mm/fault.c:1539 asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:623 fault_in_readable+0x1a6/0x230 mm/gup.c:2228 fault_in_iov_iter_readable+0x101/0x2c0 lib/iov_iter.c:94 generic_perform_write+0x21b/0x920 mm/filemap.c:4044 shmem_file_write_iter+0x10e/0x140 mm/shmem.c:3216 new_sync_write fs/read_write.c:590 [inline] vfs_write+0x6b5/0x1140 fs/read_write.c:683 ksys_write+0x12f/0x260 fs/read_write.c:736 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f other info that might help us debug this: Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&sb->s_type->i_mutex_key#12); lock(&mm->mmap_lock); lock(&sb->s_type->i_mutex_key#12); rlock(&mm->mmap_lock); *** DEADLOCK *** 3 locks held by syz.3.1971/9791: #0: ffff88802deb1b38 (&f->f_pos_lock){+.+.}-{3:3}, at: fdget_pos+0x24c/0x360 fs/file.c:1160 #1: ffff888024da6420 (sb_writers#6){.+.+}-{0:0}, at: ksys_write+0x12f/0x260 fs/read_write.c:736 #2: ffff888055545e38 (&sb->s_type->i_mutex_key#12){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:815 [inline] #2: ffff888055545e38 (&sb->s_type->i_mutex_key#12){+.+.}-{3:3}, at: shmem_file_write_iter+0x86/0x140 mm/shmem.c:3206 stack backtrace: CPU: 3 UID: 0 PID: 9791 Comm: syz.3.1971 Not tainted 6.12.0-rc4-syzkaller-00047-gc2ee9f594da8 #0 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014 Call Trace: __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120 print_circular_bug+0x41c/0x610 kernel/locking/lockdep.c:2074 check_noncircular+0x31a/0x400 kernel/locking/lockdep.c:2206 check_prev_add kernel/locking/lockdep.c:3161 [inline] check_prevs_add kernel/locking/lockdep.c:3280 [inline] validate_chain kernel/locking/lockdep.c:3904 [inline] __lock_acquire+0x250b/0x3ce0 kernel/locking/lockdep.c:5202 lock_acquire.part.0+0x11b/0x380 kernel/locking/lockdep.c:5825 down_read_killable+0x9d/0x380 kernel/locking/rwsem.c:1547 mmap_read_lock_killable include/linux/mmap_lock.h:153 [inline] get_mmap_lock_carefully mm/memory.c:6112 [inline] lock_mm_and_find_vma+0x3a9/0x6a0 mm/memory.c:6163 do_user_addr_fault+0x2b5/0x13f0 arch/x86/mm/fault.c:1361 handle_page_fault arch/x86/mm/fault.c:1481 [inline] exc_page_fault+0x5c/0xc0 arch/x86/mm/fault.c:1539 asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:623 RIP: 0010:fault_in_readable+0x1a6/0x230 mm/gup.c:2228 Code: c7 04 02 00 00 00 00 48 83 c4 48 4c 89 e0 5b 5d 41 5c 41 5d 41 5e 41 5f c3 cc cc cc cc 45 31 e4 eb ca e8 0d 1c ba ff 45 31 f6 <41> 8a 45 00 31 ff 44 89 f6 88 44 24 28 e8 38 1e ba ff 45 85 f6 75 RSP: 0018:ffffc9000288fb18 EFLAGS: 00050246 RAX: 0000000000040000 RBX: 0000000000000000 RCX: ffffc90022f1e000 RDX: 0000000000040000 RSI: ffffffff81d362f3 RDI: 0000000000000007 RBP: 0000000020701400 R08: 0000000000000007 R09: 0000000000000000 R10: 0000000000000400 R11: 0000000000000000 R12: 0000000000077000 R13: 000000002068a400 R14: 0000000000000000 R15: 1ffff92000511f64 fault_in_iov_iter_readable+0x101/0x2c0 lib/iov_iter.c:94 generic_perform_write+0x21b/0x920 mm/filemap.c:4044 shmem_file_write_iter+0x10e/0x140 mm/shmem.c:3216 new_sync_write fs/read_write.c:590 [inline] vfs_write+0x6b5/0x1140 fs/read_write.c:683 ksys_write+0x12f/0x260 fs/read_write.c:736 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7fddbbd7dff9 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 a8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007fddbcc1f038 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 00007fddbbf35f80 RCX: 00007fddbbd7dff9 RDX: 000000000208e24b RSI: 0000000020001400 RDI: 0000000000000004 RBP: 00007fddbbdf0296 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007fddbbf35f80 R15: 00007ffdcee79cf8 ---------------- Code disassembly (best guess): 0: c7 04 02 00 00 00 00 movl $0x0,(%rdx,%rax,1) 7: 48 83 c4 48 add $0x48,%rsp b: 4c 89 e0 mov %r12,%rax e: 5b pop %rbx f: 5d pop %rbp 10: 41 5c pop %r12 12: 41 5d pop %r13 14: 41 5e pop %r14 16: 41 5f pop %r15 18: c3 ret 19: cc int3 1a: cc int3 1b: cc int3 1c: cc int3 1d: 45 31 e4 xor %r12d,%r12d 20: eb ca jmp 0xffffffec 22: e8 0d 1c ba ff call 0xffba1c34 27: 45 31 f6 xor %r14d,%r14d * 2a: 41 8a 45 00 mov 0x0(%r13),%al <-- trapping instruction 2e: 31 ff xor %edi,%edi 30: 44 89 f6 mov %r14d,%esi 33: 88 44 24 28 mov %al,0x28(%rsp) 37: e8 38 1e ba ff call 0xffba1e74 3c: 45 85 f6 test %r14d,%r14d 3f: 75 .byte 0x75