ntfs3: loop2: ino=5, "/" directory corrupted
============================================
WARNING: possible recursive locking detected
6.12.0-rc1-syzkaller-00125-g0c559323bbaa #0 Not tainted
--------------------------------------------
syz.2.217/7529 is trying to acquire lock:
ffff8880793c1e60 (&ni->ni_lock#2){+.+.}-{3:3}, at: ntfs_set_state+0x1ff/0x6c0 fs/ntfs3/fsntfs.c:947

but task is already holding lock:
ffff88805dc81e60 (&ni->ni_lock#2){+.+.}-{3:3}, at: ni_trylock fs/ntfs3/ntfs_fs.h:1129 [inline]
ffff88805dc81e60 (&ni->ni_lock#2){+.+.}-{3:3}, at: ni_write_inode+0x1bc/0x1010 fs/ntfs3/frecord.c:3333

other info that might help us debug this:
 Possible unsafe locking scenario:

       CPU0
       ----
  lock(&ni->ni_lock#2);
  lock(&ni->ni_lock#2);

 *** DEADLOCK ***

 May be due to missing lock nesting notation

4 locks held by syz.2.217/7529:
 #0: ffff88802f7ac420 (sb_writers#19){.+.+}-{0:0}, at: mnt_want_write+0x3f/0x90 fs/namespace.c:515
 #1: ffff88805dc820f8 (&sb->s_type->i_mutex_key#26){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:815 [inline]
 #1: ffff88805dc820f8 (&sb->s_type->i_mutex_key#26){+.+.}-{3:3}, at: do_truncate+0x20c/0x310 fs/open.c:63
 #2: ffff88805dc81e60 (&ni->ni_lock#2){+.+.}-{3:3}, at: ni_trylock fs/ntfs3/ntfs_fs.h:1129 [inline]
 #2: ffff88805dc81e60 (&ni->ni_lock#2){+.+.}-{3:3}, at: ni_write_inode+0x1bc/0x1010 fs/ntfs3/frecord.c:3333
 #3: ffff88805dc851c8 (&ni->ni_lock#2){+.+.}-{3:3}, at: ni_trylock fs/ntfs3/ntfs_fs.h:1129 [inline]
 #3: ffff88805dc851c8 (&ni->ni_lock#2){+.+.}-{3:3}, at: ni_update_parent+0x9d2/0xdd0 fs/ntfs3/frecord.c:3298

stack backtrace:
CPU: 1 UID: 0 PID: 7529 Comm: syz.2.217 Not tainted 6.12.0-rc1-syzkaller-00125-g0c559323bbaa #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120
 print_deadlock_bug+0x483/0x620 kernel/locking/lockdep.c:3037
 check_deadlock kernel/locking/lockdep.c:3089 [inline]
 validate_chain+0x15e2/0x5920 kernel/locking/lockdep.c:3891
 __lock_acquire+0x1384/0x2050 kernel/locking/lockdep.c:5202
 lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5825
 __mutex_lock_common kernel/locking/mutex.c:608 [inline]
 __mutex_lock+0x136/0xd70 kernel/locking/mutex.c:752
 ntfs_set_state+0x1ff/0x6c0 fs/ntfs3/fsntfs.c:947
 indx_read+0x5a7/0xc50
 indx_find+0x47a/0xbf0 fs/ntfs3/index.c:1181
 indx_update_dup+0x485/0x860 fs/ntfs3/index.c:2666
 ni_update_parent+0xa18/0xdd0 fs/ntfs3/frecord.c:3301
 ni_write_inode+0xd9a/0x1010 fs/ntfs3/frecord.c:3392
 ntfs_truncate fs/ntfs3/file.c:472 [inline]
 ntfs3_setattr+0x962/0xb80 fs/ntfs3/file.c:774
 notify_change+0xbca/0xe90 fs/attr.c:503
 do_truncate+0x220/0x310 fs/open.c:65
 handle_truncate fs/namei.c:3395 [inline]
 do_open fs/namei.c:3778 [inline]
 path_openat+0x2e1e/0x3590 fs/namei.c:3933
 do_filp_open+0x235/0x490 fs/namei.c:3960
 do_sys_openat2+0x13e/0x1d0 fs/open.c:1415
 do_sys_open fs/open.c:1430 [inline]
 __do_sys_creat fs/open.c:1506 [inline]
 __se_sys_creat fs/open.c:1500 [inline]
 __x64_sys_creat+0x123/0x170 fs/open.c:1500
 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:0x7ff3c877dff9
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:00007ff3c85d8038 EFLAGS: 00000246 ORIG_RAX: 0000000000000055
RAX: ffffffffffffffda RBX: 00007ff3c8936058 RCX: 00007ff3c877dff9
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000020000580
RBP: 00007ff3c87f0296 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007ff3c8936058 R15: 00007ffc12812ea8
 </TASK>
ntfs3: loop2: Mark volume as dirty due to NTFS errors
bio_check_eod: 10 callbacks suppressed
syz.2.217: attempt to access beyond end of device
loop2: rw=2049, sector=56, nr_sectors = 8 limit=0
Buffer I/O error on dev loop2, logical block 7, lost sync page write
ntfs3: loop2: ino=3, ntfs_set_state failed, -5.
syz.2.217: attempt to access beyond end of device
loop2: rw=2049, sector=296, nr_sectors = 8 limit=0
Buffer I/O error on dev loop2, logical block 37, lost sync page write
ntfs3: loop2: ino=21, "file0aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ntfs_sync_inode failed, -5.