syzbot


possible deadlock in ntfs_mark_rec_free

Status: upstream: reported C repro on 2024/05/17 04:58
Bug presence: origin:upstream
[Documentation on labels]
Reported-by: syzbot+57c706683b7b059bd678@syzkaller.appspotmail.com
First crash: 151d, last: 3d20h
Fix bisection: failed (error log, bisect log)
  
Bug presence (1)
Date Name Commit Repro Result
2024/05/17 upstream (ToT) ea5f6ad9ad96 C [report] possible deadlock in ntfs_mark_rec_free
Similar bugs (4)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-6.1 possible deadlock in ntfs_mark_rec_free 16 364d 572d 0/3 auto-obsoleted due to no activity on 2024/01/25 16:19
upstream possible deadlock in ntfs_mark_rec_free ntfs3 826 292d 651d 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 88 9d03h 169d 0/28 upstream: reported C repro on 2024/04/30 03:29
linux-6.1 possible deadlock in ntfs_mark_rec_free (2) 12 148d 151d 0/3 auto-obsoleted due to no activity on 2024/07/29 08:57
Last patch testing requests (1)
Created Duration User Patch Repo Result
2024/10/12 05:33 14m retest repro linux-5.15.y report log

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
5.15.158-syzkaller #0 Not tainted
------------------------------------------------------
kworker/u4:3/304 is trying to acquire lock:
ffff0000c8a68120 (&wnd->rw_lock/1){+.+.}-{3:3}, at: ntfs_mark_rec_free+0x40/0x244 fs/ntfs3/fsntfs.c:711

but task is already holding lock:
ffff0000ded0efa0 (&ni->ni_lock){+.+.}-{3:3}, at: ni_trylock fs/ntfs3/ntfs_fs.h:1113 [inline]
ffff0000ded0efa0 (&ni->ni_lock){+.+.}-{3:3}, at: ni_write_inode+0x12c/0xe38 fs/ntfs3/frecord.c:3198

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&ni->ni_lock){+.+.}-{3:3}:
       __mutex_lock_common+0x194/0x2154 kernel/locking/mutex.c:596
       __mutex_lock kernel/locking/mutex.c:729 [inline]
       mutex_lock_nested+0xa4/0xf8 kernel/locking/mutex.c:743
       ntfs_set_state+0x1a4/0x584 fs/ntfs3/fsntfs.c:925
       mi_read+0x3e0/0x4d8 fs/ntfs3/record.c:185
       mi_format_new+0x174/0x514 fs/ntfs3/record.c:374
       ni_add_subrecord+0xd0/0x3c4 fs/ntfs3/frecord.c:370
       ntfs_look_free_mft+0x4c8/0xd0c fs/ntfs3/fsntfs.c:686
       ni_create_attr_list+0x764/0xf54 fs/ntfs3/frecord.c:848
       ni_ins_attr_ext+0x328/0x99c fs/ntfs3/frecord.c:949
       ni_insert_attr fs/ntfs3/frecord.c:1103 [inline]
       ni_insert_resident fs/ntfs3/frecord.c:1477 [inline]
       ni_add_name+0x544/0x818 fs/ntfs3/frecord.c:2983
       ni_rename+0xc8/0x1d8 fs/ntfs3/frecord.c:3023
       ntfs_rename+0x5c4/0xb10 fs/ntfs3/namei.c:318
       vfs_rename+0xac8/0xe04 fs/namei.c:4832
       do_renameat2+0xa00/0x10c0 fs/namei.c:4985
       __do_sys_renameat2 fs/namei.c:5018 [inline]
       __se_sys_renameat2 fs/namei.c:5015 [inline]
       __arm64_sys_renameat2+0xe0/0xfc fs/namei.c:5015
       __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
       invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
       el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
       do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
       el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:608
       el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:626
       el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

-> #0 (&wnd->rw_lock/1){+.+.}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3053 [inline]
       check_prevs_add kernel/locking/lockdep.c:3172 [inline]
       validate_chain kernel/locking/lockdep.c:3788 [inline]
       __lock_acquire+0x32d4/0x7638 kernel/locking/lockdep.c:5012
       lock_acquire+0x240/0x77c kernel/locking/lockdep.c:5623
       down_write_nested+0xc0/0x130 kernel/locking/rwsem.c:1667
       ntfs_mark_rec_free+0x40/0x244 fs/ntfs3/fsntfs.c:711
       ni_write_inode+0xb00/0xe38 fs/ntfs3/frecord.c:3293
       ntfs3_write_inode+0x70/0x98 fs/ntfs3/inode.c:1036
       write_inode fs/fs-writeback.c:1495 [inline]
       __writeback_single_inode+0x584/0x13a4 fs/fs-writeback.c:1705
       writeback_sb_inodes+0x94c/0x1654 fs/fs-writeback.c:1930
       wb_writeback+0x3fc/0xfc8 fs/fs-writeback.c:2104
       wb_do_writeback fs/fs-writeback.c:2247 [inline]
       wb_workfn+0x3a4/0x1070 fs/fs-writeback.c:2288
       process_one_work+0x790/0x11b8 kernel/workqueue.c:2310
       worker_thread+0x910/0x1034 kernel/workqueue.c:2457
       kthread+0x37c/0x45c kernel/kthread.c:334
       ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:870

other info that might help us debug this:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&ni->ni_lock);
                               lock(&wnd->rw_lock/1);
                               lock(&ni->ni_lock);
  lock(&wnd->rw_lock/1);

 *** DEADLOCK ***

3 locks held by kworker/u4:3/304:
 #0: ffff0000c21c8138 ((wq_completion)writeback){+.+.}-{0:0}, at: process_one_work+0x66c/0x11b8 kernel/workqueue.c:2283
 #1: ffff80001c977c00 ((work_completion)(&(&wb->dwork)->work)){+.+.}-{0:0}, at: process_one_work+0x6ac/0x11b8 kernel/workqueue.c:2285
 #2: ffff0000ded0efa0 (&ni->ni_lock){+.+.}-{3:3}, at: ni_trylock fs/ntfs3/ntfs_fs.h:1113 [inline]
 #2: ffff0000ded0efa0 (&ni->ni_lock){+.+.}-{3:3}, at: ni_write_inode+0x12c/0xe38 fs/ntfs3/frecord.c:3198

stack backtrace:
CPU: 1 PID: 304 Comm: kworker/u4:3 Not tainted 5.15.158-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024
Workqueue: writeback wb_workfn (flush-7:0)
Call trace:
 dump_backtrace+0x0/0x530 arch/arm64/kernel/stacktrace.c:152
 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:216
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x108/0x170 lib/dump_stack.c:106
 dump_stack+0x1c/0x58 lib/dump_stack.c:113
 print_circular_bug+0x150/0x1b8 kernel/locking/lockdep.c:2011
 check_noncircular+0x2cc/0x378 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 kernel/locking/lockdep.c:3788 [inline]
 __lock_acquire+0x32d4/0x7638 kernel/locking/lockdep.c:5012
 lock_acquire+0x240/0x77c kernel/locking/lockdep.c:5623
 down_write_nested+0xc0/0x130 kernel/locking/rwsem.c:1667
 ntfs_mark_rec_free+0x40/0x244 fs/ntfs3/fsntfs.c:711
 ni_write_inode+0xb00/0xe38 fs/ntfs3/frecord.c:3293
 ntfs3_write_inode+0x70/0x98 fs/ntfs3/inode.c:1036
 write_inode fs/fs-writeback.c:1495 [inline]
 __writeback_single_inode+0x584/0x13a4 fs/fs-writeback.c:1705
 writeback_sb_inodes+0x94c/0x1654 fs/fs-writeback.c:1930
 wb_writeback+0x3fc/0xfc8 fs/fs-writeback.c:2104
 wb_do_writeback fs/fs-writeback.c:2247 [inline]
 wb_workfn+0x3a4/0x1070 fs/fs-writeback.c:2288
 process_one_work+0x790/0x11b8 kernel/workqueue.c:2310
 worker_thread+0x910/0x1034 kernel/workqueue.c:2457
 kthread+0x37c/0x45c kernel/kthread.c:334
 ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:870

Crashes (18):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/05/17 06:37 linux-5.15.y 284087d4f7d5 c2e07261 .config console log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-linux-5-15-kasan-arm64 possible deadlock in ntfs_mark_rec_free
2024/10/12 08:05 linux-5.15.y 3a5928702e71 084d8178 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in ntfs_mark_rec_free
2024/05/21 14:25 linux-5.15.y 83655231580b 4c0d3ee3 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in ntfs_mark_rec_free
2024/05/21 07:42 linux-5.15.y 83655231580b 4c0d3ee3 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in ntfs_mark_rec_free
2024/05/21 07:41 linux-5.15.y 83655231580b 4c0d3ee3 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in ntfs_mark_rec_free
2024/05/21 07:40 linux-5.15.y 83655231580b 4c0d3ee3 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in ntfs_mark_rec_free
2024/05/21 07:40 linux-5.15.y 83655231580b 4c0d3ee3 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in ntfs_mark_rec_free
2024/05/21 07:40 linux-5.15.y 83655231580b 4c0d3ee3 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in ntfs_mark_rec_free
2024/05/21 07:40 linux-5.15.y 83655231580b 4c0d3ee3 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in ntfs_mark_rec_free
2024/05/20 09:02 linux-5.15.y 83655231580b c0f1611a .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in ntfs_mark_rec_free
2024/05/20 09:01 linux-5.15.y 83655231580b c0f1611a .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in ntfs_mark_rec_free
2024/05/20 09:01 linux-5.15.y 83655231580b c0f1611a .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in ntfs_mark_rec_free
2024/05/20 08:59 linux-5.15.y 83655231580b c0f1611a .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in ntfs_mark_rec_free
2024/05/20 08:59 linux-5.15.y 83655231580b c0f1611a .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in ntfs_mark_rec_free
2024/05/20 08:58 linux-5.15.y 83655231580b c0f1611a .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in ntfs_mark_rec_free
2024/05/20 08:56 linux-5.15.y 83655231580b c0f1611a .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in ntfs_mark_rec_free
2024/05/17 05:55 linux-5.15.y 284087d4f7d5 c2e07261 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in ntfs_mark_rec_free
2024/05/17 04:57 linux-5.15.y 284087d4f7d5 c2e07261 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in ntfs_mark_rec_free
* Struck through repros no longer work on HEAD.