======================================================
WARNING: possible circular locking dependency detected
6.6.0-rc7-syzkaller-00195-g2af9b20dbb39 #0 Not tainted
------------------------------------------------------
kworker/u4:1/12 is trying to acquire lock:
ffff888075eb0940 (&rl->lock){++++}-{3:3}, at: ntfs_read_block fs/ntfs/aops.c:248 [inline]
ffff888075eb0940 (&rl->lock){++++}-{3:3}, at: ntfs_read_folio+0x14cb/0x29c0 fs/ntfs/aops.c:436

but task is already holding lock:
ffff888075eb6490 (&ni->mrec_lock){+.+.}-{3:3}, at: map_mft_record+0x4c/0x630 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}:
       __mutex_lock_common kernel/locking/mutex.c:603 [inline]
       __mutex_lock+0x136/0xd60 kernel/locking/mutex.c:747
       map_mft_record+0x4c/0x630 fs/ntfs/mft.c:154
       ntfs_truncate+0x267/0x2880 fs/ntfs/inode.c:2383
       ntfs_truncate_vfs fs/ntfs/inode.c:2863 [inline]
       ntfs_setattr+0x329/0x400 fs/ntfs/inode.c:2915
       notify_change+0xb99/0xe60 fs/attr.c:499
       do_truncate+0x220/0x300 fs/open.c:66
       handle_truncate fs/namei.c:3299 [inline]
       do_open fs/namei.c:3644 [inline]
       path_openat+0x2959/0x3180 fs/namei.c:3797
       do_filp_open+0x234/0x490 fs/namei.c:3824
       do_sys_openat2+0x13e/0x1d0 fs/open.c:1422
       do_sys_open fs/open.c:1437 [inline]
       __do_sys_creat fs/open.c:1513 [inline]
       __se_sys_creat fs/open.c:1507 [inline]
       __x64_sys_creat+0x123/0x160 fs/open.c:1507
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x41/0xc0 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:3134 [inline]
       check_prevs_add kernel/locking/lockdep.c:3253 [inline]
       validate_chain kernel/locking/lockdep.c:3868 [inline]
       __lock_acquire+0x39ff/0x7f70 kernel/locking/lockdep.c:5136
       lock_acquire+0x1e3/0x520 kernel/locking/lockdep.c:5753
       down_read+0xb1/0xa40 kernel/locking/rwsem.c:1520
       ntfs_read_block fs/ntfs/aops.c:248 [inline]
       ntfs_read_folio+0x14cb/0x29c0 fs/ntfs/aops.c:436
       filemap_read_folio+0x19c/0x770 mm/filemap.c:2382
       do_read_cache_folio+0x134/0x810 mm/filemap.c:3742
       do_read_cache_page+0x30/0x210 mm/filemap.c:3808
       read_mapping_page include/linux/pagemap.h:860 [inline]
       ntfs_map_page fs/ntfs/aops.h:75 [inline]
       ntfs_sync_mft_mirror+0x25f/0x1ad0 fs/ntfs/mft.c:480
       write_mft_record_nolock+0x1155/0x18d0 fs/ntfs/mft.c:787
       write_mft_record+0x149/0x310 fs/ntfs/mft.h:95
       __ntfs_write_inode+0x703/0xbb0 fs/ntfs/inode.c:3051
       write_inode fs/fs-writeback.c:1456 [inline]
       __writeback_single_inode+0x69b/0xfa0 fs/fs-writeback.c:1673
       writeback_sb_inodes+0x8e3/0x1210 fs/fs-writeback.c:1899
       __writeback_inodes_wb+0x11b/0x260 fs/fs-writeback.c:1970
       wb_writeback+0x461/0xc60 fs/fs-writeback.c:2077
       wb_check_background_flush fs/fs-writeback.c:2147 [inline]
       wb_do_writeback fs/fs-writeback.c:2235 [inline]
       wb_workfn+0xc6f/0xff0 fs/fs-writeback.c:2262
       process_one_work kernel/workqueue.c:2630 [inline]
       process_scheduled_works+0x90f/0x1400 kernel/workqueue.c:2703
       worker_thread+0xa5f/0xff0 kernel/workqueue.c:2784
       kthread+0x2d3/0x370 kernel/kthread.c:388
       ret_from_fork+0x48/0x80 arch/x86/kernel/process.c:147
       ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:304

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);
  rlock(&rl->lock);

 *** DEADLOCK ***

4 locks held by kworker/u4:1/12:
 #0: ffff888018a6d938 ((wq_completion)writeback){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:2605 [inline]
 #0: ffff888018a6d938 ((wq_completion)writeback){+.+.}-{0:0}, at: process_scheduled_works+0x825/0x1400 kernel/workqueue.c:2703
 #1: ffffc90000117d20 ((work_completion)(&(&wb->dwork)->work)){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:2605 [inline]
 #1: ffffc90000117d20 ((work_completion)(&(&wb->dwork)->work)){+.+.}-{0:0}, at: process_scheduled_works+0x825/0x1400 kernel/workqueue.c:2703
 #2: ffff88801fee40e0 (&type->s_umount_key#66){++++}-{3:3}, at: super_trylock_shared+0x22/0xf0 fs/super.c:607
 #3: ffff888075eb6490 (&ni->mrec_lock){+.+.}-{3:3}, at: map_mft_record+0x4c/0x630 fs/ntfs/mft.c:154

stack backtrace:
CPU: 0 PID: 12 Comm: kworker/u4:1 Not tainted 6.6.0-rc7-syzkaller-00195-g2af9b20dbb39 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/09/2023
Workqueue: writeback wb_workfn (flush-7:5)
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e7/0x2d0 lib/dump_stack.c:106
 check_noncircular+0x375/0x4a0 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:3868 [inline]
 __lock_acquire+0x39ff/0x7f70 kernel/locking/lockdep.c:5136
 lock_acquire+0x1e3/0x520 kernel/locking/lockdep.c:5753
 down_read+0xb1/0xa40 kernel/locking/rwsem.c:1520
 ntfs_read_block fs/ntfs/aops.c:248 [inline]
 ntfs_read_folio+0x14cb/0x29c0 fs/ntfs/aops.c:436
 filemap_read_folio+0x19c/0x770 mm/filemap.c:2382
 do_read_cache_folio+0x134/0x810 mm/filemap.c:3742
 do_read_cache_page+0x30/0x210 mm/filemap.c:3808
 read_mapping_page include/linux/pagemap.h:860 [inline]
 ntfs_map_page fs/ntfs/aops.h:75 [inline]
 ntfs_sync_mft_mirror+0x25f/0x1ad0 fs/ntfs/mft.c:480
 write_mft_record_nolock+0x1155/0x18d0 fs/ntfs/mft.c:787
 write_mft_record+0x149/0x310 fs/ntfs/mft.h:95
 __ntfs_write_inode+0x703/0xbb0 fs/ntfs/inode.c:3051
 write_inode fs/fs-writeback.c:1456 [inline]
 __writeback_single_inode+0x69b/0xfa0 fs/fs-writeback.c:1673
 writeback_sb_inodes+0x8e3/0x1210 fs/fs-writeback.c:1899
 __writeback_inodes_wb+0x11b/0x260 fs/fs-writeback.c:1970
 wb_writeback+0x461/0xc60 fs/fs-writeback.c:2077
 wb_check_background_flush fs/fs-writeback.c:2147 [inline]
 wb_do_writeback fs/fs-writeback.c:2235 [inline]
 wb_workfn+0xc6f/0xff0 fs/fs-writeback.c:2262
 process_one_work kernel/workqueue.c:2630 [inline]
 process_scheduled_works+0x90f/0x1400 kernel/workqueue.c:2703
 worker_thread+0xa5f/0xff0 kernel/workqueue.c:2784
 kthread+0x2d3/0x370 kernel/kthread.c:388
 ret_from_fork+0x48/0x80 arch/x86/kernel/process.c:147
 ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:304
 </TASK>