syzbot


possible deadlock in ntfs_mark_rec_free (3)

Status: upstream: reported on 2024/11/03 15:28
Reported-by: syzbot+e466ce8331cbbe132a72@syzkaller.appspotmail.com
First crash: 20d, last: 18d
Similar bugs (5)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-6.1 possible deadlock in ntfs_mark_rec_free 16 403d 611d 0/3 auto-obsoleted due to no activity on 2024/01/25 16:19
upstream possible deadlock in ntfs_mark_rec_free ntfs3 826 332d 690d 0/28 auto-obsoleted due to no activity on 2024/03/07 08:53
upstream possible deadlock in ntfs_mark_rec_free (2) ntfs3 C done done 88 48d 208d 0/28 upstream: reported C repro on 2024/04/30 03:29
linux-6.1 possible deadlock in ntfs_mark_rec_free (2) 12 188d 191d 0/3 auto-obsoleted due to no activity on 2024/07/29 08:57
linux-5.15 possible deadlock in ntfs_mark_rec_free origin:upstream C error 22 36d 191d 0/3 upstream: reported C repro on 2024/05/17 04:58

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.1.115-syzkaller #0 Not tainted
------------------------------------------------------
kworker/u4:5/4291 is trying to acquire lock:
ffff88807c030120 (&wnd->rw_lock/1){+.+.}-{3:3}, at: ntfs_mark_rec_free+0x3b/0x2b0 fs/ntfs3/fsntfs.c:713

but task is already holding lock:
ffff88805bea0fc0 (&ni->ni_lock){+.+.}-{3:3}, at: ni_trylock fs/ntfs3/ntfs_fs.h:1116 [inline]
ffff88805bea0fc0 (&ni->ni_lock){+.+.}-{3:3}, at: ni_write_inode+0x16b/0x1070 fs/ntfs3/frecord.c:3318

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&ni->ni_lock){+.+.}-{3:3}:
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
       __mutex_lock_common kernel/locking/mutex.c:603 [inline]
       __mutex_lock+0x132/0xd80 kernel/locking/mutex.c:747
       ntfs_set_state+0x1fa/0x660 fs/ntfs3/fsntfs.c:920
       attr_set_size+0x330d/0x4310 fs/ntfs3/attrib.c:884
       ntfs_extend_mft+0x2f2/0x4a0 fs/ntfs3/fsntfs.c:498
       ntfs_look_free_mft+0x778/0x10c0 fs/ntfs3/fsntfs.c:680
       ni_create_attr_list+0x9b6/0x1470 fs/ntfs3/frecord.c:873
       ni_ins_attr_ext+0x330/0xbf0 fs/ntfs3/frecord.c:974
       ni_insert_attr fs/ntfs3/frecord.c:1141 [inline]
       ni_insert_resident fs/ntfs3/frecord.c:1525 [inline]
       ni_add_name+0x619/0xc30 fs/ntfs3/frecord.c:3103
       ni_rename+0xbe/0x1e0 fs/ntfs3/frecord.c:3143
       ntfs_rename+0x74a/0xd10 fs/ntfs3/namei.c:318
       vfs_rename+0xd32/0x10f0 fs/namei.c:4874
       do_renameat2+0xde0/0x1440 fs/namei.c:5027
       __do_sys_renameat2 fs/namei.c:5060 [inline]
       __se_sys_renameat2 fs/namei.c:5057 [inline]
       __x64_sys_renameat2+0xce/0xe0 fs/namei.c:5057
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

-> #1 (&ni->file.run_lock#2){++++}-{3:3}:
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
       down_write+0x36/0x60 kernel/locking/rwsem.c:1573
       ntfs_extend_mft+0x15c/0x4a0 fs/ntfs3/fsntfs.c:482
       ntfs_look_free_mft+0x778/0x10c0 fs/ntfs3/fsntfs.c:680
       ni_create_attr_list+0x9b6/0x1470 fs/ntfs3/frecord.c:873
       ni_ins_attr_ext+0x330/0xbf0 fs/ntfs3/frecord.c:974
       ni_insert_attr fs/ntfs3/frecord.c:1141 [inline]
       ni_insert_resident fs/ntfs3/frecord.c:1525 [inline]
       ni_add_name+0x619/0xc30 fs/ntfs3/frecord.c:3103
       ni_rename+0xbe/0x1e0 fs/ntfs3/frecord.c:3143
       ntfs_rename+0x74a/0xd10 fs/ntfs3/namei.c:318
       vfs_rename+0xd32/0x10f0 fs/namei.c:4874
       do_renameat2+0xde0/0x1440 fs/namei.c:5027
       __do_sys_renameat2 fs/namei.c:5060 [inline]
       __se_sys_renameat2 fs/namei.c:5057 [inline]
       __x64_sys_renameat2+0xce/0xe0 fs/namei.c:5057
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

-> #0 (&wnd->rw_lock/1){+.+.}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3090 [inline]
       check_prevs_add kernel/locking/lockdep.c:3209 [inline]
       validate_chain+0x1661/0x5950 kernel/locking/lockdep.c:3825
       __lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5049
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
       down_write_nested+0x39/0x60 kernel/locking/rwsem.c:1689
       ntfs_mark_rec_free+0x3b/0x2b0 fs/ntfs3/fsntfs.c:713
       ni_write_inode+0x506/0x1070 fs/ntfs3/frecord.c:3413
       write_inode fs/fs-writeback.c:1460 [inline]
       __writeback_single_inode+0x67d/0x11e0 fs/fs-writeback.c:1677
       writeback_sb_inodes+0xc2b/0x1b20 fs/fs-writeback.c:1903
       wb_writeback+0x49d/0xe10 fs/fs-writeback.c:2077
       wb_do_writeback fs/fs-writeback.c:2220 [inline]
       wb_workfn+0x427/0x1020 fs/fs-writeback.c:2260
       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:295

other info that might help us debug this:

Chain exists of:
  &wnd->rw_lock/1 --> &ni->file.run_lock#2 --> &ni->ni_lock

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&ni->ni_lock);
                               lock(&ni->file.run_lock#2);
                               lock(&ni->ni_lock);
  lock(&wnd->rw_lock/1);

 *** DEADLOCK ***

3 locks held by kworker/u4:5/4291:
 #0: ffff888143eea138 ((wq_completion)writeback){+.+.}-{0:0}, at: process_one_work+0x7a9/0x11d0 kernel/workqueue.c:2267
 #1: ffffc9000429fd20 ((work_completion)(&(&wb->dwork)->work)){+.+.}-{0:0}, at: process_one_work+0x7a9/0x11d0 kernel/workqueue.c:2267
 #2: ffff88805bea0fc0 (&ni->ni_lock){+.+.}-{3:3}, at: ni_trylock fs/ntfs3/ntfs_fs.h:1116 [inline]
 #2: ffff88805bea0fc0 (&ni->ni_lock){+.+.}-{3:3}, at: ni_write_inode+0x16b/0x1070 fs/ntfs3/frecord.c:3318

stack backtrace:
CPU: 0 PID: 4291 Comm: kworker/u4:5 Not tainted 6.1.115-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
Workqueue: writeback wb_workfn (flush-7:0)
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+0x1661/0x5950 kernel/locking/lockdep.c:3825
 __lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5049
 lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
 down_write_nested+0x39/0x60 kernel/locking/rwsem.c:1689
 ntfs_mark_rec_free+0x3b/0x2b0 fs/ntfs3/fsntfs.c:713
 ni_write_inode+0x506/0x1070 fs/ntfs3/frecord.c:3413
 write_inode fs/fs-writeback.c:1460 [inline]
 __writeback_single_inode+0x67d/0x11e0 fs/fs-writeback.c:1677
 writeback_sb_inodes+0xc2b/0x1b20 fs/fs-writeback.c:1903
 wb_writeback+0x49d/0xe10 fs/fs-writeback.c:2077
 wb_do_writeback fs/fs-writeback.c:2220 [inline]
 wb_workfn+0x427/0x1020 fs/fs-writeback.c:2260
 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:295
 </TASK>

Crashes (4):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/11/06 04:06 linux-6.1.y 7c15117f9468 3a465482 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in ntfs_mark_rec_free
2024/11/06 04:06 linux-6.1.y 7c15117f9468 3a465482 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in ntfs_mark_rec_free
2024/11/04 04:13 linux-6.1.y 7c15117f9468 f00eed24 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in ntfs_mark_rec_free
2024/11/03 15:27 linux-6.1.y 7c15117f9468 f00eed24 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in ntfs_mark_rec_free
* Struck through repros no longer work on HEAD.