syzbot


possible deadlock in join_transaction (3)

Status: upstream: reported on 2025/12/08 00:54
Subsystems: btrfs
[Documentation on labels]
Reported-by: syzbot+c597e3e4382fe9c65845@syzkaller.appspotmail.com
First crash: 131d, last: 15d
✨ AI Jobs (1)
ID Workflow Result Correct Bug Created Started Finished Revision Error
a568803a-553a-4200-902c-7c53403714b4 repro possible deadlock in join_transaction (3) 2026/03/07 21:53 2026/03/07 21:53 2026/03/07 22:01 31e9c887f7dc24e04b3ca70d0d54fc34141844b0
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [btrfs?] possible deadlock in join_transaction (3) 0 (1) 2025/12/08 00:54
Similar bugs (2)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in join_transaction (2) btrfs 4 4 483d 491d 0/29 auto-obsoleted due to no activity on 2025/03/26 23:03
upstream possible deadlock in join_transaction btrfs 4 23 659d 702d 0/29 auto-obsoleted due to no activity on 2024/09/01 23:05

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
syzkaller #0 Not tainted
------------------------------------------------------
kworker/u8:2/43 is trying to acquire lock:
ffff8880692fb118 (btrfs_trans_num_writers){++++}-{0:0}, at: join_transaction+0x41b/0xc90 fs/btrfs/transaction.c:298

but task is already holding lock:
ffff888064b86770 (sb_internal#2){.+.+}-{0:0}, at: __cow_file_range_inline+0x167/0x1240 fs/btrfs/inode.c:646

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #6 (sb_internal#2){.+.+}-{0:0}:
       percpu_down_read_internal include/linux/percpu-rwsem.h:53 [inline]
       percpu_down_read_freezable include/linux/percpu-rwsem.h:83 [inline]
       __sb_start_write include/linux/fs/super.h:19 [inline]
       sb_start_intwrite include/linux/fs/super.h:177 [inline]
       start_transaction+0x56e/0x1650 fs/btrfs/transaction.c:702
       btrfs_dirty_inode+0x9f/0x190 fs/btrfs/inode.c:6443
       file_update_time_flags+0x2d5/0x4b0 fs/inode.c:2426
       btrfs_page_mkwrite+0x5df/0x1b10 fs/btrfs/file.c:1914
       do_page_mkwrite+0x150/0x310 mm/memory.c:3589
       wp_page_shared mm/memory.c:3990 [inline]
       do_wp_page+0x203b/0x49d0 mm/memory.c:4209
       handle_pte_fault mm/memory.c:6333 [inline]
       __handle_mm_fault mm/memory.c:6455 [inline]
       handle_mm_fault+0x9f5/0x13c0 mm/memory.c:6624
       do_user_addr_fault+0xa73/0x1340 arch/x86/mm/fault.c:1334
       handle_page_fault arch/x86/mm/fault.c:1474 [inline]
       exc_page_fault+0x6a/0xc0 arch/x86/mm/fault.c:1527
       asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:618

-> #5 (sb_pagefaults#3){.+.+}-{0:0}:
       percpu_down_read_internal include/linux/percpu-rwsem.h:53 [inline]
       percpu_down_read_freezable include/linux/percpu-rwsem.h:83 [inline]
       __sb_start_write include/linux/fs/super.h:19 [inline]
       sb_start_pagefault include/linux/fs/super.h:159 [inline]
       btrfs_page_mkwrite+0x329/0x1b10 fs/btrfs/file.c:1873
       do_page_mkwrite+0x150/0x310 mm/memory.c:3589
       do_shared_fault mm/memory.c:5875 [inline]
       do_fault mm/memory.c:5937 [inline]
       do_pte_missing+0x711/0x29e0 mm/memory.c:4477
       handle_pte_fault mm/memory.c:6317 [inline]
       __handle_mm_fault mm/memory.c:6455 [inline]
       handle_mm_fault+0xd0a/0x13c0 mm/memory.c:6624
       do_user_addr_fault+0x75b/0x1340 arch/x86/mm/fault.c:1385
       handle_page_fault arch/x86/mm/fault.c:1474 [inline]
       exc_page_fault+0x6a/0xc0 arch/x86/mm/fault.c:1527
       asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:618
       rep_movs_alternative+0x4a/0x90 arch/x86/lib/copy_user_64.S:68
       copy_user_generic arch/x86/include/asm/uaccess_64.h:126 [inline]
       raw_copy_to_user arch/x86/include/asm/uaccess_64.h:147 [inline]
       copy_to_user_iter lib/iov_iter.c:25 [inline]
       iterate_ubuf include/linux/iov_iter.h:30 [inline]
       iterate_and_advance2 include/linux/iov_iter.h:302 [inline]
       iterate_and_advance include/linux/iov_iter.h:330 [inline]
       _copy_to_iter+0x255/0x17d0 lib/iov_iter.c:197
       copy_page_to_iter+0x10c/0x1c0 lib/iov_iter.c:374
       copy_folio_to_iter include/linux/uio.h:204 [inline]
       filemap_read+0x814/0x1240 mm/filemap.c:2856
       new_sync_read fs/read_write.c:493 [inline]
       vfs_read+0x58b/0xa80 fs/read_write.c:574
       ksys_read+0x156/0x270 fs/read_write.c:717
       do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
       do_syscall_64+0x14d/0xf80 arch/x86/entry/syscall_64.c:94
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #4 (&mm->mmap_lock){++++}-{4:4}:
       down_read_killable+0xa4/0x220 kernel/locking/rwsem.c:1560
       mmap_read_lock_killable+0x1d/0x70 include/linux/mmap_lock.h:601
       get_mmap_lock_carefully mm/mmap_lock.c:450 [inline]
       lock_mm_and_find_vma+0x2d7/0x340 mm/mmap_lock.c:501
       do_user_addr_fault+0x330/0x1340 arch/x86/mm/fault.c:1357
       handle_page_fault arch/x86/mm/fault.c:1474 [inline]
       exc_page_fault+0x6a/0xc0 arch/x86/mm/fault.c:1527
       asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:618
       filldir+0x2b5/0x690 fs/readdir.c:295
       dir_emit include/linux/fs.h:3566 [inline]
       kernfs_fop_readdir+0x57e/0x8d0 fs/kernfs/dir.c:1915
       iterate_dir+0x3a5/0x580 fs/readdir.c:108
       __do_sys_getdents fs/readdir.c:327 [inline]
       __se_sys_getdents+0xf1/0x270 fs/readdir.c:312
       do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
       do_syscall_64+0x14d/0xf80 arch/x86/entry/syscall_64.c:94
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #3 (&root->kernfs_rwsem){++++}-{4:4}:
       down_write+0x3a/0x50 kernel/locking/rwsem.c:1590
       kernfs_add_one+0x41/0x5c0 fs/kernfs/dir.c:796
       kernfs_create_dir_ns+0xde/0x130 fs/kernfs/dir.c:1098
       sysfs_create_dir_ns+0x12f/0x2a0 fs/sysfs/dir.c:59
       create_dir lib/kobject.c:73 [inline]
       kobject_add_internal+0x631/0xd10 lib/kobject.c:240
       kobject_add_varg lib/kobject.c:374 [inline]
       kobject_init_and_add+0x12b/0x1a0 lib/kobject.c:457
       btrfs_sysfs_add_qgroups+0x116/0x2e0 fs/btrfs/sysfs.c:2604
       btrfs_quota_enable+0x282/0x2850 fs/btrfs/qgroup.c:1034
       btrfs_ioctl_quota_ctl+0x186/0x1c0 fs/btrfs/ioctl.c:3540
       vfs_ioctl fs/ioctl.c:51 [inline]
       __do_sys_ioctl fs/ioctl.c:597 [inline]
       __se_sys_ioctl+0xff/0x170 fs/ioctl.c:583
       do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
       do_syscall_64+0x14d/0xf80 arch/x86/entry/syscall_64.c:94
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #2 (&fs_info->qgroup_ioctl_lock){+.+.}-{4:4}:
       __mutex_lock_common kernel/locking/rtmutex_api.c:533 [inline]
       mutex_lock_nested+0x5a/0x1d0 kernel/locking/rtmutex_api.c:552
       btrfs_quota_enable+0x2c6/0x2850 fs/btrfs/qgroup.c:1063
       btrfs_ioctl_quota_ctl+0x186/0x1c0 fs/btrfs/ioctl.c:3540
       vfs_ioctl fs/ioctl.c:51 [inline]
       __do_sys_ioctl fs/ioctl.c:597 [inline]
       __se_sys_ioctl+0xff/0x170 fs/ioctl.c:583
       do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
       do_syscall_64+0x14d/0xf80 arch/x86/entry/syscall_64.c:94
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #1 (btrfs_trans_num_extwriters){++++}-{0:0}:
       join_transaction+0x1a4/0xc90 fs/btrfs/transaction.c:323
       start_transaction+0x6b9/0x1650 fs/btrfs/transaction.c:708
       btrfs_rebuild_free_space_tree+0xbb/0x6e0 fs/btrfs/free-space-tree.c:1335
       btrfs_start_pre_rw_mount+0x1529/0x1f20 fs/btrfs/disk-io.c:3071
       open_ctree+0x2e07/0x4220 fs/btrfs/disk-io.c:3668
       btrfs_fill_super fs/btrfs/super.c:981 [inline]
       btrfs_get_tree_super fs/btrfs/super.c:1944 [inline]
       btrfs_get_tree_subvol fs/btrfs/super.c:2087 [inline]
       btrfs_get_tree+0x1061/0x1930 fs/btrfs/super.c:2121
       vfs_get_tree+0x92/0x2a0 fs/super.c:1754
       fc_mount fs/namespace.c:1193 [inline]
       do_new_mount_fc fs/namespace.c:3763 [inline]
       do_new_mount+0x341/0xd30 fs/namespace.c:3839
       do_mount fs/namespace.c:4172 [inline]
       __do_sys_mount fs/namespace.c:4361 [inline]
       __se_sys_mount+0x31d/0x420 fs/namespace.c:4338
       do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
       do_syscall_64+0x14d/0xf80 arch/x86/entry/syscall_64.c:94
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #0 (btrfs_trans_num_writers){++++}-{0:0}:
       check_prev_add kernel/locking/lockdep.c:3165 [inline]
       check_prevs_add kernel/locking/lockdep.c:3284 [inline]
       validate_chain kernel/locking/lockdep.c:3908 [inline]
       __lock_acquire+0x15a5/0x2cf0 kernel/locking/lockdep.c:5237
       lock_acquire+0xf0/0x2e0 kernel/locking/lockdep.c:5868
       join_transaction+0x43b/0xc90 fs/btrfs/transaction.c:298
       start_transaction+0x6b9/0x1650 fs/btrfs/transaction.c:708
       __cow_file_range_inline+0x167/0x1240 fs/btrfs/inode.c:646
       cow_file_range_inline+0x3b5/0x4b0 fs/btrfs/inode.c:724
       compress_file_range+0xcba/0x19b0 fs/btrfs/inode.c:1054
       btrfs_work_helper+0x38b/0xc70 fs/btrfs/async-thread.c:312
       process_one_work kernel/workqueue.c:3276 [inline]
       process_scheduled_works+0xb6e/0x18c0 kernel/workqueue.c:3359
       worker_thread+0xa53/0xfc0 kernel/workqueue.c:3440
       kthread+0x388/0x470 kernel/kthread.c:436
       ret_from_fork+0x51e/0xb90 arch/x86/kernel/process.c:158
       ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245

other info that might help us debug this:

Chain exists of:
  btrfs_trans_num_writers --> sb_pagefaults#3 --> sb_internal#2

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  rlock(sb_internal#2);
                               lock(sb_pagefaults#3);
                               lock(sb_internal#2);
  rlock(btrfs_trans_num_writers);

 *** DEADLOCK ***

3 locks held by kworker/u8:2/43:
 #0: ffff888029ff8938 ((wq_completion)btrfs-delalloc){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3251 [inline]
 #0: ffff888029ff8938 ((wq_completion)btrfs-delalloc){+.+.}-{0:0}, at: process_scheduled_works+0xa52/0x18c0 kernel/workqueue.c:3359
 #1: ffffc90000b57c40 ((work_completion)(&work->normal_work)){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3252 [inline]
 #1: ffffc90000b57c40 ((work_completion)(&work->normal_work)){+.+.}-{0:0}, at: process_scheduled_works+0xa8d/0x18c0 kernel/workqueue.c:3359
 #2: ffff888064b86770 (sb_internal#2){.+.+}-{0:0}, at: __cow_file_range_inline+0x167/0x1240 fs/btrfs/inode.c:646

stack backtrace:
CPU: 1 UID: 0 PID: 43 Comm: kworker/u8:2 Not tainted syzkaller #0 PREEMPT_{RT,(full)} 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2026
Workqueue: btrfs-delalloc btrfs_work_helper
Call Trace:
 <TASK>
 dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120
 print_circular_bug+0x2e1/0x300 kernel/locking/lockdep.c:2043
 check_noncircular+0x12e/0x150 kernel/locking/lockdep.c:2175
 check_prev_add kernel/locking/lockdep.c:3165 [inline]
 check_prevs_add kernel/locking/lockdep.c:3284 [inline]
 validate_chain kernel/locking/lockdep.c:3908 [inline]
 __lock_acquire+0x15a5/0x2cf0 kernel/locking/lockdep.c:5237
 lock_acquire+0xf0/0x2e0 kernel/locking/lockdep.c:5868
 join_transaction+0x43b/0xc90 fs/btrfs/transaction.c:298
 start_transaction+0x6b9/0x1650 fs/btrfs/transaction.c:708
 __cow_file_range_inline+0x167/0x1240 fs/btrfs/inode.c:646
 cow_file_range_inline+0x3b5/0x4b0 fs/btrfs/inode.c:724
 compress_file_range+0xcba/0x19b0 fs/btrfs/inode.c:1054
 btrfs_work_helper+0x38b/0xc70 fs/btrfs/async-thread.c:312
 process_one_work kernel/workqueue.c:3276 [inline]
 process_scheduled_works+0xb6e/0x18c0 kernel/workqueue.c:3359
 worker_thread+0xa53/0xfc0 kernel/workqueue.c:3440
 kthread+0x388/0x470 kernel/kthread.c:436
 ret_from_fork+0x51e/0xb90 arch/x86/kernel/process.c:158
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
 </TASK>

Crashes (4):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/03/30 21:50 upstream 7aaa8047eafd d0af506e .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in join_transaction
2026/03/25 11:51 upstream bbeb83d3182a 8ee77f7d .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in join_transaction
2026/03/05 04:00 upstream ecc64d2dc9ff a9fe5c9e .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in join_transaction
2025/12/04 00:51 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 05c93f3395ed d6526ea3 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 possible deadlock in join_transaction
* Struck through repros no longer work on HEAD.