syzbot


possible deadlock in lock_mm_and_find_vma (3)

Status: upstream: reported on 2024/12/04 07:31
Subsystems: ntfs3
[Documentation on labels]
Reported-by: syzbot+936adc4458c5f973d899@syzkaller.appspotmail.com
First crash: 263d, last: 31d
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [ntfs3?] possible deadlock in lock_mm_and_find_vma (3) 0 (1) 2024/12/04 07:31
Similar bugs (2)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in lock_mm_and_find_vma (2) mm 4 C 6626 282d 354d 28/29 fixed on 2024/11/14 10:09
upstream possible deadlock in lock_mm_and_find_vma exfat 4 C error 2 749d 768d 23/29 fixed on 2023/10/12 12:48

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.16.0-rc6-syzkaller-00279-gbf61759db409 #0 Not tainted
------------------------------------------------------
syz.1.5054/19923 is trying to acquire lock:
ffff8880333bc7e0 (&mm->mmap_lock){++++}-{4:4}, at: mmap_read_lock_killable include/linux/mmap_lock.h:421 [inline]
ffff8880333bc7e0 (&mm->mmap_lock){++++}-{4:4}, at: get_mmap_lock_carefully mm/mmap_lock.c:197 [inline]
ffff8880333bc7e0 (&mm->mmap_lock){++++}-{4:4}, at: lock_mm_and_find_vma+0x3e7/0x6e0 mm/mmap_lock.c:248

but task is already holding lock:
ffff8880478bbe58 (&sb->s_type->i_mutex_key#34){+.+.}-{4:4}, at: inode_trylock include/linux/fs.h:899 [inline]
ffff8880478bbe58 (&sb->s_type->i_mutex_key#34){+.+.}-{4:4}, at: ntfs_file_write_iter+0xdf/0x2120 fs/ntfs3/file.c:1160

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&sb->s_type->i_mutex_key#34){+.+.}-{4:4}:
       down_write+0x92/0x200 kernel/locking/rwsem.c:1577
       inode_lock include/linux/fs.h:869 [inline]
       ntfs_file_mmap+0x60c/0x780 fs/ntfs3/file.c:313
       call_mmap include/linux/fs.h:2286 [inline]
       mmap_file mm/internal.h:167 [inline]
       __mmap_new_file_vma mm/vma.c:2405 [inline]
       __mmap_new_vma mm/vma.c:2467 [inline]
       __mmap_region+0x128e/0x25e0 mm/vma.c:2622
       mmap_region+0x32b/0x3f0 mm/vma.c:2692
       do_mmap+0xa3e/0x1210 mm/mmap.c:561
       vm_mmap_pgoff+0x281/0x450 mm/util.c:579
       ksys_mmap_pgoff+0x32c/0x5c0 mm/mmap.c:607
       __do_sys_mmap arch/x86/kernel/sys_x86_64.c:89 [inline]
       __se_sys_mmap arch/x86/kernel/sys_x86_64.c:82 [inline]
       __x64_sys_mmap+0x125/0x190 arch/x86/kernel/sys_x86_64.c:82
       do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
       do_syscall_64+0xcd/0x4c0 arch/x86/entry/syscall_64.c:94
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #0 (&mm->mmap_lock){++++}-{4:4}:
       check_prev_add kernel/locking/lockdep.c:3168 [inline]
       check_prevs_add kernel/locking/lockdep.c:3287 [inline]
       validate_chain kernel/locking/lockdep.c:3911 [inline]
       __lock_acquire+0x126f/0x1c90 kernel/locking/lockdep.c:5240
       lock_acquire kernel/locking/lockdep.c:5871 [inline]
       lock_acquire+0x179/0x350 kernel/locking/lockdep.c:5828
       down_read_killable+0x9e/0x4b0 kernel/locking/rwsem.c:1547
       mmap_read_lock_killable include/linux/mmap_lock.h:421 [inline]
       get_mmap_lock_carefully mm/mmap_lock.c:197 [inline]
       lock_mm_and_find_vma+0x3e7/0x6e0 mm/mmap_lock.c:248
       do_user_addr_fault+0x2ac/0x1370 arch/x86/mm/fault.c:1359
       handle_page_fault arch/x86/mm/fault.c:1476 [inline]
       exc_page_fault+0x5c/0xb0 arch/x86/mm/fault.c:1532
       asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:623
       fault_in_readable+0x135/0x1d0 mm/gup.c:2227
       fault_in_iov_iter_readable+0x101/0x2c0 lib/iov_iter.c:94
       ntfs_compress_write fs/ntfs3/file.c:1026 [inline]
       ntfs_file_write_iter+0x1210/0x2120 fs/ntfs3/file.c:1196
       new_sync_write fs/read_write.c:593 [inline]
       vfs_write+0x6c7/0x1150 fs/read_write.c:686
       ksys_pwrite64 fs/read_write.c:793 [inline]
       __do_sys_pwrite64 fs/read_write.c:801 [inline]
       __se_sys_pwrite64 fs/read_write.c:798 [inline]
       __x64_sys_pwrite64+0x1eb/0x250 fs/read_write.c:798
       do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
       do_syscall_64+0xcd/0x4c0 arch/x86/entry/syscall_64.c:94
       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#34);
                               lock(&mm->mmap_lock);
                               lock(&sb->s_type->i_mutex_key#34);
  rlock(&mm->mmap_lock);

 *** DEADLOCK ***

2 locks held by syz.1.5054/19923:
 #0: ffff8880395a8428 (sb_writers#12){.+.+}-{0:0}, at: ksys_pwrite64 fs/read_write.c:793 [inline]
 #0: ffff8880395a8428 (sb_writers#12){.+.+}-{0:0}, at: __do_sys_pwrite64 fs/read_write.c:801 [inline]
 #0: ffff8880395a8428 (sb_writers#12){.+.+}-{0:0}, at: __se_sys_pwrite64 fs/read_write.c:798 [inline]
 #0: ffff8880395a8428 (sb_writers#12){.+.+}-{0:0}, at: __x64_sys_pwrite64+0x1eb/0x250 fs/read_write.c:798
 #1: ffff8880478bbe58 (&sb->s_type->i_mutex_key#34){+.+.}-{4:4}, at: inode_trylock include/linux/fs.h:899 [inline]
 #1: ffff8880478bbe58 (&sb->s_type->i_mutex_key#34){+.+.}-{4:4}, at: ntfs_file_write_iter+0xdf/0x2120 fs/ntfs3/file.c:1160

stack backtrace:
CPU: 1 UID: 0 PID: 19923 Comm: syz.1.5054 Not tainted 6.16.0-rc6-syzkaller-00279-gbf61759db409 #0 PREEMPT(full) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/2025
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120
 print_circular_bug+0x275/0x350 kernel/locking/lockdep.c:2046
 check_noncircular+0x14c/0x170 kernel/locking/lockdep.c:2178
 check_prev_add kernel/locking/lockdep.c:3168 [inline]
 check_prevs_add kernel/locking/lockdep.c:3287 [inline]
 validate_chain kernel/locking/lockdep.c:3911 [inline]
 __lock_acquire+0x126f/0x1c90 kernel/locking/lockdep.c:5240
 lock_acquire kernel/locking/lockdep.c:5871 [inline]
 lock_acquire+0x179/0x350 kernel/locking/lockdep.c:5828
 down_read_killable+0x9e/0x4b0 kernel/locking/rwsem.c:1547
 mmap_read_lock_killable include/linux/mmap_lock.h:421 [inline]
 get_mmap_lock_carefully mm/mmap_lock.c:197 [inline]
 lock_mm_and_find_vma+0x3e7/0x6e0 mm/mmap_lock.c:248
 do_user_addr_fault+0x2ac/0x1370 arch/x86/mm/fault.c:1359
 handle_page_fault arch/x86/mm/fault.c:1476 [inline]
 exc_page_fault+0x5c/0xb0 arch/x86/mm/fault.c:1532
 asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:623
RIP: 0010:fault_in_readable+0x135/0x1d0 mm/gup.c:2227
Code: 11 27 b9 ff 48 85 db 0f 84 9c 00 00 00 e8 93 2b b9 ff 48 89 de 48 89 ef e8 38 26 b9 ff 48 39 eb 73 1d e8 7e 2b b9 ff 45 89 f7 <8a> 03 31 ff 44 89 fe 88 44 24 28 e8 ab 26 b9 ff 45 85 ff 74 a8 e8
RSP: 0018:ffffc90003e1fac8 EFLAGS: 00050287
RAX: 0000000000038863 RBX: 0000200000009000 RCX: ffffc9000e8f9000
RDX: 0000000000080000 RSI: ffffffff8202bc82 RDI: 0000000000000006
RBP: 000020000000ff2f R08: 0000000000000006 R09: 000020000000ff2f
R10: 0000200000009000 R11: 0000000000000001 R12: 0000200000000274
R13: 000000000000fcbb R14: 0000000000000000 R15: 0000000000000000
 fault_in_iov_iter_readable+0x101/0x2c0 lib/iov_iter.c:94
 ntfs_compress_write fs/ntfs3/file.c:1026 [inline]
 ntfs_file_write_iter+0x1210/0x2120 fs/ntfs3/file.c:1196
 new_sync_write fs/read_write.c:593 [inline]
 vfs_write+0x6c7/0x1150 fs/read_write.c:686
 ksys_pwrite64 fs/read_write.c:793 [inline]
 __do_sys_pwrite64 fs/read_write.c:801 [inline]
 __se_sys_pwrite64 fs/read_write.c:798 [inline]
 __x64_sys_pwrite64+0x1eb/0x250 fs/read_write.c:798
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0xcd/0x4c0 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f996158e9a9
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:00007f99623f6038 EFLAGS: 00000246 ORIG_RAX: 0000000000000012
RAX: ffffffffffffffda RBX: 00007f99617b5fa0 RCX: 00007f996158e9a9
RDX: 000000000000fdef RSI: 0000200000000140 RDI: 0000000000000005
RBP: 00007f9961610d69 R08: 0000000000000000 R09: 0000000000000000
R10: 000000000000fecc R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f99617b5fa0 R15: 00007ffcf39cee18
 </TASK>
----------------
Code disassembly (best guess):
   0:	11 27                	adc    %esp,(%rdi)
   2:	b9 ff 48 85 db       	mov    $0xdb8548ff,%ecx
   7:	0f 84 9c 00 00 00    	je     0xa9
   d:	e8 93 2b b9 ff       	call   0xffb92ba5
  12:	48 89 de             	mov    %rbx,%rsi
  15:	48 89 ef             	mov    %rbp,%rdi
  18:	e8 38 26 b9 ff       	call   0xffb92655
  1d:	48 39 eb             	cmp    %rbp,%rbx
  20:	73 1d                	jae    0x3f
  22:	e8 7e 2b b9 ff       	call   0xffb92ba5
  27:	45 89 f7             	mov    %r14d,%r15d
* 2a:	8a 03                	mov    (%rbx),%al <-- trapping instruction
  2c:	31 ff                	xor    %edi,%edi
  2e:	44 89 fe             	mov    %r15d,%esi
  31:	88 44 24 28          	mov    %al,0x28(%rsp)
  35:	e8 ab 26 b9 ff       	call   0xffb926e5
  3a:	45 85 ff             	test   %r15d,%r15d
  3d:	74 a8                	je     0xffffffe7
  3f:	e8                   	.byte 0xe8

Crashes (7):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/07/19 23:20 upstream bf61759db409 7117feec .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-badwrites-root possible deadlock in lock_mm_and_find_vma
2025/06/20 08:01 upstream 41687a5c6f8b ed3e87f7 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-badwrites-root possible deadlock in lock_mm_and_find_vma
2025/05/08 17:36 upstream d76bb1ebb558 dbf35fa1 .config console log report info [disk image] [vmlinux] [kernel image] ci-qemu-gce-upstream-auto possible deadlock in lock_mm_and_find_vma
2025/04/16 03:25 upstream 1a1d569a75f3 23b969b7 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-badwrites-root possible deadlock in lock_mm_and_find_vma
2025/04/14 01:03 upstream 8ffd015db85f 0bd6db41 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-badwrites-root possible deadlock in lock_mm_and_find_vma
2025/01/07 06:36 upstream fbfd64d25c7a f3558dbf .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-badwrites-root possible deadlock in lock_mm_and_find_vma
2024/11/30 07:29 upstream 509f806f7f70 68914665 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-badwrites-root possible deadlock in lock_mm_and_find_vma
* Struck through repros no longer work on HEAD.