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: 227d, last: 25d
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 247d 319d 28/29 fixed on 2024/11/14 10:09
upstream possible deadlock in lock_mm_and_find_vma exfat 4 C error 2 714d 733d 23/29 fixed on 2023/10/12 12:48

Sample crash report:
loop2: detected capacity change from 0 to 4096
======================================================
WARNING: possible circular locking dependency detected
6.16.0-rc2-syzkaller-00162-g41687a5c6f8b #0 Not tainted
------------------------------------------------------
syz.2.5760/21909 is trying to acquire lock:
ffff888033a16d60 (&mm->mmap_lock){++++}-{4:4}, at: mmap_read_lock_killable include/linux/mmap_lock.h:421 [inline]
ffff888033a16d60 (&mm->mmap_lock){++++}-{4:4}, at: get_mmap_lock_carefully mm/mmap_lock.c:197 [inline]
ffff888033a16d60 (&mm->mmap_lock){++++}-{4:4}, at: lock_mm_and_find_vma+0x3e7/0x6e0 mm/mmap_lock.c:248

but task is already holding lock:
ffff88804bfe9248 (&sb->s_type->i_mutex_key#28){+.+.}-{4:4}, at: inode_trylock include/linux/fs.h:899 [inline]
ffff88804bfe9248 (&sb->s_type->i_mutex_key#28){+.+.}-{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#28){+.+.}-{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
       generic_perform_write+0x7b4/0x930 mm/filemap.c:4161
       __generic_file_write_iter+0x1f7/0x240 mm/filemap.c:4229
       ntfs_file_write_iter+0xed3/0x2120 fs/ntfs3/file.c:1197
       do_iter_readv_writev+0x657/0x950 fs/read_write.c:827
       vfs_writev+0x35f/0xde0 fs/read_write.c:1057
       do_pwritev+0x1a6/0x270 fs/read_write.c:1153
       __do_sys_pwritev2 fs/read_write.c:1211 [inline]
       __se_sys_pwritev2 fs/read_write.c:1202 [inline]
       __x64_sys_pwritev2+0xef/0x160 fs/read_write.c:1202
       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#28);
                               lock(&mm->mmap_lock);
                               lock(&sb->s_type->i_mutex_key#28);
  rlock(&mm->mmap_lock);

 *** DEADLOCK ***

2 locks held by syz.2.5760/21909:
 #0: ffff8880364a6428 (sb_writers#21){.+.+}-{0:0}, at: do_pwritev+0x1a6/0x270 fs/read_write.c:1153
 #1: ffff88804bfe9248 (&sb->s_type->i_mutex_key#28){+.+.}-{4:4}, at: inode_trylock include/linux/fs.h:899 [inline]
 #1: ffff88804bfe9248 (&sb->s_type->i_mutex_key#28){+.+.}-{4:4}, at: ntfs_file_write_iter+0xdf/0x2120 fs/ntfs3/file.c:1160

stack backtrace:
CPU: 1 UID: 0 PID: 21909 Comm: syz.2.5760 Not tainted 6.16.0-rc2-syzkaller-00162-g41687a5c6f8b #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: e1 a5 b7 ff 48 85 db 0f 84 9c 00 00 00 e8 63 aa b7 ff 48 89 de 48 89 ef e8 08 a5 b7 ff 48 39 eb 73 1d e8 4e aa b7 ff 45 89 f7 <8a> 03 31 ff 44 89 fe 88 44 24 28 e8 7b a5 b7 ff 45 85 ff 74 a8 e8
RSP: 0018:ffffc9000ec8f790 EFLAGS: 00050283
RAX: 000000000000c6a4 RBX: 000020000000c000 RCX: ffffc9000c7cb000
RDX: 0000000000080000 RSI: ffffffff82047132 RDI: 0000000000000006
RBP: 000020000000c205 R08: 0000000000000006 R09: 000020000000c000
R10: 000020000000c205 R11: 0000000000000000 R12: 000020000000c000
R13: 0000000000000205 R14: 0000000000000000 R15: 0000000000000000
 fault_in_iov_iter_readable+0x101/0x2c0 lib/iov_iter.c:94
 generic_perform_write+0x7b4/0x930 mm/filemap.c:4161
 __generic_file_write_iter+0x1f7/0x240 mm/filemap.c:4229
 ntfs_file_write_iter+0xed3/0x2120 fs/ntfs3/file.c:1197
 do_iter_readv_writev+0x657/0x950 fs/read_write.c:827
 vfs_writev+0x35f/0xde0 fs/read_write.c:1057
 do_pwritev+0x1a6/0x270 fs/read_write.c:1153
 __do_sys_pwritev2 fs/read_write.c:1211 [inline]
 __se_sys_pwritev2 fs/read_write.c:1202 [inline]
 __x64_sys_pwritev2+0xef/0x160 fs/read_write.c:1202
 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:0x7fda19f8e929
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:00007fda1ae4e038 EFLAGS: 00000246 ORIG_RAX: 0000000000000148
RAX: ffffffffffffffda RBX: 00007fda1a1b5fa0 RCX: 00007fda19f8e929
RDX: 0000000000000001 RSI: 00002000000001c0 RDI: 0000000000000004
RBP: 00007fda1a010b39 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000e7b R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007fda1a1b5fa0 R15: 00007ffeaa9ebf48
 </TASK>
----------------
Code disassembly (best guess):
   0:	e1 a5                	loope  0xffffffa7
   2:	b7 ff                	mov    $0xff,%bh
   4:	48 85 db             	test   %rbx,%rbx
   7:	0f 84 9c 00 00 00    	je     0xa9
   d:	e8 63 aa b7 ff       	call   0xffb7aa75
  12:	48 89 de             	mov    %rbx,%rsi
  15:	48 89 ef             	mov    %rbp,%rdi
  18:	e8 08 a5 b7 ff       	call   0xffb7a525
  1d:	48 39 eb             	cmp    %rbp,%rbx
  20:	73 1d                	jae    0x3f
  22:	e8 4e aa b7 ff       	call   0xffb7aa75
  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 7b a5 b7 ff       	call   0xffb7a5b5
  3a:	45 85 ff             	test   %r15d,%r15d
  3d:	74 a8                	je     0xffffffe7
  3f:	e8                   	.byte 0xe8

Crashes (6):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
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.