syzbot


possible deadlock in ntfs_fallocate

Status: upstream: reported on 2025/08/01 09:06
Reported-by: syzbot+c2c0cea7a22826d672dc@syzkaller.appspotmail.com
First crash: 26d, last: 26d
Similar bugs (2)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in ntfs_fallocate ntfs3 4 C error 490 4d07h 992d 0/29 upstream: reported C repro on 2022/12/09 08:57
linux-6.1 possible deadlock in ntfs_fallocate origin:lts-only 4 C error 54 17d 644d 0/3 upstream: reported C repro on 2023/11/22 18:34

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.6.100-syzkaller #0 Not tainted
------------------------------------------------------
syz.3.628/8936 is trying to acquire lock:
ffff88806199d980 (&ni->ni_lock#2/5){+.+.}-{3:3}, at: ni_lock fs/ntfs3/ntfs_fs.h:1120 [inline]
ffff88806199d980 (&ni->ni_lock#2/5){+.+.}-{3:3}, at: ntfs_fallocate+0x7b2/0xfd0 fs/ntfs3/file.c:554

but task is already holding lock:
ffff88806199ddc0 (mapping.invalidate_lock#9){++++}-{3:3}, at: filemap_invalidate_lock include/linux/fs.h:849 [inline]
ffff88806199ddc0 (mapping.invalidate_lock#9){++++}-{3:3}, at: ntfs_fallocate+0x3c5/0xfd0 fs/ntfs3/file.c:484

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (mapping.invalidate_lock#9){++++}-{3:3}:
       down_read+0x46/0x2e0 kernel/locking/rwsem.c:1520
       filemap_invalidate_lock_shared include/linux/fs.h:859 [inline]
       filemap_fault+0x5db/0x15a0 mm/filemap.c:3330
       __do_fault+0x13b/0x4e0 mm/memory.c:4243
       do_read_fault mm/memory.c:4616 [inline]
       do_fault mm/memory.c:4753 [inline]
       do_pte_missing mm/memory.c:3688 [inline]
       handle_pte_fault mm/memory.c:5025 [inline]
       __handle_mm_fault mm/memory.c:5166 [inline]
       handle_mm_fault+0x3886/0x4920 mm/memory.c:5331
       do_user_addr_fault+0x738/0x12e0 arch/x86/mm/fault.c:1373
       handle_page_fault arch/x86/mm/fault.c:1465 [inline]
       exc_page_fault+0x67/0x110 arch/x86/mm/fault.c:1521
       asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:608
       do_strncpy_from_user lib/strncpy_from_user.c:-1 [inline]
       strncpy_from_user+0xff/0x2e0 lib/strncpy_from_user.c:139
       getname_flags+0xf6/0x500 fs/namei.c:151
       do_sys_openat2+0xcb/0x1c0 fs/open.c:1413
       do_sys_open fs/open.c:1434 [inline]
       __do_sys_openat fs/open.c:1450 [inline]
       __se_sys_openat fs/open.c:1445 [inline]
       __x64_sys_openat+0x139/0x160 fs/open.c:1445
       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

-> #1 (&mm->mmap_lock){++++}-{3:3}:
       __might_fault+0xc6/0x120 mm/memory.c:5946
       _copy_to_user+0x2a/0xa0 lib/usercopy.c:36
       copy_to_user include/linux/uaccess.h:191 [inline]
       fiemap_fill_next_extent+0x1c1/0x390 fs/ioctl.c:145
       ni_fiemap+0x7e6/0xbe0 fs/ntfs3/frecord.c:2038
       ntfs_fiemap+0xdb/0x130 fs/ntfs3/file.c:1213
       ioctl_fiemap fs/ioctl.c:220 [inline]
       do_vfs_ioctl+0x140c/0x1bb0 fs/ioctl.c:811
       __do_sys_ioctl fs/ioctl.c:869 [inline]
       __se_sys_ioctl+0x83/0x170 fs/ioctl.c:857
       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 (&ni->ni_lock#2/5){+.+.}-{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
       __mutex_lock_common kernel/locking/mutex.c:603 [inline]
       __mutex_lock+0x129/0xcc0 kernel/locking/mutex.c:747
       ni_lock fs/ntfs3/ntfs_fs.h:1120 [inline]
       ntfs_fallocate+0x7b2/0xfd0 fs/ntfs3/file.c:554
       vfs_fallocate+0x58e/0x700 fs/open.c:324
       ksys_fallocate fs/open.c:347 [inline]
       __do_sys_fallocate fs/open.c:355 [inline]
       __se_sys_fallocate fs/open.c:353 [inline]
       __x64_sys_fallocate+0xc1/0x110 fs/open.c:353
       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:

Chain exists of:
  &ni->ni_lock#2/5 --> &mm->mmap_lock --> mapping.invalidate_lock#9

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(mapping.invalidate_lock#9);
                               lock(&mm->mmap_lock);
                               lock(mapping.invalidate_lock#9);
  lock(&ni->ni_lock#2/5);

 *** DEADLOCK ***

3 locks held by syz.3.628/8936:
 #0: ffff8880257e6418 (sb_writers#17){.+.+}-{0:0}, at: file_start_write include/linux/fs.h:2711 [inline]
 #0: ffff8880257e6418 (sb_writers#17){.+.+}-{0:0}, at: vfs_fallocate+0x4fb/0x700 fs/open.c:323
 #1: ffff88806199dc30 (&sb->s_type->i_mutex_key#21){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:804 [inline]
 #1: ffff88806199dc30 (&sb->s_type->i_mutex_key#21){+.+.}-{3:3}, at: ntfs_fallocate+0x2fe/0xfd0 fs/ntfs3/file.c:470
 #2: ffff88806199ddc0 (mapping.invalidate_lock#9){++++}-{3:3}, at: filemap_invalidate_lock include/linux/fs.h:849 [inline]
 #2: ffff88806199ddc0 (mapping.invalidate_lock#9){++++}-{3:3}, at: ntfs_fallocate+0x3c5/0xfd0 fs/ntfs3/file.c:484

stack backtrace:
CPU: 1 PID: 8936 Comm: syz.3.628 Not tainted 6.6.100-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/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
 __mutex_lock_common kernel/locking/mutex.c:603 [inline]
 __mutex_lock+0x129/0xcc0 kernel/locking/mutex.c:747
 ni_lock fs/ntfs3/ntfs_fs.h:1120 [inline]
 ntfs_fallocate+0x7b2/0xfd0 fs/ntfs3/file.c:554
 vfs_fallocate+0x58e/0x700 fs/open.c:324
 ksys_fallocate fs/open.c:347 [inline]
 __do_sys_fallocate fs/open.c:355 [inline]
 __se_sys_fallocate fs/open.c:353 [inline]
 __x64_sys_fallocate+0xc1/0x110 fs/open.c:353
 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:0x7f3b39d8eb69
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:00007f3b3ab7b038 EFLAGS: 00000246 ORIG_RAX: 000000000000011d
RAX: ffffffffffffffda RBX: 00007f3b39fb6080 RCX: 00007f3b39d8eb69
RDX: 0000000000004000 RSI: 0000000000000008 RDI: 0000000000000004
RBP: 00007f3b39e11df1 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000004000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000001 R14: 00007f3b39fb6080 R15: 00007ffc20592288
 </TASK>

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/08/01 09:06 linux-6.6.y dbcb8d8e4163 0c075d67 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan possible deadlock in ntfs_fallocate
* Struck through repros no longer work on HEAD.