syzbot


possible deadlock in map_mft_record

Status: upstream: reported C repro on 2022/11/15 01:41
Subsystems: ntfs
[Documentation on labels]
Reported-by: syzbot+50dde734aa62ec2523d3@syzkaller.appspotmail.com
First crash: 474d, last: 380d
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 51d 347d 0/3 upstream: reported on 2023/03/21 20:17
upstream possible deadlock in map_mft_record ntfs3 C error 845 32d 501d 0/26 upstream: reported C repro on 2022/10/19 05:29
linux-5.15 possible deadlock in map_mft_record 27 32d 351d 0/3 upstream: reported on 2023/03/17 18:38
linux-4.19 possible deadlock in map_mft_record ntfs C error 11 399d 510d 0/1 upstream: reported C repro on 2022/10/09 19:52
Fix bisection attempts (1)
Created Duration User Patch Repo Result
2023/02/17 00:02 36m bisect fix linux-4.14.y job log (0) log

Sample crash report:
IPVS: ftp: loaded support on port[0] = 21
ntfs: volume version 3.1.
======================================================
WARNING: possible circular locking dependency detected
4.14.302-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor207/7976 is trying to acquire lock:
 (&lcnbmp_mrec_lock_key){+.+.}, at: [<ffffffff8213da7b>] map_mft_record+0x2b/0xbe0 fs/ntfs/mft.c:166

but task is already holding lock:
 (&vol->lcnbmp_lock){+.+.}, at: [<ffffffff8215a4e1>] ntfs_put_super+0x311/0x14d0 fs/ntfs/super.c:2296

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&vol->lcnbmp_lock){+.+.}:
       down_write+0x34/0x90 kernel/locking/rwsem.c:54
       __ntfs_cluster_free+0xff/0xa80 fs/ntfs/lcnalloc.c:876
       ntfs_cluster_free fs/ntfs/lcnalloc.h:110 [inline]
       ntfs_truncate+0x10b7/0x22d0 fs/ntfs/inode.c:2727
       ntfs_truncate_vfs fs/ntfs/inode.c:2895 [inline]
       ntfs_setattr+0x148/0x580 fs/ntfs/inode.c:2945
       notify_change+0x56b/0xd10 fs/attr.c:315
       do_truncate+0xff/0x1a0 fs/open.c:63
       handle_truncate fs/namei.c:3010 [inline]
       do_last fs/namei.c:3437 [inline]
       path_openat+0x1dcc/0x2970 fs/namei.c:3571
       do_file_open_root+0x224/0x490 fs/namei.c:3633
       file_open_root+0x1e7/0x2a0 fs/open.c:1042
       do_handle_open+0x2a2/0x570 fs/fhandle.c:233
       do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
       entry_SYSCALL_64_after_hwframe+0x5e/0xd3

-> #0 (&lcnbmp_mrec_lock_key){+.+.}:
       lock_acquire+0x170/0x3f0 kernel/locking/lockdep.c:3998
       __mutex_lock_common kernel/locking/mutex.c:756 [inline]
       __mutex_lock+0xc4/0x1310 kernel/locking/mutex.c:893
       map_mft_record+0x2b/0xbe0 fs/ntfs/mft.c:166
       __ntfs_write_inode+0x97/0xcc0 fs/ntfs/inode.c:3012
       ntfs_commit_inode fs/ntfs/inode.h:315 [inline]
       ntfs_put_super+0xf81/0x14d0 fs/ntfs/super.c:2297
       generic_shutdown_super+0x144/0x370 fs/super.c:446
       kill_block_super+0x95/0xe0 fs/super.c:1161
       deactivate_locked_super+0x6c/0xd0 fs/super.c:319
       deactivate_super+0x7f/0xa0 fs/super.c:350
       cleanup_mnt+0x186/0x2c0 fs/namespace.c:1183
       task_work_run+0x11f/0x190 kernel/task_work.c:113
       exit_task_work include/linux/task_work.h:22 [inline]
       do_exit+0xa44/0x2850 kernel/exit.c:868
       do_group_exit+0x100/0x2e0 kernel/exit.c:965
       SYSC_exit_group kernel/exit.c:976 [inline]
       SyS_exit_group+0x19/0x20 kernel/exit.c:974
       do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
       entry_SYSCALL_64_after_hwframe+0x5e/0xd3

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-executor207/7976:
 #0:  (&type->s_umount_key#47){+.+.}, at: [<ffffffff818785b7>] deactivate_super+0x77/0xa0 fs/super.c:349
 #1:  (&vol->lcnbmp_lock){+.+.}, at: [<ffffffff8215a4e1>] ntfs_put_super+0x311/0x14d0 fs/ntfs/super.c:2296

stack backtrace:
CPU: 1 PID: 7976 Comm: syz-executor207 Not tainted 4.14.302-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
Call Trace:
 __dump_stack lib/dump_stack.c:17 [inline]
 dump_stack+0x1b2/0x281 lib/dump_stack.c:58
 print_circular_bug.constprop.0.cold+0x2d7/0x41e kernel/locking/lockdep.c:1258
 check_prev_add kernel/locking/lockdep.c:1905 [inline]
 check_prevs_add kernel/locking/lockdep.c:2022 [inline]
 validate_chain kernel/locking/lockdep.c:2464 [inline]
 __lock_acquire+0x2e0e/0x3f20 kernel/locking/lockdep.c:3491
 lock_acquire+0x170/0x3f0 kernel/locking/lockdep.c:3998
 __mutex_lock_common kernel/locking/mutex.c:756 [inline]
 __mutex_lock+0xc4/0x1310 kernel/locking/mutex.c:893
 map_mft_record+0x2b/0xbe0 fs/ntfs/mft.c:166
 __ntfs_write_inode+0x97/0xcc0 fs/ntfs/inode.c:3012
 ntfs_commit_inode fs/ntfs/inode.h:315 [inline]
 ntfs_put_super+0xf81/0x14d0 fs/ntfs/super.c:2297
 generic_shutdown_super+0x144/0x370 fs/super.c:446
 kill_block_super+0x95/0xe0 fs/super.c:1161
 deactivate_locked_super+0x6c/0xd0 fs/super.c:319
 deactivate_super+0x7f/0xa0 fs/super.c:350
 cleanup_mnt+0x186/0x2c0 fs/namespace.c:1183
 task_work_run+0x11f/0x190 kernel/task_work.c:113
 exit_task_work include/linux/task_work.h:22 [inline]
 do_exit+0xa44/0x2850 kernel/exit.c:868
 do_group_exit+0x100/0x2e0 kernel/exit.c:965
 SYSC_exit_group kernel/exit.c:976 [inline]
 SyS_exit_group+0x19/0x20 kernel/exit.c:974
 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x5e/0xd3
RIP: 0033:0x7fa10da72a49
RSP: 002b:00007ffd05b00f48 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 00007

Crashes (5):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/01/08 03:26 linux-4.14.y c4215ee4771b 1dac8c7a .config console log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-linux-4-14 possible deadlock in map_mft_record
2023/01/17 23:45 linux-4.14.y c4215ee4771b 42660d9e .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-4-14 possible deadlock in map_mft_record
2022/12/13 23:01 linux-4.14.y 65afe34ac33d f6511626 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-4-14 possible deadlock in map_mft_record
2022/12/08 05:47 linux-4.14.y 179ef7fe8677 d88f3abb .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-4-14 possible deadlock in map_mft_record
2022/11/15 01:41 linux-4.14.y e911713e40ca 97de9cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-4-14 possible deadlock in map_mft_record
* Struck through repros no longer work on HEAD.