syzbot


possible deadlock in map_mft_record

Status: upstream: reported on 2023/03/21 20:17
Reported-by: syzbot+7788c04db40a6dad9586@syzkaller.appspotmail.com
First crash: 339d, last: 43d
Similar bugs (4)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in map_mft_record ntfs3 C error 845 24d 493d 0/26 upstream: reported C repro on 2022/10/19 05:29
linux-4.14 possible deadlock in map_mft_record ntfs C 5 372d 466d 0/1 upstream: reported C repro on 2022/11/15 01:41
linux-5.15 possible deadlock in map_mft_record 27 24d 343d 0/3 upstream: reported on 2023/03/17 18:38
linux-4.19 possible deadlock in map_mft_record ntfs C error 11 391d 502d 0/1 upstream: reported C repro on 2022/10/09 19:52

Sample crash report:
ntfs: volume version 3.1.
======================================================
WARNING: possible circular locking dependency detected
6.1.62-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.3/13069 is trying to acquire lock:
ffff888140d50190 (&ni->mrec_lock){+.+.}-{3:3}, at: map_mft_record+0x48/0x630 fs/ntfs/mft.c:154

but task is already holding lock:
ffff888140d50100 (&rl->lock){++++}-{3:3}, at: ntfs_map_runlist+0x2a/0xa0 fs/ntfs/attrib.c:288

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&rl->lock){++++}-{3:3}:
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5661
       down_read+0xad/0xa30 kernel/locking/rwsem.c:1520
       ntfs_read_block fs/ntfs/aops.c:248 [inline]
       ntfs_read_folio+0x14c9/0x29d0 fs/ntfs/aops.c:436
       filemap_read_folio+0x199/0x780 mm/filemap.c:2407
       do_read_cache_folio+0x2ee/0x810 mm/filemap.c:3535
       do_read_cache_page+0x32/0x220 mm/filemap.c:3577
       read_mapping_page include/linux/pagemap.h:756 [inline]
       ntfs_map_page fs/ntfs/aops.h:75 [inline]
       ntfs_sync_mft_mirror+0x25b/0x1ad0 fs/ntfs/mft.c:480
       write_mft_record_nolock+0x1151/0x18d0 fs/ntfs/mft.c:787
       write_mft_record+0x149/0x310 fs/ntfs/mft.h:95
       __ntfs_write_inode+0x6ff/0xbb0 fs/ntfs/inode.c:3050
       write_inode fs/fs-writeback.c:1443 [inline]
       __writeback_single_inode+0x67d/0x11e0 fs/fs-writeback.c:1660
       writeback_sb_inodes+0xc2b/0x1b20 fs/fs-writeback.c:1886
       wb_writeback+0x49d/0xe10 fs/fs-writeback.c:2060
       wb_do_writeback fs/fs-writeback.c:2203 [inline]
       wb_workfn+0x427/0x1020 fs/fs-writeback.c:2243
       process_one_work+0x8a9/0x11d0 kernel/workqueue.c:2292
       worker_thread+0xa47/0x1200 kernel/workqueue.c:2439
       kthread+0x28d/0x320 kernel/kthread.c:376
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306

-> #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+0x1667/0x58e0 kernel/locking/lockdep.c:3824
       __lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5048
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5661
       __mutex_lock_common kernel/locking/mutex.c:603 [inline]
       __mutex_lock+0x132/0xd80 kernel/locking/mutex.c:747
       map_mft_record+0x48/0x630 fs/ntfs/mft.c:154
       ntfs_map_runlist_nolock+0x4b4/0x1790 fs/ntfs/attrib.c:91
       ntfs_map_runlist+0x7e/0xa0 fs/ntfs/attrib.c:292
       ntfs_read_block fs/ntfs/aops.c:283 [inline]
       ntfs_read_folio+0x16fe/0x29d0 fs/ntfs/aops.c:436
       read_pages+0x5f2/0x830 mm/readahead.c:181
       page_cache_ra_unbounded+0x68b/0x7b0 mm/readahead.c:270
       page_cache_sync_readahead include/linux/pagemap.h:1213 [inline]
       filemap_get_pages mm/filemap.c:2582 [inline]
       filemap_read+0x7fa/0x31d0 mm/filemap.c:2676
       __kernel_read+0x41e/0x8a0 fs/read_write.c:428
       integrity_kernel_read+0xac/0xf0 security/integrity/iint.c:202
       ima_calc_file_hash_tfm security/integrity/ima/ima_crypto.c:485 [inline]
       ima_calc_file_shash security/integrity/ima/ima_crypto.c:516 [inline]
       ima_calc_file_hash+0xa57/0x1c00 security/integrity/ima/ima_crypto.c:573
       ima_collect_measurement+0x4d4/0x970 security/integrity/ima/ima_api.c:292
       process_measurement+0x1018/0x1cf0 security/integrity/ima/ima_main.c:337
       ima_file_check+0xed/0x170 security/integrity/ima/ima_main.c:520
       do_open fs/namei.c:3560 [inline]
       path_openat+0x2687/0x2e60 fs/namei.c:3715
       do_filp_open+0x230/0x480 fs/namei.c:3742
       do_sys_openat2+0x13b/0x500 fs/open.c:1318
       do_sys_open fs/open.c:1334 [inline]
       __do_sys_open fs/open.c:1342 [inline]
       __se_sys_open fs/open.c:1338 [inline]
       __x64_sys_open+0x221/0x270 fs/open.c:1338
       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

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.3/13069:
 #0: ffff8880799d83e0 (&iint->mutex){+.+.}-{3:3}, at: process_measurement+0x7fe/0x1cf0 security/integrity/ima/ima_main.c:260
 #1: ffff888140d50610 (mapping.invalidate_lock#10){.+.+}-{3:3}, at: filemap_invalidate_lock_shared include/linux/fs.h:811 [inline]
 #1: ffff888140d50610 (mapping.invalidate_lock#10){.+.+}-{3:3}, at: page_cache_ra_unbounded+0xed/0x7b0 mm/readahead.c:226
 #2: ffff888140d50100 (&rl->lock){++++}-{3:3}, at: ntfs_map_runlist+0x2a/0xa0 fs/ntfs/attrib.c:288

stack backtrace:
CPU: 1 PID: 13069 Comm: syz-executor.3 Not tainted 6.1.62-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/10/2023
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 check_noncircular+0x2fa/0x3b0 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+0x1667/0x58e0 kernel/locking/lockdep.c:3824
 __lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5048
 lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5661
 __mutex_lock_common kernel/locking/mutex.c:603 [inline]
 __mutex_lock+0x132/0xd80 kernel/locking/mutex.c:747
 map_mft_record+0x48/0x630 fs/ntfs/mft.c:154
 ntfs_map_runlist_nolock+0x4b4/0x1790 fs/ntfs/attrib.c:91
 ntfs_map_runlist+0x7e/0xa0 fs/ntfs/attrib.c:292
 ntfs_read_block fs/ntfs/aops.c:283 [inline]
 ntfs_read_folio+0x16fe/0x29d0 fs/ntfs/aops.c:436
 read_pages+0x5f2/0x830 mm/readahead.c:181
 page_cache_ra_unbounded+0x68b/0x7b0 mm/readahead.c:270
 page_cache_sync_readahead include/linux/pagemap.h:1213 [inline]
 filemap_get_pages mm/filemap.c:2582 [inline]
 filemap_read+0x7fa/0x31d0 mm/filemap.c:2676
 __kernel_read+0x41e/0x8a0 fs/read_write.c:428
 integrity_kernel_read+0xac/0xf0 security/integrity/iint.c:202
 ima_calc_file_hash_tfm security/integrity/ima/ima_crypto.c:485 [inline]
 ima_calc_file_shash security/integrity/ima/ima_crypto.c:516 [inline]
 ima_calc_file_hash+0xa57/0x1c00 security/integrity/ima/ima_crypto.c:573
 ima_collect_measurement+0x4d4/0x970 security/integrity/ima/ima_api.c:292
 process_measurement+0x1018/0x1cf0 security/integrity/ima/ima_main.c:337
 ima_file_check+0xed/0x170 security/integrity/ima/ima_main.c:520
 do_open fs/namei.c:3560 [inline]
 path_openat+0x2687/0x2e60 fs/namei.c:3715
 do_filp_open+0x230/0x480 fs/namei.c:3742
 do_sys_openat2+0x13b/0x500 fs/open.c:1318
 do_sys_open fs/open.c:1334 [inline]
 __do_sys_open fs/open.c:1342 [inline]
 __se_sys_open fs/open.c:1338 [inline]
 __x64_sys_open+0x221/0x270 fs/open.c:1338
 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
RIP: 0033:0x7fbae987cae9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 20 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fbaea58f0c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000002
RAX: ffffffffffffffda RBX: 00007fbae999bf80 RCX: 00007fbae987cae9
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000020000700
RBP: 00007fbae98c847a R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 000000000000000b R14: 00007fbae999bf80 R15: 00007ffdf03c1ad8
 </TASK>
syz-executor.3 (13069) used greatest stack depth: 19064 bytes left

Crashes (12):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/11/20 09:59 linux-6.1.y fb2635ac69ab cb976f63 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in map_mft_record
2024/01/11 23:45 linux-6.1.y 7c58bfa711cb dda5a988 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in map_mft_record
2023/12/23 17:56 linux-6.1.y 4aa6747d9352 fb427a07 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in map_mft_record
2023/10/22 01:27 linux-6.1.y 7d24402875c7 361b23dc .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in map_mft_record
2023/09/02 10:47 linux-6.1.y c2cbfe5f5122 696ea0d2 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in map_mft_record
2023/08/13 08:54 linux-6.1.y 1321ab403b38 39990d51 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in map_mft_record
2023/08/01 06:22 linux-6.1.y d2a6dc4eaf6d 2a0d0f29 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in map_mft_record
2023/07/09 02:43 linux-6.1.y 61fd484b2cf6 668cb1fa .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in map_mft_record
2023/07/07 04:34 linux-6.1.y 61fd484b2cf6 22ae5830 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in map_mft_record
2023/07/23 21:03 linux-6.1.y 75389113731b 27cbe77f .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in map_mft_record
2023/07/01 16:01 linux-6.1.y 0f4ac6b4c5f0 bfc47836 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in map_mft_record
2023/03/21 20:17 linux-6.1.y 7eaef76fbc46 8b4eb097 .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.