syzbot


possible deadlock in map_mft_record (2)

Status: moderation: reported on 2024/04/09 04:58
Subsystems: fs
[Documentation on labels]
Reported-by: syzbot+7e5585816225fc542ecc@syzkaller.appspotmail.com
First crash: 46d, last: 46d
Similar bugs (5)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-6.1 possible deadlock in map_mft_record 13 51d 427d 0/3 upstream: reported on 2023/03/21 20:17
upstream possible deadlock in map_mft_record ntfs3 C error done 845 111d 580d 26/26 fixed on 2024/03/20 11:33
linux-4.14 possible deadlock in map_mft_record ntfs C 5 459d 553d 0/1 upstream: reported C repro on 2022/11/15 01:41
linux-5.15 possible deadlock in map_mft_record 32 2d18h 431d 0/3 upstream: reported on 2023/03/17 18:38
linux-4.19 possible deadlock in map_mft_record ntfs C error 11 478d 590d 0/1 upstream: reported C repro on 2022/10/09 19:52

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.8.0-rc7-syzkaller-g707081b61156 #0 Not tainted
------------------------------------------------------
syz-executor.1/9099 is trying to acquire lock:
ffff0000c179f510 (&ni->mrec_lock){+.+.}-{3:3}, at: map_mft_record+0x64/0x7b4 fs/ntfs/mft.c:154

but task is already holding lock:
ffff0000c179f480 (&rl->lock){++++}-{3:3}, at: ntfs_truncate+0x170/0x2130 fs/ntfs/inode.c:2378

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&rl->lock){++++}-{3:3}:
       down_read+0x58/0x2fc kernel/locking/rwsem.c:1526
       ntfs_read_block fs/ntfs/aops.c:242 [inline]
       ntfs_read_folio+0xd84/0x1c08 fs/ntfs/aops.c:430
       filemap_read_folio+0x14c/0x39c mm/filemap.c:2324
       do_read_cache_folio+0x114/0x548 mm/filemap.c:3703
       do_read_cache_page mm/filemap.c:3769 [inline]
       read_cache_page+0x6c/0x15c mm/filemap.c:3778
       read_mapping_page include/linux/pagemap.h:888 [inline]
       ntfs_map_page fs/ntfs/aops.h:75 [inline]
       ntfs_sync_mft_mirror+0x1cc/0x1894 fs/ntfs/mft.c:480
       write_mft_record_nolock+0x100c/0x1630 fs/ntfs/mft.c:787
       write_mft_record+0x144/0x1bc fs/ntfs/mft.h:95
       __ntfs_write_inode+0x5cc/0xa78 fs/ntfs/inode.c:3052
       ntfs_write_inode+0x68/0x90 fs/ntfs/super.c:2664
       write_inode fs/fs-writeback.c:1473 [inline]
       __writeback_single_inode+0x5a8/0x146c fs/fs-writeback.c:1690
       writeback_sb_inodes+0x718/0x1010 fs/fs-writeback.c:1916
       wb_writeback+0x3f4/0xfc0 fs/fs-writeback.c:2092
       wb_do_writeback fs/fs-writeback.c:2239 [inline]
       wb_workfn+0x37c/0xf9c fs/fs-writeback.c:2279
       process_one_work+0x694/0x1204 kernel/workqueue.c:2633
       process_scheduled_works kernel/workqueue.c:2706 [inline]
       worker_thread+0x938/0xef4 kernel/workqueue.c:2787
       kthread+0x288/0x310 kernel/kthread.c:388
       ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:860

-> #0 (&ni->mrec_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+0x3384/0x763c kernel/locking/lockdep.c:5137
       lock_acquire+0x23c/0x71c kernel/locking/lockdep.c:5754
       __mutex_lock_common+0x190/0x21a0 kernel/locking/mutex.c:608
       __mutex_lock kernel/locking/mutex.c:752 [inline]
       mutex_lock_nested+0x2c/0x38 kernel/locking/mutex.c:804
       map_mft_record+0x64/0x7b4 fs/ntfs/mft.c:154
       ntfs_truncate+0x1d0/0x2130 fs/ntfs/inode.c:2383
       ntfs_truncate_vfs fs/ntfs/inode.c:2864 [inline]
       ntfs_setattr+0x368/0x428 fs/ntfs/inode.c:2916
       notify_change+0x9d4/0xc8c fs/attr.c:499
       do_truncate+0x1c0/0x28c fs/open.c:66
       vfs_truncate+0x2b8/0x360 fs/open.c:112
       do_sys_truncate+0xec/0x1b4 fs/open.c:135
       __do_sys_truncate fs/open.c:147 [inline]
       __se_sys_truncate fs/open.c:145 [inline]
       __arm64_sys_truncate+0x5c/0x70 fs/open.c:145
       __invoke_syscall arch/arm64/kernel/syscall.c:34 [inline]
       invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:48
       el0_svc_common+0x130/0x23c arch/arm64/kernel/syscall.c:133
       do_el0_svc+0x48/0x58 arch/arm64/kernel/syscall.c:152
       el0_svc+0x54/0x168 arch/arm64/kernel/entry-common.c:712
       el0t_64_sync_handler+0x84/0xfc arch/arm64/kernel/entry-common.c:730
       el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:598

other info that might help us debug this:

 Possible unsafe locking scenario:

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

 *** DEADLOCK ***

3 locks held by syz-executor.1/9099:
 #0: ffff0000ed7c6420 (sb_writers#31){.+.+}-{0:0}, at: mnt_want_write+0x44/0x9c fs/namespace.c:409
 #1: ffff0000c179f7f0 (&sb->s_type->i_mutex_key#36){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:804 [inline]
 #1: ffff0000c179f7f0 (&sb->s_type->i_mutex_key#36){+.+.}-{3:3}, at: do_truncate+0x1ac/0x28c fs/open.c:64
 #2: ffff0000c179f480 (&rl->lock){++++}-{3:3}, at: ntfs_truncate+0x170/0x2130 fs/ntfs/inode.c:2378

stack backtrace:
CPU: 1 PID: 9099 Comm: syz-executor.1 Not tainted 6.8.0-rc7-syzkaller-g707081b61156 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024
Call trace:
 dump_backtrace+0x1b8/0x1e4 arch/arm64/kernel/stacktrace.c:291
 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:298
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xd0/0x124 lib/dump_stack.c:106
 dump_stack+0x1c/0x28 lib/dump_stack.c:113
 print_circular_bug+0x150/0x1b8 kernel/locking/lockdep.c:2060
 check_noncircular+0x310/0x404 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+0x3384/0x763c kernel/locking/lockdep.c:5137
 lock_acquire+0x23c/0x71c kernel/locking/lockdep.c:5754
 __mutex_lock_common+0x190/0x21a0 kernel/locking/mutex.c:608
 __mutex_lock kernel/locking/mutex.c:752 [inline]
 mutex_lock_nested+0x2c/0x38 kernel/locking/mutex.c:804
 map_mft_record+0x64/0x7b4 fs/ntfs/mft.c:154
 ntfs_truncate+0x1d0/0x2130 fs/ntfs/inode.c:2383
 ntfs_truncate_vfs fs/ntfs/inode.c:2864 [inline]
 ntfs_setattr+0x368/0x428 fs/ntfs/inode.c:2916
 notify_change+0x9d4/0xc8c fs/attr.c:499
 do_truncate+0x1c0/0x28c fs/open.c:66
 vfs_truncate+0x2b8/0x360 fs/open.c:112
 do_sys_truncate+0xec/0x1b4 fs/open.c:135
 __do_sys_truncate fs/open.c:147 [inline]
 __se_sys_truncate fs/open.c:145 [inline]
 __arm64_sys_truncate+0x5c/0x70 fs/open.c:145
 __invoke_syscall arch/arm64/kernel/syscall.c:34 [inline]
 invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:48
 el0_svc_common+0x130/0x23c arch/arm64/kernel/syscall.c:133
 do_el0_svc+0x48/0x58 arch/arm64/kernel/syscall.c:152
 el0_svc+0x54/0x168 arch/arm64/kernel/entry-common.c:712
 el0t_64_sync_handler+0x84/0xfc arch/arm64/kernel/entry-common.c:730
 el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:598

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/04/05 04:54 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 707081b61156 0ee3535e .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 possible deadlock in map_mft_record
* Struck through repros no longer work on HEAD.