syzbot


possible deadlock in __bch2_trans_get

Status: upstream: reported on 2025/09/05 17:26
Subsystems: bcachefs
[Documentation on labels]
Reported-by: syzbot+b70ffe7893bd1110ddd0@syzkaller.appspotmail.com
First crash: 5d00h, last: 1d18h
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [bcachefs?] possible deadlock in __bch2_trans_get 0 (1) 2025/09/05 17:26

Sample crash report:
bcachefs (loop0): /file0/file0 offset 0: data_read_io_err
  u64s 8 type extent 4099:8:U32_MAX len 8 ver 1: durability: 1 crc: c_size 8 size 8 offset 0 nonce 0 csum chacha20_poly1305_80 77fa:f532966a693125aa  compress incompressible ptr: 0:34:0 gen 0
bcachefs (loop0): /file0/file0 offset 0: data read error: data_read_io_err
bcachefs (loop0): /file0/file0 offset 0: data read error, data_read_io_err
  u64s 8 type extent 4099:8:U32_MAX len 8 ver 1: durability: 1 crc: c_size 8 size 8 offset 0 nonce 0 csum chacha20_poly1305_80 77fa:f532966a693125aa  compress incompressible ptr: 0:34:0 gen 0
  loop0 io error
============================================
WARNING: possible recursive locking detected
syzkaller #0 Not tainted
--------------------------------------------
kworker/u4:5/1037 is trying to acquire lock:
ffff888055bec1b0 (bcachefs_btree){+.+.}-{0:0}, at: srcu_lock_acquire include/linux/srcu.h:161 [inline]
ffff888055bec1b0 (bcachefs_btree){+.+.}-{0:0}, at: srcu_read_lock include/linux/srcu.h:253 [inline]
ffff888055bec1b0 (bcachefs_btree){+.+.}-{0:0}, at: __bch2_trans_get+0x7f4/0xd80 fs/bcachefs/btree_iter.c:3505

but task is already holding lock:
ffff888051f701b0 (bcachefs_btree){+.+.}-{0:0}, at: trans_set_locked fs/bcachefs/btree_locking.h:206 [inline]
ffff888051f701b0 (bcachefs_btree){+.+.}-{0:0}, at: bch2_trans_begin+0xbe0/0x2310 fs/bcachefs/btree_iter.c:3403

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

       CPU0
       ----
  lock(bcachefs_btree);
  lock(bcachefs_btree);

 *** DEADLOCK ***

 May be due to missing lock nesting notation

5 locks held by kworker/u4:5/1037:
 #0: ffff88801a479148 ((wq_completion)events_unbound){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3211 [inline]
 #0: ffff88801a479148 ((wq_completion)events_unbound){+.+.}-{0:0}, at: process_scheduled_works+0x9b4/0x17b0 kernel/workqueue.c:3319
 #1: ffffc900025ffbc0 ((work_completion)(&rbio->work)){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3212 [inline]
 #1: ffffc900025ffbc0 ((work_completion)(&rbio->work)){+.+.}-{0:0}, at: process_scheduled_works+0x9ef/0x17b0 kernel/workqueue.c:3319
 #2: ffff888051f701b0 (bcachefs_btree){+.+.}-{0:0}, at: trans_set_locked fs/bcachefs/btree_locking.h:206 [inline]
 #2: ffff888051f701b0 (bcachefs_btree){+.+.}-{0:0}, at: bch2_trans_begin+0xbe0/0x2310 fs/bcachefs/btree_iter.c:3403
 #3: ffff888052f04398 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_lock_acquire include/linux/srcu.h:161 [inline]
 #3: ffff888052f04398 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_read_lock include/linux/srcu.h:253 [inline]
 #3: ffff888052f04398 (&c->btree_trans_barrier){.+.+}-{0:0}, at: bch2_trans_srcu_lock+0xaf/0x220 fs/bcachefs/btree_iter.c:3299
 #4: ffff888052f04398 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_lock_acquire include/linux/srcu.h:161 [inline]
 #4: ffff888052f04398 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_read_lock include/linux/srcu.h:253 [inline]
 #4: ffff888052f04398 (&c->btree_trans_barrier){.+.+}-{0:0}, at: __bch2_trans_get+0x7f4/0xd80 fs/bcachefs/btree_iter.c:3505

stack backtrace:
CPU: 0 UID: 0 PID: 1037 Comm: kworker/u4:5 Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
Workqueue: events_unbound bch2_rbio_retry
Call Trace:
 <TASK>
 dump_stack_lvl+0x189/0x250 lib/dump_stack.c:120
 print_deadlock_bug+0x28b/0x2a0 kernel/locking/lockdep.c:3041
 check_deadlock kernel/locking/lockdep.c:3093 [inline]
 validate_chain+0x1a3f/0x2140 kernel/locking/lockdep.c:3895
 __lock_acquire+0xab9/0xd20 kernel/locking/lockdep.c:5237
 lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5868
 trans_set_locked fs/bcachefs/btree_locking.h:206 [inline]
 __bch2_trans_get+0x8fd/0xd80 fs/bcachefs/btree_iter.c:3508
 bch2_rbio_retry+0x1d1/0x19b0 fs/bcachefs/io_read.c:594
 bch2_rbio_done fs/bcachefs/io_read.c:464 [inline]
 bch2_rbio_retry+0xbf4/0x19b0 fs/bcachefs/io_read.c:667
 process_one_work kernel/workqueue.c:3236 [inline]
 process_scheduled_works+0xae1/0x17b0 kernel/workqueue.c:3319
 worker_thread+0x8a0/0xda0 kernel/workqueue.c:3400
 kthread+0x70e/0x8a0 kernel/kthread.c:463
 ret_from_fork+0x3fc/0x770 arch/x86/kernel/process.c:148
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
 </TASK>

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/09/04 23:25 upstream 08b06c30a445 d291dd2d .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root possible deadlock in __bch2_trans_get
2025/09/03 13:50 upstream e6b9dce0aeeb 96a211bc .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root possible deadlock in __bch2_trans_get
2025/09/01 17:20 upstream b320789d6883 807a3b61 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root possible deadlock in __bch2_trans_get
* Struck through repros no longer work on HEAD.