syzbot


possible deadlock in ntfs_mark_rec_free

Status: auto-obsoleted due to no activity on 2024/01/25 16:19
Reported-by: syzbot+927df0cad3dbce5d7246@syzkaller.appspotmail.com
First crash: 608d, last: 400d
Similar bugs (5)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in ntfs_mark_rec_free ntfs3 826 329d 688d 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 45d 205d 0/28 upstream: reported C repro on 2024/04/30 03:29
linux-6.1 possible deadlock in ntfs_mark_rec_free (2) 12 185d 188d 0/3 auto-obsoleted due to no activity on 2024/07/29 08:57
linux-6.1 possible deadlock in ntfs_mark_rec_free (3) 4 15d 18d 0/3 upstream: reported on 2024/11/03 15:28
linux-5.15 possible deadlock in ntfs_mark_rec_free origin:upstream C error 22 33d 188d 0/3 upstream: reported C repro on 2024/05/17 04:58

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

but task is already holding lock:
ffff88808aa14360 (&ni->ni_lock){+.+.}-{3:3}, at: ni_trylock fs/ntfs3/ntfs_fs.h:1126 [inline]
ffff88808aa14360 (&ni->ni_lock){+.+.}-{3:3}, at: ni_write_inode+0x151/0x1240 fs/ntfs3/frecord.c:3246

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:5661
       __mutex_lock_common kernel/locking/mutex.c:603 [inline]
       __mutex_lock+0x132/0xd80 kernel/locking/mutex.c:747
       ntfs_set_state+0x217/0x6f0 fs/ntfs3/fsntfs.c:920
       attr_set_size+0x32e5/0x42f0 fs/ntfs3/attrib.c:880
       ntfs_extend_mft+0x2f6/0x4b0 fs/ntfs3/fsntfs.c:498
       ntfs_look_free_mft+0x439/0x10c0 fs/ntfs3/fsntfs.c:561
       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+0x354/0x900 fs/ntfs3/frecord.c:1141
       ni_insert_resident+0xf4/0x3c0 fs/ntfs3/frecord.c:1525
       ntfs_set_ea+0xab8/0x1660 fs/ntfs3/xattr.c:434
       ntfs_save_wsl_perm+0x139/0x490 fs/ntfs3/xattr.c:965
       ntfs3_setattr+0x961/0xb70 fs/ntfs3/file.c:817
       notify_change+0xce3/0xfc0 fs/attr.c:499
       chown_common+0x5aa/0x900 fs/open.c:736
       do_fchownat+0x169/0x240 fs/open.c:767
       __do_sys_lchown fs/open.c:792 [inline]
       __se_sys_lchown fs/open.c:790 [inline]
       __x64_sys_lchown+0x81/0x90 fs/open.c:790
       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

-> #1 (&ni->file.run_lock#2){++++}-{3:3}:
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5661
       down_write+0x36/0x60 kernel/locking/rwsem.c:1573
       ntfs_extend_mft+0x15c/0x4b0 fs/ntfs3/fsntfs.c:482
       ntfs_look_free_mft+0x439/0x10c0 fs/ntfs3/fsntfs.c:561
       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+0x354/0x900 fs/ntfs3/frecord.c:1141
       ni_insert_resident+0xf4/0x3c0 fs/ntfs3/frecord.c:1525
       ntfs_set_ea+0xab8/0x1660 fs/ntfs3/xattr.c:434
       ntfs_save_wsl_perm+0x139/0x490 fs/ntfs3/xattr.c:965
       ntfs3_setattr+0x961/0xb70 fs/ntfs3/file.c:817
       notify_change+0xce3/0xfc0 fs/attr.c:499
       chown_common+0x5aa/0x900 fs/open.c:736
       do_fchownat+0x169/0x240 fs/open.c:767
       __do_sys_lchown fs/open.c:792 [inline]
       __se_sys_lchown fs/open.c:790 [inline]
       __x64_sys_lchown+0x81/0x90 fs/open.c:790
       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

-> #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+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
       down_write_nested+0x39/0x60 kernel/locking/rwsem.c:1689
       ntfs_mark_rec_free+0x3b/0x2b0 fs/ntfs3/fsntfs.c:713
       ni_write_inode+0x433/0x1240 fs/ntfs3/frecord.c:3338
       write_inode fs/fs-writeback.c:1443 [inline]
       __writeback_single_inode+0x67d/0x11e0 fs/fs-writeback.c:1655
       writeback_sb_inodes+0xc21/0x1ac0 fs/fs-writeback.c:1881
       wb_writeback+0x49d/0xe10 fs/fs-writeback.c:2055
       wb_do_writeback fs/fs-writeback.c:2198 [inline]
       wb_workfn+0x427/0x1020 fs/fs-writeback.c:2238
       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

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:0/9:
 #0: ffff8881426ee938 ((wq_completion)writeback){+.+.}-{0:0}, at: process_one_work+0x7a9/0x11d0 kernel/workqueue.c:2267
 #1: ffffc900000e7d20 ((work_completion)(&(&wb->dwork)->work)){+.+.}-{0:0}, at: process_one_work+0x7a9/0x11d0 kernel/workqueue.c:2267
 #2: ffff88808aa14360 (&ni->ni_lock){+.+.}-{3:3}, at: ni_trylock fs/ntfs3/ntfs_fs.h:1126 [inline]
 #2: ffff88808aa14360 (&ni->ni_lock){+.+.}-{3:3}, at: ni_write_inode+0x151/0x1240 fs/ntfs3/frecord.c:3246

stack backtrace:
CPU: 1 PID: 9 Comm: kworker/u4:0 Not tainted 6.1.58-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/06/2023
Workqueue: writeback wb_workfn (flush-7:5)
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
 down_write_nested+0x39/0x60 kernel/locking/rwsem.c:1689
 ntfs_mark_rec_free+0x3b/0x2b0 fs/ntfs3/fsntfs.c:713
 ni_write_inode+0x433/0x1240 fs/ntfs3/frecord.c:3338
 write_inode fs/fs-writeback.c:1443 [inline]
 __writeback_single_inode+0x67d/0x11e0 fs/fs-writeback.c:1655
 writeback_sb_inodes+0xc21/0x1ac0 fs/fs-writeback.c:1881
 wb_writeback+0x49d/0xe10 fs/fs-writeback.c:2055
 wb_do_writeback fs/fs-writeback.c:2198 [inline]
 wb_workfn+0x427/0x1020 fs/fs-writeback.c:2238
 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
 </TASK>

Crashes (16):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/10/17 16:18 linux-6.1.y adc4d740ad9e 342b9c55 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in ntfs_mark_rec_free
2023/08/24 13:55 linux-6.1.y 802aacbbffe2 4d7ae7ab .config console log report info ci2-linux-6-1-kasan possible deadlock in ntfs_mark_rec_free
2023/08/07 19:29 linux-6.1.y 52a953d0934b b1b6ae3d .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in ntfs_mark_rec_free
2023/08/04 23:00 linux-6.1.y 52a953d0934b cdae481e .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in ntfs_mark_rec_free
2023/08/03 07:30 linux-6.1.y d2a6dc4eaf6d 39a91c18 .config console log report info ci2-linux-6-1-kasan possible deadlock in ntfs_mark_rec_free
2023/08/01 16:33 linux-6.1.y d2a6dc4eaf6d df07ffe8 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in ntfs_mark_rec_free
2023/07/26 21:46 linux-6.1.y 5302e81aa209 41fe1bae .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in ntfs_mark_rec_free
2023/07/25 12:56 linux-6.1.y 5302e81aa209 3b91ad04 .config console log report info ci2-linux-6-1-kasan possible deadlock in ntfs_mark_rec_free
2023/07/17 21:00 linux-6.1.y 61fd484b2cf6 20f8b3c2 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in ntfs_mark_rec_free
2023/06/29 02:56 linux-6.1.y a1c449d00ff8 ca69c785 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in ntfs_mark_rec_free
2023/06/19 21:06 linux-6.1.y ca87e77a2ef8 d521bc56 .config console log report info ci2-linux-6-1-kasan possible deadlock in ntfs_mark_rec_free
2023/05/12 05:11 linux-6.1.y bf4ad6fa4e53 adb9a3cd .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in ntfs_mark_rec_free
2023/05/05 07:04 linux-6.1.y ca48fc16c493 518a39a6 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in ntfs_mark_rec_free
2023/03/28 18:49 linux-6.1.y e3a87a10f259 fc067f05 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in ntfs_mark_rec_free
2023/03/23 23:58 linux-6.1.y e3a87a10f259 f94b4a29 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in ntfs_mark_rec_free
2023/03/30 15:56 linux-6.1.y 3b29299e5f60 f325deb0 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in ntfs_mark_rec_free
* Struck through repros no longer work on HEAD.