syzbot


possible deadlock in ntfs_file_mmap_prepare

Status: upstream: reported C repro on 2025/06/24 18:51
Subsystems: ntfs3
[Documentation on labels]
Reported-by: syzbot+a5d1c9dfa91705cd2f6d@syzkaller.appspotmail.com
First crash: 3d04h, last: 2d03h
Cause bisection: failed (error log, bisect log)
  
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [ntfs3?] possible deadlock in ntfs_file_mmap_prepare 1 (2) 2025/06/25 00:37

Sample crash report:
loop0: detected capacity change from 0 to 4096
======================================================
WARNING: possible circular locking dependency detected
6.16.0-rc2-next-20250620-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor414/5843 is trying to acquire lock:
ffff8880739bcd08 (&sb->s_type->i_mutex_key#15){+.+.}-{4:4}, at: inode_lock include/linux/fs.h:869 [inline]
ffff8880739bcd08 (&sb->s_type->i_mutex_key#15){+.+.}-{4:4}, at: ntfs_file_mmap_prepare+0x599/0x770 fs/ntfs3/file.c:314

but task is already holding lock:
ffff888023ca6d60 (&mm->mmap_lock){++++}-{4:4}, at: mmap_write_lock_killable include/linux/mmap_lock.h:374 [inline]
ffff888023ca6d60 (&mm->mmap_lock){++++}-{4:4}, at: vm_mmap_pgoff+0x1bd/0x4c0 mm/util.c:577

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&mm->mmap_lock){++++}-{4:4}:
       lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5871
       gup_fast_fallback+0x22e/0x2270 mm/gup.c:3366
       iov_iter_extract_user_pages lib/iov_iter.c:1846 [inline]
       iov_iter_extract_pages+0x35a/0x5e0 lib/iov_iter.c:1909
       dio_refill_pages fs/direct-io.c:172 [inline]
       dio_get_page fs/direct-io.c:213 [inline]
       do_direct_IO fs/direct-io.c:915 [inline]
       __blockdev_direct_IO+0x1166/0x3490 fs/direct-io.c:1243
       blockdev_direct_IO include/linux/fs.h:3497 [inline]
       ntfs_direct_IO+0x20b/0x410 fs/ntfs3/inode.c:813
       generic_file_read_iter+0x319/0x510 mm/filemap.c:2881
       do_iter_readv_writev+0x56b/0x7f0 fs/read_write.c:-1
       vfs_readv+0x253/0x850 fs/read_write.c:1018
       do_preadv fs/read_write.c:1132 [inline]
       __do_sys_preadv2 fs/read_write.c:1191 [inline]
       __se_sys_preadv2+0x179/0x290 fs/read_write.c:1182
       do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
       do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #0 (&sb->s_type->i_mutex_key#15){+.+.}-{4:4}:
       check_prev_add kernel/locking/lockdep.c:3168 [inline]
       check_prevs_add kernel/locking/lockdep.c:3287 [inline]
       validate_chain+0xb9b/0x2140 kernel/locking/lockdep.c:3911
       __lock_acquire+0xab9/0xd20 kernel/locking/lockdep.c:5240
       lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5871
       down_write+0x96/0x1f0 kernel/locking/rwsem.c:1577
       inode_lock include/linux/fs.h:869 [inline]
       ntfs_file_mmap_prepare+0x599/0x770 fs/ntfs3/file.c:314
       vfs_mmap_prepare include/linux/fs.h:2294 [inline]
       call_mmap_prepare mm/vma.c:2585 [inline]
       __mmap_region mm/vma.c:2657 [inline]
       mmap_region+0xb4a/0x2080 mm/vma.c:2746
       do_mmap+0xc45/0x10d0 mm/mmap.c:561
       vm_mmap_pgoff+0x31b/0x4c0 mm/util.c:579
       ksys_mmap_pgoff+0x51f/0x760 mm/mmap.c:607
       do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
       do_syscall_64+0xfa/0x3b0 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(&mm->mmap_lock);
                               lock(&sb->s_type->i_mutex_key#15);
                               lock(&mm->mmap_lock);
  lock(&sb->s_type->i_mutex_key#15);

 *** DEADLOCK ***

1 lock held by syz-executor414/5843:
 #0: ffff888023ca6d60 (&mm->mmap_lock){++++}-{4:4}, at: mmap_write_lock_killable include/linux/mmap_lock.h:374 [inline]
 #0: ffff888023ca6d60 (&mm->mmap_lock){++++}-{4:4}, at: vm_mmap_pgoff+0x1bd/0x4c0 mm/util.c:577

stack backtrace:
CPU: 1 UID: 0 PID: 5843 Comm: syz-executor414 Not tainted 6.16.0-rc2-next-20250620-syzkaller #0 PREEMPT(full) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/2025
Call Trace:
 <TASK>
 dump_stack_lvl+0x189/0x250 lib/dump_stack.c:120
 print_circular_bug+0x2ee/0x310 kernel/locking/lockdep.c:2046
 check_noncircular+0x134/0x160 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+0xb9b/0x2140 kernel/locking/lockdep.c:3911
 __lock_acquire+0xab9/0xd20 kernel/locking/lockdep.c:5240
 lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5871
 down_write+0x96/0x1f0 kernel/locking/rwsem.c:1577
 inode_lock include/linux/fs.h:869 [inline]
 ntfs_file_mmap_prepare+0x599/0x770 fs/ntfs3/file.c:314
 vfs_mmap_prepare include/linux/fs.h:2294 [inline]
 call_mmap_prepare mm/vma.c:2585 [inline]
 __mmap_region mm/vma.c:2657 [inline]
 mmap_region+0xb4a/0x2080 mm/vma.c:2746
 do_mmap+0xc45/0x10d0 mm/mmap.c:561
 vm_mmap_pgoff+0x31b/0x4c0 mm/util.c:579
 ksys_mmap_pgoff+0x51f/0x760 mm/mmap.c:607
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fd3b0279469
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 21 18 00 00 90 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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fff0b2f7dd8 EFLAGS: 00000246 ORIG_RAX: 0000000000000009
RAX: ffffffffffffffda RBX: 0000200000000080 RCX: 00007fd3b0279469
RDX: 000000000000000e RSI: 0000000000001000 RDI: 0000200000001000
RBP: 00002000000000c0 R08: 0000000000000005 R09: 0000000000000000
R10: 0000000000000011 R11: 0000000000000246 R12: 0031656c69662f2e
R13: 0000200000000040 R14: 431bde82d7b634db R15: 00007fff0b2f7e40
 </TASK>

Crashes (9):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/06/22 22:43 linux-next 5d4809e25903 d6cdfb8a .config console log report syz / log C [disk image] [vmlinux] [kernel image] [mounted in repro #1] [mounted in repro #2] ci-upstream-linux-next-kasan-gce-root possible deadlock in ntfs_file_mmap_prepare
2025/06/22 20:12 linux-next 5d4809e25903 d6cdfb8a .config console log report syz / log C [disk image] [vmlinux] [kernel image] [mounted in repro #1] [mounted in repro #2] ci-upstream-linux-next-kasan-gce-root possible deadlock in ntfs_file_mmap_prepare
2025/06/22 18:05 linux-next 5d4809e25903 d6cdfb8a .config strace log report syz / log C [disk image] [vmlinux] [kernel image] [mounted in repro #1] [mounted in repro #2] ci-upstream-linux-next-kasan-gce-root possible deadlock in ntfs_file_mmap_prepare
2025/06/22 16:27 linux-next 5d4809e25903 d6cdfb8a .config console log report syz / log C [disk image] [vmlinux] [kernel image] [mounted in repro #1] [mounted in repro #2] ci-upstream-linux-next-kasan-gce-root possible deadlock in ntfs_file_mmap_prepare
2025/06/22 12:23 linux-next 5d4809e25903 d6cdfb8a .config strace log report syz / log C [disk image] [vmlinux] [kernel image] [mounted in repro #1] [mounted in repro #2] ci-upstream-linux-next-kasan-gce-root possible deadlock in ntfs_file_mmap_prepare
2025/06/22 10:23 linux-next 5d4809e25903 d6cdfb8a .config console log report syz / log C [disk image] [vmlinux] [kernel image] [mounted in repro #1] [mounted in repro #2] ci-upstream-linux-next-kasan-gce-root possible deadlock in ntfs_file_mmap_prepare
2025/06/23 09:21 linux-next f817b6dd2b62 d6cdfb8a .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root possible deadlock in ntfs_file_mmap_prepare
2025/06/23 09:21 linux-next f817b6dd2b62 d6cdfb8a .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root possible deadlock in ntfs_file_mmap_prepare
2025/06/22 08:21 linux-next 5d4809e25903 d6cdfb8a .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root possible deadlock in ntfs_file_mmap_prepare
* Struck through repros no longer work on HEAD.