syzbot


possible deadlock in upgrade_mmap_lock_carefully (3)

Status: upstream: reported C repro on 2025/11/04 07:34
Bug presence: origin:lts-only
[Documentation on labels]
Reported-by: syzbot+4399e870ea0b97221185@syzkaller.appspotmail.com
First crash: 68d, last: 21d
Bug presence (2)
Date Name Commit Repro Result
2025/12/05 linux-6.1.y (ToT) f6e38ae624cf C [report] possible deadlock in upgrade_mmap_lock_carefully
2025/12/05 upstream (ToT) b0206c4eb637 C Didn't crash
Similar bugs (4)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in upgrade_mmap_lock_carefully (2) ntfs3 mm 4 C error 6 199d 217d 29/29 fixed on 2025/09/04 16:57
linux-6.1 possible deadlock in upgrade_mmap_lock_carefully (2) 4 1 187d 187d 0/3 auto-obsoleted due to no activity on 2025/10/16 05:57
upstream possible deadlock in upgrade_mmap_lock_carefully mm 4 C done 30 439d 470d 0/29 closed as dup on 2024/10/03 02:52
linux-6.1 possible deadlock in upgrade_mmap_lock_carefully 4 13 297d 390d 0/3 auto-obsoleted due to no activity on 2025/06/28 07:47

Sample crash report:
mmap: syz.0.17 (4433) uses deprecated remap_file_pages() syscall. See Documentation/mm/remap_file_pages.rst.
======================================================
WARNING: possible circular locking dependency detected
syzkaller #0 Not tainted
------------------------------------------------------
syz.0.17/4433 is trying to acquire lock:
ffff88807cfc9f58 (&mm->mmap_lock){++++}-{3:3}, at: mmap_write_lock_killable include/linux/mmap_lock.h:87 [inline]
ffff88807cfc9f58 (&mm->mmap_lock){++++}-{3:3}, at: upgrade_mmap_lock_carefully+0xbb/0x140 mm/memory.c:5357

but task is already holding lock:
ffff888073e5c1b0 (&sb->s_type->i_mutex_key#12){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:758 [inline]
ffff888073e5c1b0 (&sb->s_type->i_mutex_key#12){+.+.}-{3:3}, at: generic_file_write_iter+0x7f/0x2e0 mm/filemap.c:4003

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+0x36/0x60 kernel/locking/rwsem.c:1573
       inode_lock include/linux/fs.h:758 [inline]
       process_measurement+0x33c/0x1a10 security/integrity/ima/ima_main.c:242
       ima_file_mmap+0x104/0x150 security/integrity/ima/ima_main.c:429
       __do_sys_remap_file_pages mm/mmap.c:3036 [inline]
       __se_sys_remap_file_pages+0x53e/0x770 mm/mmap.c:2968
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:81
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

-> #0 (&mm->mmap_lock){++++}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3090 [inline]
       check_prevs_add kernel/locking/lockdep.c:3209 [inline]
       validate_chain kernel/locking/lockdep.c:3825 [inline]
       __lock_acquire+0x2cf8/0x7c50 kernel/locking/lockdep.c:5049
       lock_acquire+0x1b4/0x490 kernel/locking/lockdep.c:5662
       down_write_killable+0x45/0x90 kernel/locking/rwsem.c:1584
       mmap_write_lock_killable include/linux/mmap_lock.h:87 [inline]
       upgrade_mmap_lock_carefully+0xbb/0x140 mm/memory.c:5357
       lock_mm_and_find_vma+0x117/0x2f0 mm/memory.c:5410
       do_user_addr_fault+0x2db/0xb10 arch/x86/mm/fault.c:1312
       handle_page_fault arch/x86/mm/fault.c:1431 [inline]
       exc_page_fault+0x60/0x100 arch/x86/mm/fault.c:1487
       asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:608
       fault_in_readable+0x13e/0x1f0 mm/gup.c:1914
       fault_in_iov_iter_readable+0xbb/0x2e0 lib/iov_iter.c:356
       generic_perform_write+0x1d2/0x560 mm/filemap.c:3836
       __generic_file_write_iter+0x172/0x430 mm/filemap.c:3974
       generic_file_write_iter+0xab/0x2e0 mm/filemap.c:4006
       call_write_iter include/linux/fs.h:2265 [inline]
       new_sync_write fs/read_write.c:491 [inline]
       vfs_write+0x44c/0x960 fs/read_write.c:584
       ksys_write+0x143/0x240 fs/read_write.c:637
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:81
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

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);
  lock(&mm->mmap_lock);

 *** DEADLOCK ***

2 locks held by syz.0.17/4433:
 #0: ffff88807bf60460 (sb_writers#5){.+.+}-{0:0}, at: vfs_write+0x256/0x960 fs/read_write.c:580
 #1: ffff888073e5c1b0 (&sb->s_type->i_mutex_key#12){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:758 [inline]
 #1: ffff888073e5c1b0 (&sb->s_type->i_mutex_key#12){+.+.}-{3:3}, at: generic_file_write_iter+0x7f/0x2e0 mm/filemap.c:4003

stack backtrace:
CPU: 0 PID: 4433 Comm: syz.0.17 Not tainted syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/25/2025
Call Trace:
 <TASK>
 dump_stack_lvl+0x168/0x22e lib/dump_stack.c:106
 check_noncircular+0x274/0x310 kernel/locking/lockdep.c:2170
 check_prev_add kernel/locking/lockdep.c:3090 [inline]
 check_prevs_add kernel/locking/lockdep.c:3209 [inline]
 validate_chain kernel/locking/lockdep.c:3825 [inline]
 __lock_acquire+0x2cf8/0x7c50 kernel/locking/lockdep.c:5049
 lock_acquire+0x1b4/0x490 kernel/locking/lockdep.c:5662
 down_write_killable+0x45/0x90 kernel/locking/rwsem.c:1584
 mmap_write_lock_killable include/linux/mmap_lock.h:87 [inline]
 upgrade_mmap_lock_carefully+0xbb/0x140 mm/memory.c:5357
 lock_mm_and_find_vma+0x117/0x2f0 mm/memory.c:5410
 do_user_addr_fault+0x2db/0xb10 arch/x86/mm/fault.c:1312
 handle_page_fault arch/x86/mm/fault.c:1431 [inline]
 exc_page_fault+0x60/0x100 arch/x86/mm/fault.c:1487
 asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:608
RIP: 0010:fault_in_readable+0x13e/0x1f0 mm/gup.c:1915
Code: 48 e7 c4 ff 4d 89 f4 49 81 cc ff 0f 00 00 4d 89 f7 49 01 dc 49 81 e4 00 f0 ff ff 4d 39 e6 77 44 e8 27 e7 c4 ff 4d 39 e7 74 47 <41> 8a 07 88 44 24 07 49 81 c7 00 10 00 00 4d 39 e7 74 07 e8 0a e7
RSP: 0018:ffffc900035a7a90 EFLAGS: 00050287
RAX: ffffffff81bbef39 RBX: 0000000000001000 RCX: ffff88807efd1dc0
RDX: 0000000000000000 RSI: 0000000000000100 RDI: 0000000000000000
RBP: 0000000000000000 R08: ffff88807efd1dc0 R09: 0000000000000002
R10: 0000000000000006 R11: 0000000000000000 R12: 0000200000002000
R13: dffffc0000000000 R14: 0000200000000100 R15: 0000200000001000
 fault_in_iov_iter_readable+0xbb/0x2e0 lib/iov_iter.c:356
 generic_perform_write+0x1d2/0x560 mm/filemap.c:3836
 __generic_file_write_iter+0x172/0x430 mm/filemap.c:3974
 generic_file_write_iter+0xab/0x2e0 mm/filemap.c:4006
 call_write_iter include/linux/fs.h:2265 [inline]
 new_sync_write fs/read_write.c:491 [inline]
 vfs_write+0x44c/0x960 fs/read_write.c:584
 ksys_write+0x143/0x240 fs/read_write.c:637
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2
RIP: 0033:0x7fec11f8f749
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:00007fffd97579f8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007fec121e5fa0 RCX: 00007fec11f8f749
RDX: 0000000000032600 RSI: 0000200000000100 RDI: 0000000000000003
RBP: 00007fec12013f91 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007fec121e5fa0 R14: 00007fec121e5fa0 R15: 0000000000000003
 </TASK>
----------------
Code disassembly (best guess):
   0:	48 e7 c4             	rex.W out %eax,$0xc4
   3:	ff 4d 89             	decl   -0x77(%rbp)
   6:	f4                   	hlt
   7:	49 81 cc ff 0f 00 00 	or     $0xfff,%r12
   e:	4d 89 f7             	mov    %r14,%r15
  11:	49 01 dc             	add    %rbx,%r12
  14:	49 81 e4 00 f0 ff ff 	and    $0xfffffffffffff000,%r12
  1b:	4d 39 e6             	cmp    %r12,%r14
  1e:	77 44                	ja     0x64
  20:	e8 27 e7 c4 ff       	call   0xffc4e74c
  25:	4d 39 e7             	cmp    %r12,%r15
  28:	74 47                	je     0x71
* 2a:	41 8a 07             	mov    (%r15),%al <-- trapping instruction
  2d:	88 44 24 07          	mov    %al,0x7(%rsp)
  31:	49 81 c7 00 10 00 00 	add    $0x1000,%r15
  38:	4d 39 e7             	cmp    %r12,%r15
  3b:	74 07                	je     0x44
  3d:	e8                   	.byte 0xe8
  3e:	0a e7                	or     %bh,%ah

Crashes (5):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/12/05 00:52 linux-6.1.y f6e38ae624cf d6526ea3 .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in upgrade_mmap_lock_carefully
2025/12/21 18:13 linux-6.1.y 50cbba13faa2 d6526ea3 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in upgrade_mmap_lock_carefully
2025/12/17 16:38 linux-6.1.y 50cbba13faa2 d6526ea3 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in upgrade_mmap_lock_carefully
2025/12/04 22:26 linux-6.1.y f6e38ae624cf d6526ea3 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in upgrade_mmap_lock_carefully
2025/11/04 07:33 linux-6.1.y f6e38ae624cf 686bf657 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in upgrade_mmap_lock_carefully
* Struck through repros no longer work on HEAD.