exFAT-fs (loop6): failed to load alloc-bitmap
exFAT-fs (loop6): failed to recognize exfat type
loop6: detected capacity change from 0 to 4096
ntfs3(loop6): ino=5, "/" mi_enum_attr
======================================================
WARNING: possible circular locking dependency detected
6.14.0-rc1-syzkaller-00081-gbb066fe812d6 #0 Not tainted
------------------------------------------------------
syz.6.717/13207 is trying to acquire lock:
ffff88805968f6e0 (&mm->mmap_lock){++++}-{4:4}, at: mmap_read_lock_killable+0x1d/0x70 include/linux/mmap_lock.h:199

but task is already holding lock:
ffff88804c9499a0 (&sb->s_type->i_mutex_key#31){+.+.}-{4:4}, at: inode_trylock include/linux/fs.h:885 [inline]
ffff88804c9499a0 (&sb->s_type->i_mutex_key#31){+.+.}-{4:4}, at: ntfs_file_write_iter+0x294/0x7e0 fs/ntfs3/file.c:1240

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&sb->s_type->i_mutex_key#31){+.+.}-{4:4}:
       lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5851
       down_write+0x99/0x220 kernel/locking/rwsem.c:1577
       inode_lock include/linux/fs.h:865 [inline]
       ntfs_file_mmap+0x5bc/0x850 fs/ntfs3/file.c:379
       call_mmap include/linux/fs.h:2233 [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+0x245e/0x2f80 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

-> #0 (&mm->mmap_lock){++++}-{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
       down_read_killable+0xca/0xd30 kernel/locking/rwsem.c:1547
       mmap_read_lock_killable+0x1d/0x70 include/linux/mmap_lock.h:199
       get_mmap_lock_carefully mm/memory.c:6247 [inline]
       lock_mm_and_find_vma+0x29c/0x2f0 mm/memory.c:6298
       do_user_addr_fault arch/x86/mm/fault.c:1360 [inline]
       handle_page_fault arch/x86/mm/fault.c:1480 [inline]
       exc_page_fault+0x1bf/0x8b0 arch/x86/mm/fault.c:1538
       asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:623
       fault_in_readable+0x173/0x2d0
       fault_in_iov_iter_readable+0x229/0x280 lib/iov_iter.c:94
       ntfs_compress_write+0x110b/0x2170 fs/ntfs3/file.c:1095
       ntfs_file_write_iter+0x697/0x7e0 fs/ntfs3/file.c:1266
       new_sync_write fs/read_write.c:586 [inline]
       vfs_write+0xacf/0xd10 fs/read_write.c:679
       ksys_write+0x18f/0x2b0 fs/read_write.c:731
       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(&sb->s_type->i_mutex_key#31);
                               lock(&mm->mmap_lock);
                               lock(&sb->s_type->i_mutex_key#31);
  rlock(&mm->mmap_lock);

 *** DEADLOCK ***

3 locks held by syz.6.717/13207:
 #0: ffff888029a82638 (&f->f_pos_lock){+.+.}-{4:4}, at: fdget_pos+0x254/0x320 fs/file.c:1192
 #1: ffff8880329e8420 (sb_writers#25){.+.+}-{0:0}, at: file_start_write include/linux/fs.h:3023 [inline]
 #1: ffff8880329e8420 (sb_writers#25){.+.+}-{0:0}, at: vfs_write+0x225/0xd10 fs/read_write.c:675
 #2: ffff88804c9499a0 (&sb->s_type->i_mutex_key#31){+.+.}-{4:4}, at: inode_trylock include/linux/fs.h:885 [inline]
 #2: ffff88804c9499a0 (&sb->s_type->i_mutex_key#31){+.+.}-{4:4}, at: ntfs_file_write_iter+0x294/0x7e0 fs/ntfs3/file.c:1240

stack backtrace:
CPU: 1 UID: 0 PID: 13207 Comm: syz.6.717 Not tainted 6.14.0-rc1-syzkaller-00081-gbb066fe812d6 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 12/27/2024
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
 down_read_killable+0xca/0xd30 kernel/locking/rwsem.c:1547
 mmap_read_lock_killable+0x1d/0x70 include/linux/mmap_lock.h:199
 get_mmap_lock_carefully mm/memory.c:6247 [inline]
 lock_mm_and_find_vma+0x29c/0x2f0 mm/memory.c:6298
 do_user_addr_fault arch/x86/mm/fault.c:1360 [inline]
 handle_page_fault arch/x86/mm/fault.c:1480 [inline]
 exc_page_fault+0x1bf/0x8b0 arch/x86/mm/fault.c:1538
 asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:623
RIP: 0010:fault_in_readable+0x173/0x2d0 mm/gup.c:2241
Code: 00 fc ff df 4c 89 e8 4f 8d ac 25 ff 0f 00 00 49 81 e5 00 f0 ff ff 49 39 c5 72 7a e8 27 7f b7 ff 4c 39 eb 74 7d 4c 89 64 24 08 <44> 8a 23 43 0f b6 04 3e 84 c0 75 18 44 88 64 24 40 48 81 c3 00 10
RSP: 0000:ffffc900044cf980 EFLAGS: 00050287
RAX: ffffffff8207de99 RBX: 0000200000021000 RCX: 0000000000080000
RDX: ffffc9000d319000 RSI: 0000000000031888 RDI: 0000000000031889
RBP: ffffc900044cfa38 R08: ffffffff8207de2c R09: ffffffff84de5179
R10: 0000000000000002 R11: ffff88802fea0000 R12: 0000000000010000
R13: 0000200000031000 R14: 1ffff92000899f38 R15: dffffc0000000000
 fault_in_iov_iter_readable+0x229/0x280 lib/iov_iter.c:94
 ntfs_compress_write+0x110b/0x2170 fs/ntfs3/file.c:1095
 ntfs_file_write_iter+0x697/0x7e0 fs/ntfs3/file.c:1266
 new_sync_write fs/read_write.c:586 [inline]
 vfs_write+0xacf/0xd10 fs/read_write.c:679
 ksys_write+0x18f/0x2b0 fs/read_write.c:731
 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:0x7f064e98cde9
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:00007f064f71e038 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007f064eba5fa0 RCX: 00007f064e98cde9
RDX: 00000000fffffdef RSI: 00002000000000c0 RDI: 0000000000000005
RBP: 00007f064ea0e2a0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f064eba5fa0 R15: 00007ffda2aee4e8
 </TASK>
----------------
Code disassembly (best guess), 3 bytes skipped:
   0:	df 4c 89 e8          	fisttps -0x18(%rcx,%rcx,4)
   4:	4f 8d ac 25 ff 0f 00 	lea    0xfff(%r13,%r12,1),%r13
   b:	00
   c:	49 81 e5 00 f0 ff ff 	and    $0xfffffffffffff000,%r13
  13:	49 39 c5             	cmp    %rax,%r13
  16:	72 7a                	jb     0x92
  18:	e8 27 7f b7 ff       	call   0xffb77f44
  1d:	4c 39 eb             	cmp    %r13,%rbx
  20:	74 7d                	je     0x9f
  22:	4c 89 64 24 08       	mov    %r12,0x8(%rsp)
* 27:	44 8a 23             	mov    (%rbx),%r12b <-- trapping instruction
  2a:	43 0f b6 04 3e       	movzbl (%r14,%r15,1),%eax
  2f:	84 c0                	test   %al,%al
  31:	75 18                	jne    0x4b
  33:	44 88 64 24 40       	mov    %r12b,0x40(%rsp)
  38:	48                   	rex.W
  39:	81                   	.byte 0x81
  3a:	c3                   	ret
  3b:	00 10                	add    %dl,(%rax)