syzbot


possible deadlock in ntfs_file_mmap

Status: upstream: reported on 2025/07/04 01:12
Reported-by: syzbot+b58b96cb5ac8d4ad1cbc@syzkaller.appspotmail.com
First crash: 4d04h, last: 4d04h
Similar bugs (3)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-6.1 possible deadlock in ntfs_file_mmap origin:lts-only C error 355 5d01h 338d 0/3 upstream: reported C repro on 2024/08/03 10:10
linux-5.15 possible deadlock in ntfs_file_mmap origin:lts-only C error 454 2d03h 322d 0/3 upstream: reported C repro on 2024/08/19 06:49
upstream possible deadlock in ntfs_file_mmap ntfs3 C done 3426 3h20m 387d 0/29 upstream: reported C repro on 2024/06/15 07:17

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.6.95-syzkaller #0 Not tainted
------------------------------------------------------
syz.8.3980/15969 is trying to acquire lock:
ffff88805ce7dc30 (&sb->s_type->i_mutex_key#30){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:804 [inline]
ffff88805ce7dc30 (&sb->s_type->i_mutex_key#30){+.+.}-{3:3}, at: ntfs_file_mmap+0x54c/0x730 fs/ntfs3/file.c:302

but task is already holding lock:
ffff88802d8f27a0 (&mm->mmap_lock){++++}-{3:3}, at: mmap_write_lock_killable include/linux/mmap_lock.h:124 [inline]
ffff88802d8f27a0 (&mm->mmap_lock){++++}-{3:3}, at: vm_mmap_pgoff+0x168/0x400 mm/util.c:554

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&mm->mmap_lock){++++}-{3:3}:
       internal_get_user_pages_fast+0x21d/0x2730 mm/gup.c:3195
       iov_iter_extract_user_pages lib/iov_iter.c:1785 [inline]
       iov_iter_extract_pages+0x393/0x790 lib/iov_iter.c:1848
       dio_refill_pages fs/direct-io.c:173 [inline]
       dio_get_page fs/direct-io.c:214 [inline]
       do_direct_IO fs/direct-io.c:914 [inline]
       __blockdev_direct_IO+0x10d6/0x3420 fs/direct-io.c:1248
       blockdev_direct_IO include/linux/fs.h:3047 [inline]
       ntfs_direct_IO+0x196/0x3a0 fs/ntfs3/inode.c:801
       generic_file_direct_write+0x1d4/0x3e0 mm/filemap.c:3941
       __generic_file_write_iter+0x11b/0x230 mm/filemap.c:4097
       ntfs_file_write_iter+0x61c/0x700 fs/ntfs3/file.c:1120
       do_iter_readv_writev fs/read_write.c:-1 [inline]
       do_iter_write+0x79a/0xc70 fs/read_write.c:860
       vfs_writev fs/read_write.c:933 [inline]
       do_writev+0x252/0x410 fs/read_write.c:976
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x55/0xb0 arch/x86/entry/common.c:81
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

-> #0 (&sb->s_type->i_mutex_key#30){+.+.}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3134 [inline]
       check_prevs_add kernel/locking/lockdep.c:3253 [inline]
       validate_chain kernel/locking/lockdep.c:3869 [inline]
       __lock_acquire+0x2ddb/0x7c80 kernel/locking/lockdep.c:5137
       lock_acquire+0x197/0x410 kernel/locking/lockdep.c:5754
       down_write+0x97/0x1f0 kernel/locking/rwsem.c:1573
       inode_lock include/linux/fs.h:804 [inline]
       ntfs_file_mmap+0x54c/0x730 fs/ntfs3/file.c:302
       call_mmap include/linux/fs.h:2023 [inline]
       mmap_file mm/internal.h:98 [inline]
       __mmap_region mm/mmap.c:2786 [inline]
       mmap_region+0xe57/0x1f80 mm/mmap.c:2937
       do_mmap+0x8d1/0xfd0 mm/mmap.c:1381
       vm_mmap_pgoff+0x1c0/0x400 mm/util.c:556
       ksys_mmap_pgoff+0x520/0x700 mm/mmap.c:1427
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x55/0xb0 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(&mm->mmap_lock);
                               lock(&sb->s_type->i_mutex_key#30);
                               lock(&mm->mmap_lock);
  lock(&sb->s_type->i_mutex_key#30);

 *** DEADLOCK ***

1 lock held by syz.8.3980/15969:
 #0: ffff88802d8f27a0 (&mm->mmap_lock){++++}-{3:3}, at: mmap_write_lock_killable include/linux/mmap_lock.h:124 [inline]
 #0: ffff88802d8f27a0 (&mm->mmap_lock){++++}-{3:3}, at: vm_mmap_pgoff+0x168/0x400 mm/util.c:554

stack backtrace:
CPU: 1 PID: 15969 Comm: syz.8.3980 Not tainted 6.6.95-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/2025
Call Trace:
 <TASK>
 dump_stack_lvl+0x16c/0x230 lib/dump_stack.c:106
 check_noncircular+0x2bd/0x3c0 kernel/locking/lockdep.c:2187
 check_prev_add kernel/locking/lockdep.c:3134 [inline]
 check_prevs_add kernel/locking/lockdep.c:3253 [inline]
 validate_chain kernel/locking/lockdep.c:3869 [inline]
 __lock_acquire+0x2ddb/0x7c80 kernel/locking/lockdep.c:5137
 lock_acquire+0x197/0x410 kernel/locking/lockdep.c:5754
 down_write+0x97/0x1f0 kernel/locking/rwsem.c:1573
 inode_lock include/linux/fs.h:804 [inline]
 ntfs_file_mmap+0x54c/0x730 fs/ntfs3/file.c:302
 call_mmap include/linux/fs.h:2023 [inline]
 mmap_file mm/internal.h:98 [inline]
 __mmap_region mm/mmap.c:2786 [inline]
 mmap_region+0xe57/0x1f80 mm/mmap.c:2937
 do_mmap+0x8d1/0xfd0 mm/mmap.c:1381
 vm_mmap_pgoff+0x1c0/0x400 mm/util.c:556
 ksys_mmap_pgoff+0x520/0x700 mm/mmap.c:1427
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x55/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2
RIP: 0033:0x7fa087b8e929
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:00007fa088a09038 EFLAGS: 00000246 ORIG_RAX: 0000000000000009
RAX: ffffffffffffffda RBX: 00007fa087db5fa0 RCX: 00007fa087b8e929
RDX: 0000000000000002 RSI: 0000000000001000 RDI: 0000200000001000
RBP: 00007fa087c10b39 R08: 0000000000000004 R09: 0000000000000000
R10: 0000000000000011 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007fa087db5fa0 R15: 00007ffe6ab0f6c8
 </TASK>

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/07/04 01:12 linux-6.6.y 3f5b4c104b7d 76ad128c .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan possible deadlock in ntfs_file_mmap
2025/07/04 01:11 linux-6.6.y 3f5b4c104b7d 76ad128c .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan possible deadlock in ntfs_file_mmap
* Struck through repros no longer work on HEAD.