syzbot


possible deadlock in map_mft_record (2)

Status: upstream: reported on 2024/09/14 09:25
Reported-by: syzbot+ba30c43520c2fdcee3a2@syzkaller.appspotmail.com
First crash: 26d, last: 26d
Similar bugs (6)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-6.1 possible deadlock in map_mft_record 13 193d 568d 0/3 auto-obsoleted due to no activity on 2024/07/09 13:58
upstream possible deadlock in map_mft_record ntfs3 C error done 845 253d 722d 25/28 fixed on 2024/03/20 11:33
linux-4.14 possible deadlock in map_mft_record ntfs C 5 601d 695d 0/1 upstream: reported C repro on 2022/11/15 01:41
upstream possible deadlock in map_mft_record (2) fs 1 188d 184d 0/28 auto-obsoleted due to no activity on 2024/07/04 04:55
linux-5.15 possible deadlock in map_mft_record 35 15h08m 572d 0/3 upstream: reported on 2023/03/17 18:38
linux-4.19 possible deadlock in map_mft_record ntfs C error 11 620d 731d 0/1 upstream: reported C repro on 2022/10/09 19:52

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

but task is already holding lock:
ffff0000e1d40100 (&rl->lock){++++}-{3:3}, at: ntfs_attr_vcn_to_lcn_nolock+0x1b0/0x340 fs/ntfs/attrib.c:363

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&rl->lock){++++}-{3:3}:
       down_read+0x64/0x308 kernel/locking/rwsem.c:1520
       ntfs_read_block fs/ntfs/aops.c:248 [inline]
       ntfs_read_folio+0xf40/0x1d70 fs/ntfs/aops.c:436
       filemap_read_folio+0x14c/0x39c mm/filemap.c:2461
       do_read_cache_folio+0x24c/0x544 mm/filemap.c:3598
       do_read_cache_page mm/filemap.c:3640 [inline]
       read_cache_page+0x6c/0x180 mm/filemap.c:3649
       read_mapping_page include/linux/pagemap.h:791 [inline]
       ntfs_map_page fs/ntfs/aops.h:75 [inline]
       ntfs_sync_mft_mirror+0x1cc/0x1890 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:3050
       ntfs_write_inode+0x68/0x90 fs/ntfs/super.c:2656
       write_inode fs/fs-writeback.c:1460 [inline]
       __writeback_single_inode+0x614/0x1770 fs/fs-writeback.c:1677
       writeback_sb_inodes+0x978/0x1718 fs/fs-writeback.c:1903
       wb_writeback+0x414/0x1130 fs/fs-writeback.c:2077
       wb_do_writeback fs/fs-writeback.c:2220 [inline]
       wb_workfn+0x3a8/0x1034 fs/fs-writeback.c:2260
       process_one_work+0x7ac/0x1404 kernel/workqueue.c:2292
       worker_thread+0x8e4/0xfec kernel/workqueue.c:2439
       kthread+0x250/0x2d8 kernel/kthread.c:376
       ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:864

-> #0 (&ni->mrec_lock){+.+.}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3090 [inline]
       check_prevs_add kernel/locking/lockdep.c:3209 [inline]
       validate_chain kernel/locking/lockdep.c:3825 [inline]
       __lock_acquire+0x3338/0x7680 kernel/locking/lockdep.c:5049
       lock_acquire+0x26c/0x7cc kernel/locking/lockdep.c:5662
       __mutex_lock_common+0x190/0x21a0 kernel/locking/mutex.c:603
       __mutex_lock kernel/locking/mutex.c:747 [inline]
       mutex_lock_nested+0x38/0x44 kernel/locking/mutex.c:799
       map_mft_record+0x64/0x7b4 fs/ntfs/mft.c:154
       ntfs_map_runlist_nolock+0x370/0x12fc fs/ntfs/attrib.c:91
       ntfs_attr_vcn_to_lcn_nolock+0x1f8/0x340 fs/ntfs/attrib.c:371
       ntfs_perform_write+0x58e4/0x6ef4 fs/ntfs/file.c:1788
       ntfs_file_write_iter+0xf78/0x17b0 fs/ntfs/file.c:1917
       call_write_iter include/linux/fs.h:2265 [inline]
       new_sync_write fs/read_write.c:491 [inline]
       vfs_write+0x610/0x91c fs/read_write.c:584
       ksys_write+0x15c/0x26c fs/read_write.c:637
       __do_sys_write fs/read_write.c:649 [inline]
       __se_sys_write fs/read_write.c:646 [inline]
       __arm64_sys_write+0x7c/0x90 fs/read_write.c:646
       __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
       invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
       el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:140
       do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:204
       el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
       el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
       el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585

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

4 locks held by syz.3.474/5618:
 #0: ffff0000d97b3c68 (&f->f_pos_lock){+.+.}-{3:3}, at: __fdget_pos+0x124/0x16c fs/file.c:1058
 #1: ffff0000f5cd0460 (sb_writers#15){.+.+}-{0:0}, at: vfs_write+0x244/0x91c fs/read_write.c:580
 #2: ffff0000e1d40470 (&sb->s_type->i_mutex_key#32){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:758 [inline]
 #2: ffff0000e1d40470 (&sb->s_type->i_mutex_key#32){+.+.}-{3:3}, at: ntfs_file_write_iter+0x7c/0x17b0 fs/ntfs/file.c:1912
 #3: ffff0000e1d40100 (&rl->lock){++++}-{3:3}, at: ntfs_attr_vcn_to_lcn_nolock+0x1b0/0x340 fs/ntfs/attrib.c:363

stack backtrace:
CPU: 0 PID: 5618 Comm: syz.3.474 Not tainted 6.1.110-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/06/2024
Call trace:
 dump_backtrace+0x1c8/0x1f4 arch/arm64/kernel/stacktrace.c:158
 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:165
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x108/0x170 lib/dump_stack.c:106
 dump_stack+0x1c/0x58 lib/dump_stack.c:113
 print_circular_bug+0x150/0x1b8 kernel/locking/lockdep.c:2048
 check_noncircular+0x2cc/0x378 kernel/locking/lockdep.c:2170
 check_prev_add kernel/locking/lockdep.c:3090 [inline]
 check_prevs_add kernel/locking/lockdep.c:3209 [inline]
 validate_chain kernel/locking/lockdep.c:3825 [inline]
 __lock_acquire+0x3338/0x7680 kernel/locking/lockdep.c:5049
 lock_acquire+0x26c/0x7cc kernel/locking/lockdep.c:5662
 __mutex_lock_common+0x190/0x21a0 kernel/locking/mutex.c:603
 __mutex_lock kernel/locking/mutex.c:747 [inline]
 mutex_lock_nested+0x38/0x44 kernel/locking/mutex.c:799
 map_mft_record+0x64/0x7b4 fs/ntfs/mft.c:154
 ntfs_map_runlist_nolock+0x370/0x12fc fs/ntfs/attrib.c:91
 ntfs_attr_vcn_to_lcn_nolock+0x1f8/0x340 fs/ntfs/attrib.c:371
 ntfs_perform_write+0x58e4/0x6ef4 fs/ntfs/file.c:1788
 ntfs_file_write_iter+0xf78/0x17b0 fs/ntfs/file.c:1917
 call_write_iter include/linux/fs.h:2265 [inline]
 new_sync_write fs/read_write.c:491 [inline]
 vfs_write+0x610/0x91c fs/read_write.c:584
 ksys_write+0x15c/0x26c fs/read_write.c:637
 __do_sys_write fs/read_write.c:649 [inline]
 __se_sys_write fs/read_write.c:646 [inline]
 __arm64_sys_write+0x7c/0x90 fs/read_write.c:646
 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
 invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:140
 do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:204
 el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
 el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/09/14 09:24 linux-6.1.y 5f55cad62cc9 c7e35043 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in map_mft_record
* Struck through repros no longer work on HEAD.