syzbot


possible deadlock in map_mft_record

Status: upstream: reported C repro on 2022/10/09 19:52
Subsystems: ntfs
[Documentation on labels]
Reported-by: syzbot+780cf5325e371630f195@syzkaller.appspotmail.com
First crash: 773d, last: 662d
Fix bisection: failed (error log, bisect log)
  
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 235d 610d 0/3 auto-obsoleted due to no activity on 2024/07/09 13:58
linux-6.1 possible deadlock in map_mft_record (2) 1 68d 68d 0/3 upstream: reported on 2024/09/14 09:25
upstream possible deadlock in map_mft_record ntfs3 C error done 845 295d 764d 25/28 fixed on 2024/03/20 11:33
linux-4.14 possible deadlock in map_mft_record ntfs C 5 643d 737d 0/1 upstream: reported C repro on 2022/11/15 01:41
upstream possible deadlock in map_mft_record (2) fs 1 230d 226d 0/28 auto-obsoleted due to no activity on 2024/07/04 04:55
linux-5.15 possible deadlock in map_mft_record 36 34d 615d 0/3 upstream: reported on 2023/03/17 18:38

Sample crash report:
IPVS: ftp: loaded support on port[0] = 21
ntfs: volume version 3.1.
======================================================
WARNING: possible circular locking dependency detected
4.19.211-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor339/8134 is trying to acquire lock:
00000000e032c785 (&lcnbmp_mrec_lock_key){+.+.}, at: map_mft_record+0x3c/0xc70 fs/ntfs/mft.c:168

but task is already holding lock:
000000008e8ded6c (&vol->lcnbmp_lock){+.+.}, at: ntfs_put_super+0x398/0x16f0 fs/ntfs/super.c:2295

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&vol->lcnbmp_lock){+.+.}:
       __ntfs_cluster_free+0x129/0xbd0 fs/ntfs/lcnalloc.c:876
       ntfs_cluster_free fs/ntfs/lcnalloc.h:110 [inline]
       ntfs_truncate+0x157c/0x2820 fs/ntfs/inode.c:2707
       ntfs_truncate_vfs fs/ntfs/inode.c:2875 [inline]
       ntfs_setattr+0x1b6/0x620 fs/ntfs/inode.c:2925
       notify_change+0x70b/0xfc0 fs/attr.c:334
       do_truncate+0x134/0x1f0 fs/open.c:63
       handle_truncate fs/namei.c:3009 [inline]
       do_last fs/namei.c:3427 [inline]
       path_openat+0x2308/0x2df0 fs/namei.c:3537
       do_file_open_root+0x265/0x4f0 fs/namei.c:3595
       file_open_root+0x279/0x390 fs/open.c:1066
       do_handle_open+0x368/0x650 fs/fhandle.c:232
       do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
       entry_SYSCALL_64_after_hwframe+0x49/0xbe

-> #0 (&lcnbmp_mrec_lock_key){+.+.}:
       __mutex_lock_common kernel/locking/mutex.c:937 [inline]
       __mutex_lock+0xd7/0x1190 kernel/locking/mutex.c:1078
       map_mft_record+0x3c/0xc70 fs/ntfs/mft.c:168
       __ntfs_write_inode+0xa4/0xe10 fs/ntfs/inode.c:2992
       ntfs_commit_inode fs/ntfs/inode.h:315 [inline]
       ntfs_put_super+0x117b/0x16f0 fs/ntfs/super.c:2296
       generic_shutdown_super+0x144/0x370 fs/super.c:456
       kill_block_super+0x97/0xf0 fs/super.c:1185
       deactivate_locked_super+0x94/0x160 fs/super.c:329
       deactivate_super+0x174/0x1a0 fs/super.c:360
       cleanup_mnt+0x1a8/0x290 fs/namespace.c:1098
       task_work_run+0x148/0x1c0 kernel/task_work.c:113
       exit_task_work include/linux/task_work.h:22 [inline]
       do_exit+0xbf3/0x2be0 kernel/exit.c:870
       do_group_exit+0x125/0x310 kernel/exit.c:967
       __do_sys_exit_group kernel/exit.c:978 [inline]
       __se_sys_exit_group kernel/exit.c:976 [inline]
       __x64_sys_exit_group+0x3a/0x50 kernel/exit.c:976
       do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
       entry_SYSCALL_64_after_hwframe+0x49/0xbe

other info that might help us debug this:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&vol->lcnbmp_lock);
                               lock(&lcnbmp_mrec_lock_key);
                               lock(&vol->lcnbmp_lock);
  lock(&lcnbmp_mrec_lock_key);

 *** DEADLOCK ***

2 locks held by syz-executor339/8134:
 #0: 00000000fcff927b (&type->s_umount_key#47){+.+.}, at: deactivate_super+0x16c/0x1a0 fs/super.c:359
 #1: 000000008e8ded6c (&vol->lcnbmp_lock){+.+.}, at: ntfs_put_super+0x398/0x16f0 fs/ntfs/super.c:2295

stack backtrace:
CPU: 0 PID: 8134 Comm: syz-executor339 Not tainted 4.19.211-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x1fc/0x2ef lib/dump_stack.c:118
 print_circular_bug.constprop.0.cold+0x2d7/0x41e kernel/locking/lockdep.c:1222
 check_prev_add kernel/locking/lockdep.c:1866 [inline]
 check_prevs_add kernel/locking/lockdep.c:1979 [inline]
 validate_chain kernel/locking/lockdep.c:2420 [inline]
 __lock_acquire+0x30c9/0x3ff0 kernel/locking/lockdep.c:3416
 lock_acquire+0x170/0x3c0 kernel/locking/lockdep.c:3908
 __mutex_lock_common kernel/locking/mutex.c:937 [inline]
 __mutex_lock+0xd7/0x1190 kernel/locking/mutex.c:1078
 map_mft_record+0x3c/0xc70 fs/ntfs/mft.c:168
 __ntfs_write_inode+0xa4/0xe10 fs/ntfs/inode.c:2992
 ntfs_commit_inode fs/ntfs/inode.h:315 [inline]
 ntfs_put_super+0x117b/0x16f0 fs/ntfs/super.c:2296
 generic_shutdown_super+0x144/0x370 fs/super.c:456
 kill_block_super+0x97/0xf0 fs/super.c:1185
 deactivate_locked_super+0x94/0x160 fs/super.c:329
 deactivate_super+0x174/0x1a0 fs/super.c:360
 cleanup_mnt+0x1a8/0x290 fs/namespace.c:1098
 task_work_run+0x148/0x1c0 kernel/task_work.c:113
 exit_task_work include/linux/task_work.h:22 [inline]
 do_exit+0xbf3/0x2be0 kernel/exit.c:870
 do_group_exit+0x125/0x310 kernel/exit.c:967
 __do_sys_exit_group kernel/exit.c:978 [inline]
 __se_sys_exit_group kernel/exit.c:976 [inline]
 __x64_sys_exit_group+0x3a/0x50 kernel/exit.c:976
 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x7ff633870a49
Code: Bad RIP value.
RSP: 002b:00007ffc6b2983d8 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 00007ff633905330 RCX: 00007ff633870a49
RDX: 000000000000003c RSI: 00000000000000e7 RDI: 0000000000000001
RBP: 0000000000000001 R08: f

Crashes (11):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/01/12 20:05 linux-4.19.y 3f8a27f9e27b 96166539 .config console log report syz C [disk image] [vmlinux] [mounted in repro] ci2-linux-4-19 possible deadlock in map_mft_record
2023/01/29 07:58 linux-4.19.y 3f8a27f9e27b 9dfcf09c .config console log report info [disk image] [vmlinux] ci2-linux-4-19 possible deadlock in map_mft_record
2023/01/09 01:51 linux-4.19.y 3f8a27f9e27b 1dac8c7a .config console log report info [disk image] [vmlinux] ci2-linux-4-19 possible deadlock in map_mft_record
2022/12/30 08:39 linux-4.19.y 3f8a27f9e27b 44712fbc .config console log report info [disk image] [vmlinux] ci2-linux-4-19 possible deadlock in map_mft_record
2022/12/03 05:56 linux-4.19.y 3f8a27f9e27b e080de16 .config console log report info [disk image] [vmlinux] ci2-linux-4-19 possible deadlock in map_mft_record
2022/12/02 04:11 linux-4.19.y 3f8a27f9e27b e080de16 .config console log report info [disk image] [vmlinux] ci2-linux-4-19 possible deadlock in map_mft_record
2022/12/01 15:39 linux-4.19.y 3f8a27f9e27b 4c2a66e8 .config console log report info [disk image] [vmlinux] ci2-linux-4-19 possible deadlock in map_mft_record
2022/11/08 14:22 linux-4.19.y 3f8a27f9e27b 060f945e .config console log report info [disk image] [vmlinux] ci2-linux-4-19 possible deadlock in map_mft_record
2022/11/02 17:44 linux-4.19.y 3f8a27f9e27b 08977f5d .config console log report info [disk image] [vmlinux] ci2-linux-4-19 possible deadlock in map_mft_record
2022/11/01 22:40 linux-4.19.y 3f8a27f9e27b 08977f5d .config console log report info [disk image] [vmlinux] ci2-linux-4-19 possible deadlock in map_mft_record
2022/10/09 19:51 linux-4.19.y 3f8a27f9e27b aea5da89 .config console log report info [disk image] [vmlinux] ci2-linux-4-19 possible deadlock in map_mft_record
* Struck through repros no longer work on HEAD.