====================================================== WARNING: possible circular locking dependency detected 6.12.0-syzkaller-07834-g06afb0f36106 #0 Not tainted ------------------------------------------------------ syz.0.0/5340 is trying to acquire lock: ffff8880570d0128 (bcachefs_btree){+.+.}-{0:0}, at: trans_set_locked fs/bcachefs/btree_locking.h:194 [inline] ffff8880570d0128 (bcachefs_btree){+.+.}-{0:0}, at: __bch2_trans_relock+0x382/0x5f0 fs/bcachefs/btree_locking.c:785 but task is already holding lock: ffff888052d61548 (&c->fsck_error_msgs_lock){+.+.}-{4:4}, at: __bch2_fsck_err+0x3d4/0x1570 fs/bcachefs/error.c:282 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #1 (&c->fsck_error_msgs_lock){+.+.}-{4:4}: lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849 __mutex_lock_common kernel/locking/mutex.c:585 [inline] __mutex_lock+0x1ac/0xee0 kernel/locking/mutex.c:735 __bch2_fsck_err+0x3d4/0x1570 fs/bcachefs/error.c:282 __bch2_bkey_fsck_err+0x24d/0x280 fs/bcachefs/error.c:464 __bch2_bkey_validate+0x5f8/0x7b0 bset_key_validate fs/bcachefs/btree_io.c:839 [inline] validate_bset_keys+0x775/0x1610 fs/bcachefs/btree_io.c:910 bch2_btree_node_read_done+0x2402/0x5e90 fs/bcachefs/btree_io.c:1130 btree_node_read_work+0x68b/0x1260 fs/bcachefs/btree_io.c:1323 bch2_btree_node_read+0x2433/0x2a10 bch2_btree_node_fill+0xc75/0x12f0 fs/bcachefs/btree_cache.c:991 bch2_btree_node_get_noiter+0x9d5/0xf70 fs/bcachefs/btree_cache.c:1260 found_btree_node_is_readable fs/bcachefs/btree_node_scan.c:85 [inline] try_read_btree_node fs/bcachefs/btree_node_scan.c:193 [inline] read_btree_nodes_worker+0x13c5/0x2220 fs/bcachefs/btree_node_scan.c:242 kthread+0x2f0/0x390 kernel/kthread.c:389 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244 -> #0 (bcachefs_btree){+.+.}-{0:0}: check_prev_add kernel/locking/lockdep.c:3161 [inline] check_prevs_add kernel/locking/lockdep.c:3280 [inline] validate_chain+0x18ef/0x5920 kernel/locking/lockdep.c:3904 __lock_acquire+0x1397/0x2100 kernel/locking/lockdep.c:5226 lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849 trans_set_locked fs/bcachefs/btree_locking.h:194 [inline] __bch2_trans_relock+0x397/0x5f0 fs/bcachefs/btree_locking.c:785 __bch2_fsck_err+0x12ab/0x1570 fs/bcachefs/error.c:363 bch2_check_alloc_key+0x10c9/0x3200 fs/bcachefs/alloc_background.c:1159 bch2_check_alloc_info+0x21f1/0x5330 fs/bcachefs/alloc_background.c:1537 bch2_run_recovery_pass+0xf0/0x1e0 fs/bcachefs/recovery_passes.c:191 bch2_run_online_recovery_passes+0x85/0x150 fs/bcachefs/recovery_passes.c:212 bch2_fsck_online_thread_fn+0x1da/0x410 fs/bcachefs/chardev.c:799 thread_with_stdio_fn+0x5f/0x130 fs/bcachefs/thread_with_file.c:298 kthread+0x2f0/0x390 kernel/kthread.c:389 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244 other info that might help us debug this: Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&c->fsck_error_msgs_lock); lock(bcachefs_btree); lock(&c->fsck_error_msgs_lock); lock(bcachefs_btree); *** DEADLOCK *** 3 locks held by syz.0.0/5340: #0: ffff888052d00278 (&c->state_lock){++++}-{4:4}, at: bch2_run_online_recovery_passes+0x32/0x150 fs/bcachefs/recovery_passes.c:204 #1: ffff888052d04398 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_lock_acquire include/linux/srcu.h:158 [inline] #1: ffff888052d04398 (&c->btree_trans_barrier){.+.+}-{0:0}, at: srcu_read_lock include/linux/srcu.h:249 [inline] #1: ffff888052d04398 (&c->btree_trans_barrier){.+.+}-{0:0}, at: __bch2_trans_get+0x7e1/0xd30 fs/bcachefs/btree_iter.c:3228 #2: ffff888052d61548 (&c->fsck_error_msgs_lock){+.+.}-{4:4}, at: __bch2_fsck_err+0x3d4/0x1570 fs/bcachefs/error.c:282 stack backtrace: CPU: 0 UID: 0 PID: 5340 Comm: syz.0.0 Not tainted 6.12.0-syzkaller-07834-g06afb0f36106 #0 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014 Call Trace: __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120 print_circular_bug+0x13a/0x1b0 kernel/locking/lockdep.c:2074 check_noncircular+0x36a/0x4a0 kernel/locking/lockdep.c:2206 check_prev_add kernel/locking/lockdep.c:3161 [inline] check_prevs_add kernel/locking/lockdep.c:3280 [inline] validate_chain+0x18ef/0x5920 kernel/locking/lockdep.c:3904 __lock_acquire+0x1397/0x2100 kernel/locking/lockdep.c:5226 lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849 trans_set_locked fs/bcachefs/btree_locking.h:194 [inline] __bch2_trans_relock+0x397/0x5f0 fs/bcachefs/btree_locking.c:785 __bch2_fsck_err+0x12ab/0x1570 fs/bcachefs/error.c:363 bch2_check_alloc_key+0x10c9/0x3200 fs/bcachefs/alloc_background.c:1159 bch2_check_alloc_info+0x21f1/0x5330 fs/bcachefs/alloc_background.c:1537 bch2_run_recovery_pass+0xf0/0x1e0 fs/bcachefs/recovery_passes.c:191 bch2_run_online_recovery_passes+0x85/0x150 fs/bcachefs/recovery_passes.c:212 bch2_fsck_online_thread_fn+0x1da/0x410 fs/bcachefs/chardev.c:799 thread_with_stdio_fn+0x5f/0x130 fs/bcachefs/thread_with_file.c:298 kthread+0x2f0/0x390 kernel/kthread.c:389 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244 syz.0.0 (5340) used greatest stack depth: 15792 bytes left