syzbot


possible deadlock in ntfs_sync_mft_mirror

Status: upstream: reported on 2023/03/21 16:42
Subsystems: fs
[Documentation on labels]
Reported-by: syzbot+c9340661f4a0bb3e7e65@syzkaller.appspotmail.com
First crash: 388d, last: 83d
Discussions (2)
Title Replies (including bot) Last reply
[syzbot] Monthly ntfs report (Jun 2023) 0 (1) 2023/06/02 08:40
[syzbot] [ntfs?] possible deadlock in ntfs_sync_mft_mirror 0 (1) 2023/03/21 16:42
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.19 possible deadlock in ntfs_sync_mft_mirror ntfs 1 455d 455d 0/1 upstream: reported on 2023/01/14 12:35

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.7.0-syzkaller-12829-g125514880ddd #0 Not tainted
------------------------------------------------------
kworker/u16:0/11 is trying to acquire lock:
ffff888051240940 (&rl->lock){++++}-{3:3}, at: ntfs_sync_mft_mirror+0x19cb/0x1ed0 fs/ntfs/mft.c:536

but task is already holding lock:
ffff888051243310 (&ni->mrec_lock){+.+.}-{3:3}, at: map_mft_record+0x4a/0x730 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:608 [inline]
       __mutex_lock+0x175/0x9d0 kernel/locking/mutex.c:752
       map_mft_record+0x4a/0x730 fs/ntfs/mft.c:154
       ntfs_truncate+0x263/0x2a20 fs/ntfs/inode.c:2383
       ntfs_truncate_vfs fs/ntfs/inode.c:2864 [inline]
       ntfs_setattr+0x44d/0x640 fs/ntfs/inode.c:2916
       notify_change+0x742/0x11c0 fs/attr.c:499
       do_truncate+0x15c/0x220 fs/open.c:66
       vfs_truncate+0x3eb/0x4d0 fs/open.c:112
       do_sys_truncate+0x12c/0x190 fs/open.c:135
       do_syscall_32_irqs_on arch/x86/entry/common.c:165 [inline]
       __do_fast_syscall_32+0x79/0x110 arch/x86/entry/common.c:321
       do_fast_syscall_32+0x33/0x70 arch/x86/entry/common.c:346
       entry_SYSENTER_compat_after_hwframe+0x70/0x7a

-> #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:3869 [inline]
       __lock_acquire+0x2445/0x3b30 kernel/locking/lockdep.c:5137
       lock_acquire kernel/locking/lockdep.c:5754 [inline]
       lock_acquire+0x1ae/0x520 kernel/locking/lockdep.c:5719
       down_read+0x9a/0x330 kernel/locking/rwsem.c:1526
       ntfs_sync_mft_mirror+0x19cb/0x1ed0 fs/ntfs/mft.c:536
       write_mft_record_nolock+0x1977/0x1da0 fs/ntfs/mft.c:787
       write_mft_record+0x14b/0x380 fs/ntfs/mft.h:95
       __ntfs_write_inode+0x91b/0xc30 fs/ntfs/inode.c:3052
       write_inode fs/fs-writeback.c:1473 [inline]
       __writeback_single_inode+0xa91/0xe90 fs/fs-writeback.c:1690
       writeback_sb_inodes+0x599/0x1080 fs/fs-writeback.c:1916
       wb_writeback+0x2a5/0xaa0 fs/fs-writeback.c:2092
       wb_do_writeback fs/fs-writeback.c:2239 [inline]
       wb_workfn+0x29c/0xfe0 fs/fs-writeback.c:2279
       process_one_work+0x886/0x15d0 kernel/workqueue.c:2633
       process_scheduled_works kernel/workqueue.c:2706 [inline]
       worker_thread+0x8b9/0x1290 kernel/workqueue.c:2787
       kthread+0x2c6/0x3a0 kernel/kthread.c:388
       ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147
       ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:242

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

3 locks held by kworker/u16:0/11:
 #0: ffff888014bf3138 ((wq_completion)writeback){+.+.}-{0:0}, at: process_one_work+0x789/0x15d0 kernel/workqueue.c:2608
 #1: ffffc900003d7d80 ((work_completion)(&(&wb->dwork)->work)){+.+.}-{0:0}, at: process_one_work+0x7eb/0x15d0 kernel/workqueue.c:2609
 #2: ffff888051243310 (&ni->mrec_lock){+.+.}-{3:3}, at: map_mft_record+0x4a/0x730 fs/ntfs/mft.c:154

stack backtrace:
CPU: 0 PID: 11 Comm: kworker/u16:0 Not tainted 6.7.0-syzkaller-12829-g125514880ddd #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.2-debian-1.16.2-1 04/01/2014
Workqueue: writeback wb_workfn (flush-7:2)
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xd9/0x1b0 lib/dump_stack.c:106
 check_noncircular+0x317/0x400 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:3869 [inline]
 __lock_acquire+0x2445/0x3b30 kernel/locking/lockdep.c:5137
 lock_acquire kernel/locking/lockdep.c:5754 [inline]
 lock_acquire+0x1ae/0x520 kernel/locking/lockdep.c:5719
 down_read+0x9a/0x330 kernel/locking/rwsem.c:1526
 ntfs_sync_mft_mirror+0x19cb/0x1ed0 fs/ntfs/mft.c:536
 write_mft_record_nolock+0x1977/0x1da0 fs/ntfs/mft.c:787
 write_mft_record+0x14b/0x380 fs/ntfs/mft.h:95
 __ntfs_write_inode+0x91b/0xc30 fs/ntfs/inode.c:3052
 write_inode fs/fs-writeback.c:1473 [inline]
 __writeback_single_inode+0xa91/0xe90 fs/fs-writeback.c:1690
 writeback_sb_inodes+0x599/0x1080 fs/fs-writeback.c:1916
 wb_writeback+0x2a5/0xaa0 fs/fs-writeback.c:2092
 wb_do_writeback fs/fs-writeback.c:2239 [inline]
 wb_workfn+0x29c/0xfe0 fs/fs-writeback.c:2279
 process_one_work+0x886/0x15d0 kernel/workqueue.c:2633
 process_scheduled_works kernel/workqueue.c:2706 [inline]
 worker_thread+0x8b9/0x1290 kernel/workqueue.c:2787
 kthread+0x2c6/0x3a0 kernel/kthread.c:388
 ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147
 ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:242
 </TASK>
vhci_hcd: stop threads
vhci_hcd: release socket
vhci_hcd: disconnect device

Crashes (14):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/01/21 01:15 upstream 125514880ddd 9bd8dcda .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 possible deadlock in ntfs_sync_mft_mirror
2023/11/08 14:26 upstream 305230142ae0 b93f63e8 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 possible deadlock in ntfs_sync_mft_mirror
2023/11/07 11:28 upstream be3ca57cfb77 83211397 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 possible deadlock in ntfs_sync_mft_mirror
2023/10/24 09:04 upstream e017769f4ce2 af8d2e46 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 possible deadlock in ntfs_sync_mft_mirror
2023/05/19 00:48 upstream 2d1bcbc6cd70 3bb7af1d .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream possible deadlock in ntfs_sync_mft_mirror
2023/05/17 13:27 upstream f1fcbaa18b28 258520f6 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream possible deadlock in ntfs_sync_mft_mirror
2023/03/21 16:18 upstream 17214b70a159 03fb9538 .config console log report info ci-qemu-upstream possible deadlock in ntfs_sync_mft_mirror
2023/08/22 19:24 upstream 53663f4103ff 96546ace .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 possible deadlock in ntfs_sync_mft_mirror
2023/08/04 03:17 upstream c1a515d3c027 74621247 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 possible deadlock in ntfs_sync_mft_mirror
2023/08/03 05:37 upstream 4b954598a47b 39a91c18 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 possible deadlock in ntfs_sync_mft_mirror
2023/07/05 21:06 upstream d528014517f2 e8b147c6 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 possible deadlock in ntfs_sync_mft_mirror
2023/05/14 22:44 upstream 31f4104e392a 2b9ba477 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 possible deadlock in ntfs_sync_mft_mirror
2023/05/14 05:58 upstream bb7c241fae62 2b9ba477 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 possible deadlock in ntfs_sync_mft_mirror
2023/05/12 09:07 upstream cc3c44c9fda2 adb9a3cd .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 possible deadlock in ntfs_sync_mft_mirror
* Struck through repros no longer work on HEAD.