======================================================
WARNING: possible circular locking dependency detected
6.2.0-rc6-syzkaller-00050-g9f266ccaa2f5 #0 Not tainted
------------------------------------------------------
kworker/u4:7/6360 is trying to acquire lock:
ffff88802d7e5bc0 (&rl->lock){++++}-{3:3}, at: ntfs_read_block+0x91a/0x22e0 fs/ntfs/aops.c:248

but task is already holding lock:
ffff88802d7e2290 (&ni->mrec_lock){+.+.}-{3:3}, at: map_mft_record+0x46/0x610 fs/ntfs/mft.c:154

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&ni->mrec_lock){+.+.}-{3:3}:
       lock_acquire+0x182/0x3c0 kernel/locking/lockdep.c:5668
       __mutex_lock_common+0x1bd/0x26e0 kernel/locking/mutex.c:603
       __mutex_lock kernel/locking/mutex.c:747 [inline]
       mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:799
       map_mft_record+0x46/0x610 fs/ntfs/mft.c:154
       ntfs_truncate+0x24e/0x2720 fs/ntfs/inode.c:2383
       ntfs_truncate_vfs fs/ntfs/inode.c:2862 [inline]
       ntfs_setattr+0x2b9/0x3a0 fs/ntfs/inode.c:2914
       notify_change+0xe50/0x1100 fs/attr.c:482
       do_truncate+0x200/0x2f0 fs/open.c:65
       handle_truncate fs/namei.c:3216 [inline]
       do_open fs/namei.c:3561 [inline]
       path_openat+0x272b/0x2dd0 fs/namei.c:3714
       do_filp_open+0x264/0x4f0 fs/namei.c:3741
       do_sys_openat2+0x124/0x4e0 fs/open.c:1310
       do_sys_open fs/open.c:1326 [inline]
       __do_sys_creat fs/open.c:1402 [inline]
       __se_sys_creat fs/open.c:1396 [inline]
       __x64_sys_creat+0x11f/0x160 fs/open.c:1396
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd

-> #0 (&rl->lock){++++}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3097 [inline]
       check_prevs_add kernel/locking/lockdep.c:3216 [inline]
       validate_chain+0x1898/0x6ae0 kernel/locking/lockdep.c:3831
       __lock_acquire+0x1292/0x1f60 kernel/locking/lockdep.c:5055
       lock_acquire+0x182/0x3c0 kernel/locking/lockdep.c:5668
       down_read+0x39/0x50 kernel/locking/rwsem.c:1509
       ntfs_read_block+0x91a/0x22e0 fs/ntfs/aops.c:248
       filemap_read_folio+0x187/0x7d0 mm/filemap.c:2426
       do_read_cache_folio+0x2d3/0x790 mm/filemap.c:3553
       do_read_cache_page mm/filemap.c:3595 [inline]
       read_cache_page+0x56/0x270 mm/filemap.c:3604
       read_mapping_page include/linux/pagemap.h:755 [inline]
       ntfs_map_page fs/ntfs/aops.h:75 [inline]
       ntfs_sync_mft_mirror+0x21a/0x1df0 fs/ntfs/mft.c:480
       write_mft_record_nolock+0x1213/0x1930 fs/ntfs/mft.c:787
       write_mft_record fs/ntfs/mft.h:95 [inline]
       __ntfs_write_inode+0x721/0xc90 fs/ntfs/inode.c:3050
       write_inode fs/fs-writeback.c:1451 [inline]
       __writeback_single_inode+0x4d6/0x670 fs/fs-writeback.c:1663
       writeback_sb_inodes+0x812/0x1050 fs/fs-writeback.c:1889
       wb_writeback+0x41f/0x7b0 fs/fs-writeback.c:2063
       wb_do_writeback fs/fs-writeback.c:2206 [inline]
       wb_workfn+0x3cb/0xef0 fs/fs-writeback.c:2246
       process_one_work+0x877/0xdb0 kernel/workqueue.c:2289
       worker_thread+0xb14/0x1330 kernel/workqueue.c:2436
       kthread+0x266/0x300 kernel/kthread.c:376
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308

other info that might help us debug this:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&ni->mrec_lock);
                               lock(&rl->lock);
                               lock(&ni->mrec_lock);
  lock(&rl->lock);

 *** DEADLOCK ***

3 locks held by kworker/u4:7/6360:
 #0: ffff888017a64938 ((wq_completion)writeback){+.+.}-{0:0}, at: process_one_work+0x7f2/0xdb0
 #1: ffffc9000355fd00 ((work_completion)(&(&wb->dwork)->work)){+.+.}-{0:0}, at: process_one_work+0x831/0xdb0 kernel/workqueue.c:2264
 #2: ffff88802d7e2290 (&ni->mrec_lock){+.+.}-{3:3}, at: map_mft_record+0x46/0x610 fs/ntfs/mft.c:154

stack backtrace:
CPU: 1 PID: 6360 Comm: kworker/u4:7 Not tainted 6.2.0-rc6-syzkaller-00050-g9f266ccaa2f5 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/12/2023
Workqueue: writeback wb_workfn (flush-7:3)
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1b1/0x290 lib/dump_stack.c:106
 check_noncircular+0x2cc/0x390 kernel/locking/lockdep.c:2177
 check_prev_add kernel/locking/lockdep.c:3097 [inline]
 check_prevs_add kernel/locking/lockdep.c:3216 [inline]
 validate_chain+0x1898/0x6ae0 kernel/locking/lockdep.c:3831
 __lock_acquire+0x1292/0x1f60 kernel/locking/lockdep.c:5055
 lock_acquire+0x182/0x3c0 kernel/locking/lockdep.c:5668
 down_read+0x39/0x50 kernel/locking/rwsem.c:1509
 ntfs_read_block+0x91a/0x22e0 fs/ntfs/aops.c:248
 filemap_read_folio+0x187/0x7d0 mm/filemap.c:2426
 do_read_cache_folio+0x2d3/0x790 mm/filemap.c:3553
 do_read_cache_page mm/filemap.c:3595 [inline]
 read_cache_page+0x56/0x270 mm/filemap.c:3604
 read_mapping_page include/linux/pagemap.h:755 [inline]
 ntfs_map_page fs/ntfs/aops.h:75 [inline]
 ntfs_sync_mft_mirror+0x21a/0x1df0 fs/ntfs/mft.c:480
 write_mft_record_nolock+0x1213/0x1930 fs/ntfs/mft.c:787
 write_mft_record fs/ntfs/mft.h:95 [inline]
 __ntfs_write_inode+0x721/0xc90 fs/ntfs/inode.c:3050
 write_inode fs/fs-writeback.c:1451 [inline]
 __writeback_single_inode+0x4d6/0x670 fs/fs-writeback.c:1663
 writeback_sb_inodes+0x812/0x1050 fs/fs-writeback.c:1889
 wb_writeback+0x41f/0x7b0 fs/fs-writeback.c:2063
 wb_do_writeback fs/fs-writeback.c:2206 [inline]
 wb_workfn+0x3cb/0xef0 fs/fs-writeback.c:2246
 process_one_work+0x877/0xdb0 kernel/workqueue.c:2289
 worker_thread+0xb14/0x1330 kernel/workqueue.c:2436
 kthread+0x266/0x300 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308
 </TASK>