syzbot


possible deadlock in ntfs_read_block

Status: upstream: reported C repro on 2022/09/30 22:27
Reported-by: syzbot+780dbcbee0942e16bcb6@syzkaller.appspotmail.com
First crash: 57d, last: 1h37m

Cause bisection: failed (bisect log)

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.1.0-rc6-syzkaller-00012-g4312098baf37 #0 Not tainted
------------------------------------------------------
kworker/u4:4/102 is trying to acquire lock:
ffff888073dc8940 (&rl->lock){++++}-{3:3}, at: ntfs_read_block+0x91a/0x22e0 fs/ntfs/aops.c:248

but task is already holding lock:
ffff888073dcb310 (&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+0xe38/0x10f0 fs/attr.c:420
       do_truncate+0x1fb/0x2e0 fs/open.c:65
       handle_truncate fs/namei.c:3216 [inline]
       do_open fs/namei.c:3561 [inline]
       path_openat+0x2770/0x2df0 fs/namei.c:3713
       do_filp_open+0x264/0x4f0 fs/namei.c:3740
       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:2407
       do_read_cache_folio+0x2d3/0x790 mm/filemap.c:3534
       do_read_cache_page mm/filemap.c:3576 [inline]
       read_cache_page+0x56/0x270 mm/filemap.c:3585
       read_mapping_page include/linux/pagemap.h:756 [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:1440 [inline]
       __writeback_single_inode+0x4d6/0x670 fs/fs-writeback.c:1652
       writeback_sb_inodes+0xb3b/0x18f0 fs/fs-writeback.c:1870
       __writeback_inodes_wb+0x125/0x420 fs/fs-writeback.c:1941
       wb_writeback+0x440/0x7b0 fs/fs-writeback.c:2046
       wb_check_background_flush fs/fs-writeback.c:2112 [inline]
       wb_do_writeback fs/fs-writeback.c:2200 [inline]
       wb_workfn+0xb3f/0xef0 fs/fs-writeback.c:2227
       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:306

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 ***

4 locks held by kworker/u4:4/102:
 #0: ffff8881457c6938 ((wq_completion)writeback){+.+.}-{0:0}, at: process_one_work+0x7f2/0xdb0
 #1: ffffc90001577d00 ((work_completion)(&(&wb->dwork)->work)){+.+.}-{0:0}, at: process_one_work+0x831/0xdb0 kernel/workqueue.c:2264
 #2: ffff888023c720e0 (&type->s_umount_key#63){.+.+}-{3:3}, at: trylock_super+0x1b/0xf0 fs/super.c:415
 #3: ffff888073dcb310 (&ni->mrec_lock){+.+.}-{3:3}, at: map_mft_record+0x46/0x610 fs/ntfs/mft.c:154

stack backtrace:
CPU: 0 PID: 102 Comm: kworker/u4:4 Not tainted 6.1.0-rc6-syzkaller-00012-g4312098baf37 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
Workqueue: writeback wb_workfn (flush-7:0)
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1b1/0x28e 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:2407
 do_read_cache_folio+0x2d3/0x790 mm/filemap.c:3534
 do_read_cache_page mm/filemap.c:3576 [inline]
 read_cache_page+0x56/0x270 mm/filemap.c:3585
 read_mapping_page include/linux/pagemap.h:756 [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:1440 [inline]
 __writeback_single_inode+0x4d6/0x670 fs/fs-writeback.c:1652
 writeback_sb_inodes+0xb3b/0x18f0 fs/fs-writeback.c:1870
 __writeback_inodes_wb+0x125/0x420 fs/fs-writeback.c:1941
 wb_writeback+0x440/0x7b0 fs/fs-writeback.c:2046
 wb_check_background_flush fs/fs-writeback.c:2112 [inline]
 wb_do_writeback fs/fs-writeback.c:2200 [inline]
 wb_workfn+0xb3f/0xef0 fs/fs-writeback.c:2227
 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:306
 </TASK>

Crashes (16):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci2-upstream-fs 2022/11/24 14:06 upstream 4312098baf37 ff68ff8f .config log report syz C possible deadlock in ntfs_read_block
ci2-upstream-fs 2022/10/01 12:43 upstream 70575e77839f feb56351 .config log report syz C possible deadlock in ntfs_read_block
ci-upstream-gce-arm64 2022/09/30 20:55 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci bbed346d5a96 feb56351 .config log report syz C possible deadlock in ntfs_read_block
ci2-upstream-fs 2022/11/27 01:31 upstream 644e9524388a f4470a7b .config log report info possible deadlock in ntfs_read_block
ci2-upstream-fs 2022/11/25 00:16 upstream 4312098baf37 ff68ff8f .config log report info possible deadlock in ntfs_read_block
ci2-upstream-fs 2022/11/24 16:09 upstream 4312098baf37 ff68ff8f .config log report info possible deadlock in ntfs_read_block
ci-upstream-kasan-gce-smack-root 2022/11/22 22:38 upstream eb7081409f94 9da37ae8 .config log report info possible deadlock in ntfs_read_block
ci2-upstream-fs 2022/11/09 14:20 upstream f141df371335 bebca8b7 .config log report info possible deadlock in ntfs_read_block
ci2-upstream-fs 2022/11/09 12:25 upstream f141df371335 5fa28208 .config log report info possible deadlock in ntfs_read_block
ci2-upstream-fs 2022/11/08 03:52 upstream 59f2f4b8a757 6feb842b .config log report info possible deadlock in ntfs_read_block
ci2-upstream-fs 2022/11/06 20:45 upstream b208b9fbbcba 6d752409 .config log report info possible deadlock in ntfs_read_block
ci-upstream-gce-arm64 2022/11/03 04:27 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci bbed346d5a96 08977f5d .config log report info possible deadlock in ntfs_read_block
ci-upstream-gce-arm64 2022/11/01 15:00 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci bbed346d5a96 a1d8560a .config log report info possible deadlock in ntfs_read_block
ci-upstream-gce-arm64 2022/11/01 03:15 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci bbed346d5a96 a1d8560a .config log report info possible deadlock in ntfs_read_block
ci-upstream-gce-arm64 2022/10/12 22:57 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci bbed346d5a96 89b5a509 .config log report info possible deadlock in ntfs_read_block
ci-upstream-gce-arm64 2022/09/30 20:11 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci bbed346d5a96 feb56351 .config log report info possible deadlock in ntfs_read_block
* Struck through repros no longer work on HEAD.