syzbot


possible deadlock in bch2_journal_halt

Status: upstream: reported C repro on 2025/01/26 13:37
Subsystems: bcachefs
[Documentation on labels]
Reported-by: syzbot+4a65c3228a624fc51bbd@syzkaller.appspotmail.com
First crash: 7d16h, last: 7d12h
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [bcachefs?] possible deadlock in bch2_journal_halt 1 (3) 2025/01/29 13:00
Last patch testing requests (1)
Created Duration User Patch Repo Result
2025/01/29 12:45 13m aha310510@gmail.com upstream error

Sample crash report:
bcachefs (loop0): journal_entry_open(): fatal error cannot start: journal seq overflow
============================================
WARNING: possible recursive locking detected
6.13.0-syzkaller-02526-gc4b9570cfb63 #0 Not tainted
--------------------------------------------
kworker/u4:7/1036 is trying to acquire lock:
ffff888044cca980 (&j->lock){+.+.}-{3:3}, at: spin_lock include/linux/spinlock.h:351 [inline]
ffff888044cca980 (&j->lock){+.+.}-{3:3}, at: bch2_journal_halt+0x2f/0x110 fs/bcachefs/journal.c:315

but task is already holding lock:
ffff888044cca980 (&j->lock){+.+.}-{3:3}, at: spin_lock include/linux/spinlock.h:351 [inline]
ffff888044cca980 (&j->lock){+.+.}-{3:3}, at: __journal_res_get+0x497/0x26b0 fs/bcachefs/journal.c:533

other info that might help us debug this:
 Possible unsafe locking scenario:

       CPU0
       ----
  lock(&j->lock);
  lock(&j->lock);

 *** DEADLOCK ***

 May be due to missing lock nesting notation

5 locks held by kworker/u4:7/1036:
 #0: ffff888043693948 ((wq_completion)btree_update){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3211 [inline]
 #0: ffff888043693948 ((wq_completion)btree_update){+.+.}-{0:0}, at: process_scheduled_works+0x93b/0x1840 kernel/workqueue.c:3317
 #1: ffffc9000269fc60 ((work_completion)(&c->btree_interior_update_work)){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3212 [inline]
 #1: ffffc9000269fc60 ((work_completion)(&c->btree_interior_update_work)){+.+.}-{0:0}, at: process_scheduled_works+0x976/0x1840 kernel/workqueue.c:3317
 #2: ffff888044c84378 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_lock_acquire include/linux/srcu.h:164 [inline]
 #2: ffff888044c84378 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_read_lock include/linux/srcu.h:256 [inline]
 #2: ffff888044c84378 (&c->btree_trans_barrier){.+.+}-{0:0}, at: __bch2_trans_get+0x7e4/0xd30 fs/bcachefs/btree_iter.c:3378
 #3: ffff88804430c140 (bcachefs_btree){+.+.}-{0:0}, at: trans_set_locked fs/bcachefs/btree_locking.h:198 [inline]
 #3: ffff88804430c140 (bcachefs_btree){+.+.}-{0:0}, at: bch2_trans_begin+0x9ca/0x1d90 fs/bcachefs/btree_iter.c:3275
 #4: ffff888044cca980 (&j->lock){+.+.}-{3:3}, at: spin_lock include/linux/spinlock.h:351 [inline]
 #4: ffff888044cca980 (&j->lock){+.+.}-{3:3}, at: __journal_res_get+0x497/0x26b0 fs/bcachefs/journal.c:533

stack backtrace:
CPU: 0 UID: 0 PID: 1036 Comm: kworker/u4:7 Not tainted 6.13.0-syzkaller-02526-gc4b9570cfb63 #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
Workqueue: btree_update btree_interior_update_work
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120
 print_deadlock_bug+0x483/0x620 kernel/locking/lockdep.c:3039
 check_deadlock kernel/locking/lockdep.c:3091 [inline]
 validate_chain+0x15e2/0x5920 kernel/locking/lockdep.c:3893
 __lock_acquire+0x1397/0x2100 kernel/locking/lockdep.c:5228
 lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5851
 __raw_spin_lock include/linux/spinlock_api_smp.h:133 [inline]
 _raw_spin_lock+0x2e/0x40 kernel/locking/spinlock.c:154
 spin_lock include/linux/spinlock.h:351 [inline]
 bch2_journal_halt+0x2f/0x110 fs/bcachefs/journal.c:315
 bch2_fs_emergency_read_only+0x50/0xc0 fs/bcachefs/super.c:407
 bch2_fatal_error+0x15/0x40 fs/bcachefs/error.c:49
 journal_entry_open fs/bcachefs/journal.c:385 [inline]
 __journal_res_get+0xbef/0x26b0 fs/bcachefs/journal.c:557
 bch2_journal_res_get_slowpath+0xe6/0x710 fs/bcachefs/journal.c:619
 bch2_journal_res_get fs/bcachefs/journal.h:383 [inline]
 bch2_trans_journal_res_get fs/bcachefs/btree_trans_commit.c:350 [inline]
 bch2_trans_commit_write_locked fs/bcachefs/btree_trans_commit.c:652 [inline]
 do_bch2_trans_commit fs/bcachefs/btree_trans_commit.c:866 [inline]
 __bch2_trans_commit+0x353c/0x97a0 fs/bcachefs/btree_trans_commit.c:1066
 bch2_trans_commit fs/bcachefs/btree_update.h:183 [inline]
 btree_update_nodes_written fs/bcachefs/btree_update_interior.c:706 [inline]
 btree_interior_update_work+0x1449/0x2a70 fs/bcachefs/btree_update_interior.c:844
 process_one_work kernel/workqueue.c:3236 [inline]
 process_scheduled_works+0xa66/0x1840 kernel/workqueue.c:3317
 worker_thread+0x870/0xd30 kernel/workqueue.c:3398
 kthread+0x7a9/0x920 kernel/kthread.c:464
 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:148
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
 </TASK>

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/01/22 17:24 upstream c4b9570cfb63 25e17fd3 .config console log report syz / log C [disk image (non-bootable)] [vmlinux] [kernel image] [mounted in repro] ci-snapshot-upstream-root possible deadlock in bch2_journal_halt
2025/01/22 16:44 upstream c4b9570cfb63 25e17fd3 .config console log report syz / log C [disk image (non-bootable)] [vmlinux] [kernel image] [mounted in repro] ci-snapshot-upstream-root possible deadlock in bch2_journal_halt
2025/01/22 13:26 upstream c4b9570cfb63 da72ac06 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root possible deadlock in bch2_journal_halt
* Struck through repros no longer work on HEAD.