Kernel bug: possible deadlock in attr_data_get_block (2)
Subsystem: ntfs3
Status: open

Crash report:
======================================================
WARNING: possible circular locking dependency detected
6.14.0-rc4-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor213/5832 is trying to acquire lock:
ffff888076492d10 (&ni->ni_lock/5){+.+.}-{4:4}, at: ni_lock fs/ntfs3/ntfs_fs.h:1111 [inline]
ffff888076492d10 (&ni->ni_lock/5){+.+.}-{4:4}, at: attr_data_get_block+0x464/0x2fb0 fs/ntfs3/attrib.c:918

but task is already holding lock:
ffff88807f554620 (&mm->mmap_lock){++++}-{4:4}, at: mmap_write_lock_killable include/linux/mmap_lock.h:152 [inline]
ffff88807f554620 (&mm->mmap_lock){++++}-{4:4}, at: vm_mmap_pgoff+0x182/0x430 mm/util.c:573

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&mm->mmap_lock){++++}-{4:4}:
       lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5851
       __might_fault+0xc6/0x120 mm/memory.c:6851
       _inline_copy_to_user include/linux/uaccess.h:192 [inline]
       _copy_to_user+0x2c/0xb0 lib/usercopy.c:26
       copy_to_user include/linux/uaccess.h:225 [inline]
       fiemap_fill_next_extent+0x235/0x420 fs/ioctl.c:145
       ni_fiemap+0xfec/0x1270 fs/ntfs3/frecord.c:1953
       ntfs_fiemap+0x132/0x180 fs/ntfs3/file.c:1360
       ioctl_fiemap fs/ioctl.c:220 [inline]
       do_vfs_ioctl+0x1981/0x2770 fs/ioctl.c:840
       __do_sys_ioctl fs/ioctl.c:904 [inline]
       __se_sys_ioctl+0x80/0x170 fs/ioctl.c:892
       do_syscall_x64 arch/x86/entry/common.c:52 [inline]
       do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #0 (&ni->ni_lock/5){+.+.}-{4:4}:
       check_prev_add kernel/locking/lockdep.c:3163 [inline]
       check_prevs_add kernel/locking/lockdep.c:3282 [inline]
       validate_chain+0x18ef/0x5920 kernel/locking/lockdep.c:3906
       __lock_acquire+0x1397/0x2100 kernel/locking/lockdep.c:5228
       lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5851
       __mutex_lock_common kernel/locking/mutex.c:585 [inline]
       __mutex_lock+0x19c/0x1010 kernel/locking/mutex.c:730
       ni_lock fs/ntfs3/ntfs_fs.h:1111 [inline]
       attr_data_get_block+0x464/0x2fb0 fs/ntfs3/attrib.c:918
       ntfs_file_mmap+0x4f2/0x850 fs/ntfs3/file.c:371
       call_mmap include/linux/fs.h:2245 [inline]
       mmap_file mm/internal.h:124 [inline]
       __mmap_new_file_vma mm/vma.c:2292 [inline]
       __mmap_new_vma mm/vma.c:2356 [inline]
       __mmap_region mm/vma.c:2457 [inline]
       mmap_region+0x247c/0x2fa0 mm/vma.c:2535
       do_mmap+0xecc/0x13a0 mm/mmap.c:561
       vm_mmap_pgoff+0x214/0x430 mm/util.c:575
       ksys_mmap_pgoff+0x4eb/0x720 mm/mmap.c:607
       do_syscall_x64 arch/x86/entry/common.c:52 [inline]
       do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
       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(&ni->ni_lock/5);
                               lock(&mm->mmap_lock);
  lock(&ni->ni_lock/5);

 *** DEADLOCK ***

1 lock held by syz-executor213/5832:
 #0: ffff88807f554620 (&mm->mmap_lock){++++}-{4:4}, at: mmap_write_lock_killable include/linux/mmap_lock.h:152 [inline]
 #0: ffff88807f554620 (&mm->mmap_lock){++++}-{4:4}, at: vm_mmap_pgoff+0x182/0x430 mm/util.c:573

stack backtrace:
CPU: 0 UID: 0 PID: 5832 Comm: syz-executor213 Not tainted 6.14.0-rc4-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2025
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120
 print_circular_bug+0x13a/0x1b0 kernel/locking/lockdep.c:2076
 check_noncircular+0x36a/0x4a0 kernel/locking/lockdep.c:2208
 check_prev_add kernel/locking/lockdep.c:3163 [inline]
 check_prevs_add kernel/locking/lockdep.c:3282 [inline]
 validate_chain+0x18ef/0x5920 kernel/locking/lockdep.c:3906
 __lock_acquire+0x1397/0x2100 kernel/locking/lockdep.c:5228
 lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5851
 __mutex_lock_common kernel/locking/mutex.c:585 [inline]
 __mutex_lock+0x19c/0x1010 kernel/locking/mutex.c:730
 ni_lock fs/ntfs3/ntfs_fs.h:1111 [inline]
 attr_data_get_block+0x464/0x2fb0 fs/ntfs3/attrib.c:918
 ntfs_file_mmap+0x4f2/0x850 fs/ntfs3/file.c:371
 call_mmap include/linux/fs.h:2245 [inline]
 mmap_file mm/internal.h:124 [inline]
 __mmap_new_file_vma mm/vma.c:2292 [inline]
 __mmap_new_vma mm/vma.c:2356 [inline]
 __mmap_region mm/vma.c:2457 [inline]
 mmap_region+0x247c/0x2fa0 mm/vma.c:2535
 do_mmap+0xecc/0x13a0 mm/mmap.c:561
 vm_mmap_pgoff+0x214/0x430 mm/util.c:575
 ksys_mmap_pgoff+0x4eb/0x720 mm/mmap.c:607
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f4e34788c49
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 61 17 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:00007ffcc0c215c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000009