syzbot


possible deadlock in map_mft_record

Status: upstream: reported on 2023/03/17 18:38
Reported-by: syzbot+cc027e3de0d2052775e3@syzkaller.appspotmail.com
First crash: 353d, last: 34d
Similar bugs (4)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-6.1 possible deadlock in map_mft_record 12 53d 349d 0/3 upstream: reported on 2023/03/21 20:17
upstream possible deadlock in map_mft_record ntfs3 C error 845 34d 503d 0/26 upstream: reported C repro on 2022/10/19 05:29
linux-4.14 possible deadlock in map_mft_record ntfs C 5 382d 476d 0/1 upstream: reported C repro on 2022/11/15 01:41
linux-4.19 possible deadlock in map_mft_record ntfs C error 11 401d 512d 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
5.15.136-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.1/11843 is trying to acquire lock:
ffff88808fcf6490 (&ni->mrec_lock){+.+.}-{3:3}, at: map_mft_record+0x4a/0x850 fs/ntfs/mft.c:154

but task is already holding lock:
ffff88808fcf6400 (&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+0x1db/0x4f0 kernel/locking/lockdep.c:5622
       down_read+0x45/0x2e0 kernel/locking/rwsem.c:1488
       ntfs_read_block fs/ntfs/aops.c:248 [inline]
       ntfs_readpage+0x123e/0x2210 fs/ntfs/aops.c:435
       do_read_cache_page+0x752/0x1040
       read_mapping_page include/linux/pagemap.h:515 [inline]
       ntfs_map_page+0x25/0x390 fs/ntfs/aops.h:75
       ntfs_sync_mft_mirror+0x253/0x19e0 fs/ntfs/mft.c:480
       write_mft_record_nolock+0x1164/0x16c0 fs/ntfs/mft.c:787
       write_mft_record fs/ntfs/mft.h:95 [inline]
       __ntfs_write_inode+0x7b4/0xdd0 fs/ntfs/inode.c:3050
       write_inode fs/fs-writeback.c:1478 [inline]
       __writeback_single_inode+0x644/0xe30 fs/fs-writeback.c:1683
       writeback_sb_inodes+0xbf0/0x1a50 fs/fs-writeback.c:1908
       wb_writeback+0x451/0xc50 fs/fs-writeback.c:2082
       wb_do_writeback fs/fs-writeback.c:2225 [inline]
       wb_workfn+0x46c/0x1130 fs/fs-writeback.c:2266
       process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2310
       worker_thread+0xaca/0x1280 kernel/workqueue.c:2457
       kthread+0x3f6/0x4f0 kernel/kthread.c:319
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298

-> #0 (&ni->mrec_lock){+.+.}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3053 [inline]
       check_prevs_add kernel/locking/lockdep.c:3172 [inline]
       validate_chain+0x1646/0x58b0 kernel/locking/lockdep.c:3787
       __lock_acquire+0x1295/0x1ff0 kernel/locking/lockdep.c:5011
       lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5622
       __mutex_lock_common+0x1da/0x25a0 kernel/locking/mutex.c:596
       __mutex_lock kernel/locking/mutex.c:729 [inline]
       mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:743
       map_mft_record+0x4a/0x850 fs/ntfs/mft.c:154
       ntfs_map_runlist_nolock+0x44b/0x1770 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_readpage+0x1459/0x2210 fs/ntfs/aops.c:435
       read_pages+0x605/0x8e0 mm/readahead.c:145
       page_cache_ra_unbounded+0x7b0/0x930 mm/readahead.c:239
       page_cache_sync_readahead include/linux/pagemap.h:833 [inline]
       filemap_get_pages mm/filemap.c:2551 [inline]
       filemap_read+0x71c/0x2980 mm/filemap.c:2634
       __kernel_read+0x5ac/0xa60 fs/read_write.c:443
       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+0xa5d/0x1c00 security/integrity/ima/ima_crypto.c:573
       ima_collect_measurement+0x293/0x530 security/integrity/ima/ima_api.c:254
       process_measurement+0x1038/0x1d60 security/integrity/ima/ima_main.c:337
       ima_file_check+0xf3/0x180 security/integrity/ima/ima_main.c:519
       do_open fs/namei.c:3540 [inline]
       path_openat+0x2745/0x2f20 fs/namei.c:3672
       do_filp_open+0x21c/0x460 fs/namei.c:3699
       do_sys_openat2+0x13b/0x500 fs/open.c:1211
       do_sys_open fs/open.c:1227 [inline]
       __do_sys_openat fs/open.c:1243 [inline]
       __se_sys_openat fs/open.c:1238 [inline]
       __x64_sys_openat+0x243/0x290 fs/open.c:1238
       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+0x61/0xcb

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/11843:
 #0: ffff88801e96df20 (&iint->mutex){+.+.}-{3:3}, at: process_measurement+0x733/0x1d60 security/integrity/ima/ima_main.c:260
 #1: ffff88808fcf6910 (mapping.invalidate_lock#4){.+.+}-{3:3}, at: filemap_invalidate_lock_shared include/linux/fs.h:842 [inline]
 #1: ffff88808fcf6910 (mapping.invalidate_lock#4){.+.+}-{3:3}, at: page_cache_ra_unbounded+0x1a6/0x930 mm/readahead.c:195
 #2: ffff88808fcf6400 (&rl->lock){++++}-{3:3}, at: ntfs_map_runlist+0x2a/0xa0 fs/ntfs/attrib.c:288

stack backtrace:
CPU: 1 PID: 11843 Comm: syz-executor.1 Not tainted 5.15.136-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/06/2023
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 check_noncircular+0x2f8/0x3b0 kernel/locking/lockdep.c:2133
 check_prev_add kernel/locking/lockdep.c:3053 [inline]
 check_prevs_add kernel/locking/lockdep.c:3172 [inline]
 validate_chain+0x1646/0x58b0 kernel/locking/lockdep.c:3787
 __lock_acquire+0x1295/0x1ff0 kernel/locking/lockdep.c:5011
 lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5622
 __mutex_lock_common+0x1da/0x25a0 kernel/locking/mutex.c:596
 __mutex_lock kernel/locking/mutex.c:729 [inline]
 mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:743
 map_mft_record+0x4a/0x850 fs/ntfs/mft.c:154
 ntfs_map_runlist_nolock+0x44b/0x1770 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_readpage+0x1459/0x2210 fs/ntfs/aops.c:435
 read_pages+0x605/0x8e0 mm/readahead.c:145
 page_cache_ra_unbounded+0x7b0/0x930 mm/readahead.c:239
 page_cache_sync_readahead include/linux/pagemap.h:833 [inline]
 filemap_get_pages mm/filemap.c:2551 [inline]
 filemap_read+0x71c/0x2980 mm/filemap.c:2634
 __kernel_read+0x5ac/0xa60 fs/read_write.c:443
 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+0xa5d/0x1c00 security/integrity/ima/ima_crypto.c:573
 ima_collect_measurement+0x293/0x530 security/integrity/ima/ima_api.c:254
 process_measurement+0x1038/0x1d60 security/integrity/ima/ima_main.c:337
 ima_file_check+0xf3/0x180 security/integrity/ima/ima_main.c:519
 do_open fs/namei.c:3540 [inline]
 path_openat+0x2745/0x2f20 fs/namei.c:3672
 do_filp_open+0x21c/0x460 fs/namei.c:3699
 do_sys_openat2+0x13b/0x500 fs/open.c:1211
 do_sys_open fs/open.c:1227 [inline]
 __do_sys_openat fs/open.c:1243 [inline]
 __se_sys_openat fs/open.c:1238 [inline]
 __x64_sys_openat+0x243/0x290 fs/open.c:1238
 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+0x61/0xcb
RIP: 0033:0x7f679f9ffae9
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:00007f679df810c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000101
RAX: ffffffffffffffda RBX: 00007f679fb1ef80 RCX: 00007f679f9ffae9
RDX: 0000000000141842 RSI: 0000000020000040 RDI: ffffffffffffff9c
RBP: 00007f679fa4b47a R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 000000000000000b R14: 00007f679fb1ef80 R15: 00007ffdb6792288
 </TASK>

Crashes (27):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/10/22 01:34 linux-5.15.y 00c03985402e 361b23dc .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in map_mft_record
2024/01/30 15:26 linux-5.15.y 6139f2a02fe0 7f400fcb .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in map_mft_record
2024/01/29 17:53 linux-5.15.y 6139f2a02fe0 991a98f4 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in map_mft_record
2024/01/26 18:45 linux-5.15.y 6139f2a02fe0 cc4a4020 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in map_mft_record
2024/01/25 18:21 linux-5.15.y ddcaf4999061 cc4a4020 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in map_mft_record
2024/01/24 11:46 linux-5.15.y ddcaf4999061 1e153dc8 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in map_mft_record
2023/12/30 00:46 linux-5.15.y d93fa2c78854 fb427a07 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in map_mft_record
2023/11/01 04:52 linux-5.15.y 12952a23a5da 69904c9f .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in map_mft_record
2023/10/30 13:37 linux-5.15.y 12952a23a5da b5729d82 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in map_mft_record
2023/09/18 06:39 linux-5.15.y aff03380bda4 0b6a67ac .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in map_mft_record
2023/07/07 19:48 linux-5.15.y d54cfc420586 668cb1fa .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in map_mft_record
2023/06/30 23:27 linux-5.15.y 4af60700a60c af3053d2 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in map_mft_record
2023/06/27 12:42 linux-5.15.y f67653019430 4cd5bb25 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in map_mft_record
2023/06/13 06:28 linux-5.15.y 7349e40704a0 749afb64 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in map_mft_record
2023/06/13 02:11 linux-5.15.y 7349e40704a0 aaed0183 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in map_mft_record
2023/06/12 22:02 linux-5.15.y 7349e40704a0 aaed0183 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in map_mft_record
2023/05/31 11:17 linux-5.15.y 0ab06468cbd1 09898419 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in map_mft_record
2023/05/25 21:37 linux-5.15.y 1fe619a7d252 0513b3e6 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in map_mft_record
2023/05/17 23:10 linux-5.15.y 9d6bde853685 3bb7af1d .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in map_mft_record
2023/05/16 10:29 linux-5.15.y b0ece631f84a 71b00cfb .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in map_mft_record
2023/04/05 16:55 linux-5.15.y d86dfc4d95cd 8b834965 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in map_mft_record
2023/04/05 02:51 linux-5.15.y c957cbb87315 831373d3 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in map_mft_record
2023/08/16 03:31 linux-5.15.y 24c4de4069cb 39990d51 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in map_mft_record
2023/08/13 08:48 linux-5.15.y 24c4de4069cb 39990d51 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in map_mft_record
2023/05/22 04:23 linux-5.15.y 9d6bde853685 4bce1a3e .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in map_mft_record
2023/04/13 22:46 linux-5.15.y 4fdad925aa1a 3cfcaa1b .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in map_mft_record
2023/03/17 18:37 linux-5.15.y 8020ae3c051d 7939252e .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in map_mft_record
* Struck through repros no longer work on HEAD.