possible deadlock in join_transaction (4)

Status: upstream: reported on 2026/09/14 19:47
Subsystems: btrfs
Labels: prio:low
[Documentation on labels]
Reported-by: syzbot+e394e20544a6531e8243@syzkaller.appspotmail.com
First crash: 29d, last: 1d08h
▶ ▼ ✨ AI Jobs (3)
ID Workflow Result Correct Bug Created Started Finished Revision
9c053246 repro-c 💥 possible deadlock in join_transaction (4) 2026/10/09 20:11 2026/10/09 20:11 2026/10/10 01:02 549ef7e3
553d5032 repro-c 💥 possible deadlock in join_transaction (4) 2026/10/07 15:45 2026/10/07 15:45 2026/10/07 19:21 f8f239cf
fe45d7a1 assessment-security DenialOfService: ❌ Exploitable: ❌ FilesystemTrigger: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ❌ UserNamespace: ❌ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ possible deadlock in join_transaction (4) 2026/09/12 00:34 2026/09/12 00:35 2026/09/12 01:37 6816f32e
▶ ▼ Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [btrfs?] possible deadlock in join_transaction (4) 0 (1) 2026/09/14 19:47
▶ ▼ Similar bugs (3)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in join_transaction (3) prio:high btrfs 4 4 193d 306d 0/29 auto-obsoleted due to no activity on 2026/07/08 21:51
upstream possible deadlock in join_transaction (2) btrfs 4 4 662d 670d 0/29 auto-obsoleted due to no activity on 2025/03/26 23:03
upstream possible deadlock in join_transaction btrfs 4 23 838d 881d 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 Tainted: G             L     
------------------------------------------------------
kworker/u8:25/25551 is trying to acquire lock:
ffff8880207aa680 (btrfs_trans_num_writers){++++}-{0:0}, at: join_transaction+0x6b2/0xd40 fs/btrfs/transaction.c:299

but task is already holding lock:
ffff88807ceb4650 (sb_internal#4){++++}-{0:0}, at: btrfs_finish_one_ordered+0x8bb/0x1f00 fs/btrfs/inode.c:3278

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #5 (sb_internal#4){++++}-{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+0x575/0x17d0 fs/btrfs/transaction.c:724
       btrfs_dirty_inode+0x9f/0x190 fs/btrfs/inode.c:6465
       touch_atime+0x2f8/0x670 fs/inode.c:2325
       file_accessed include/linux/fs.h:2277 [inline]
       btrfs_file_mmap_prepare+0x172/0x1f0 fs/btrfs/file.c:2003
       vfs_mmap_prepare include/linux/fs.h:2069 [inline]
       call_mmap_prepare mm/vma.c:2784 [inline]
       __mmap_region mm/vma.c:2873 [inline]
       mmap_region+0xe94/0x25b0 mm/vma.c:2974
       do_mmap+0xe0a/0x1300 mm/mmap.c:573
       vm_mmap_pgoff+0x272/0x4e0 mm/util.c:581
       ksys_mmap_pgoff+0x4dc/0x760 mm/mmap.c:619
       do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
       do_syscall_64+0x166/0x520 arch/x86/entry/syscall_64.c:84
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #4 (&mm->mmap_lock){++++}-{4:4}:
       down_read_killable+0x50/0x3b0 kernel/locking/rwsem.c:1599
       mmap_read_lock_killable+0x1d/0x70 include/linux/mmap_lock.h:609
       get_mmap_lock_carefully mm/mmap_lock.c:450 [inline]
       lock_mm_and_find_vma+0x2d6/0x340 mm/mmap_lock.c:501
       do_user_addr_fault+0x343/0x1340 arch/x86/mm/fault.c:1366
       handle_page_fault arch/x86/mm/fault.c:1483 [inline]
       exc_page_fault+0x6a/0xc0 arch/x86/mm/fault.c:1536
       asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:595
       filldir+0x2bd/0x630 fs/readdir.c:-1
       dir_emit include/linux/fs.h:3607 [inline]
       kernfs_fop_readdir+0x580/0x960 fs/kernfs/dir.c:1999
       iterate_dir+0x2e2/0x4d0 fs/readdir.c:110
       __do_sys_getdents fs/readdir.c:319 [inline]
       __se_sys_getdents+0xf1/0x270 fs/readdir.c:304
       do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
       do_syscall_64+0x166/0x520 arch/x86/entry/syscall_64.c:84
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #3 (&root->kernfs_rwsem){++++}-{4:4}:
       down_write+0x96/0x200 kernel/locking/rwsem.c:1631
       kernfs_add_one+0x41/0x6f0 fs/kernfs/dir.c:825
       kernfs_create_dir_ns+0x1a1/0x230 fs/kernfs/dir.c:1130
       sysfs_create_dir_ns+0x12f/0x2a0 fs/sysfs/dir.c:59
       create_dir lib/kobject.c:73 [inline]
       kobject_add_internal+0x622/0xcd0 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+0x118/0x2f0 fs/btrfs/sysfs.c:2604
       btrfs_quota_enable+0x274/0x1e20 fs/btrfs/qgroup.c:1032
       btrfs_ioctl_quota_ctl+0x186/0x1f0 fs/btrfs/ioctl.c:3581
       vfs_ioctl fs/ioctl.c:51 [inline]
       __do_sys_ioctl fs/ioctl.c:597 [inline]
       __se_sys_ioctl+0xfc/0x170 fs/ioctl.c:583
       do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
       do_syscall_64+0x166/0x520 arch/x86/entry/syscall_64.c:84
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #2 (&fs_info->qgroup_ioctl_lock){+.+.}-{4:4}:
       __mutex_lock_common kernel/locking/mutex.c:646 [inline]
       __mutex_lock+0x19d/0x1550 kernel/locking/mutex.c:821
       btrfs_quota_enable+0x2b1/0x1e20 fs/btrfs/qgroup.c:1061
       btrfs_ioctl_quota_ctl+0x186/0x1f0 fs/btrfs/ioctl.c:3581
       vfs_ioctl fs/ioctl.c:51 [inline]
       __do_sys_ioctl fs/ioctl.c:597 [inline]
       __se_sys_ioctl+0xfc/0x170 fs/ioctl.c:583
       do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
       do_syscall_64+0x166/0x520 arch/x86/entry/syscall_64.c:84
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #1 (btrfs_trans_num_extwriters){++++}-{0:0}:
       join_transaction+0x18a/0xd40 fs/btrfs/transaction.c:324
       start_transaction+0x6ed/0x17d0 fs/btrfs/transaction.c:730
       btrfs_create_common+0x15c/0x310 fs/btrfs/inode.c:7003
       btrfs_mkdir+0xc1/0xf0 fs/btrfs/inode.c:7148
       vfs_mkdir+0x40c/0x620 fs/namei.c:5410
       filename_mkdirat+0x285/0x510 fs/namei.c:5443
       __do_sys_mkdirat fs/namei.c:5464 [inline]
       __se_sys_mkdirat+0x35/0x150 fs/namei.c:5461
       do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
       do_syscall_64+0x166/0x520 arch/x86/entry/syscall_64.c:84
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #0 (btrfs_trans_num_writers){++++}-{0:0}:
       check_prev_add kernel/locking/lockdep.c:3209 [inline]
       check_prevs_add kernel/locking/lockdep.c:3328 [inline]
       validate_chain kernel/locking/lockdep.c:3952 [inline]
       __lock_acquire+0x164c/0x2de0 kernel/locking/lockdep.c:5288
       lock_acquire+0x115/0x350 kernel/locking/lockdep.c:5942
       join_transaction+0x6cf/0xd40 fs/btrfs/transaction.c:299
       start_transaction+0x6ed/0x17d0 fs/btrfs/transaction.c:730
       btrfs_finish_one_ordered+0x8bb/0x1f00 fs/btrfs/inode.c:3278
       btrfs_work_helper+0x3a2/0xc50 fs/btrfs/async-thread.c:312
       process_one_work kernel/workqueue.c:3396 [inline]
       process_scheduled_works+0xc3d/0x1630 kernel/workqueue.c:3479
       worker_thread+0xa47/0xfb0 kernel/workqueue.c:3560
       kthread+0x38b/0x480 kernel/kthread.c:436
       ret_from_fork+0x514/0xb70 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 --> &mm->mmap_lock --> sb_internal#4

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  rlock(sb_internal#4);
                               lock(&mm->mmap_lock);
                               lock(sb_internal#4);
  rlock(btrfs_trans_num_writers);

 *** DEADLOCK ***

locks held by kworker/u8:25/25551: 4, last CPU#0:
 #0: ffff8880537f7140 ((wq_completion)btrfs-endio-write){+.+.}-{0:0}, at: rcu_lock_acquire include/linux/rcupdate.h:309 [inline]
 #0: ffff8880537f7140 ((wq_completion)btrfs-endio-write){+.+.}-{0:0}, at: rcu_read_lock include/linux/rcupdate.h:849 [inline]
 #0: ffff8880537f7140 ((wq_completion)btrfs-endio-write){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3361 [inline]
 #0: ffff8880537f7140 ((wq_completion)btrfs-endio-write){+.+.}-{0:0}, at: process_scheduled_works+0x97a/0x1630 kernel/workqueue.c:3479
 #1: ffffc90009d07c40 ((work_completion)(&work->normal_work)){+.+.}-{0:0}, at: rcu_lock_acquire include/linux/rcupdate.h:309 [inline]
 #1: ffffc90009d07c40 ((work_completion)(&work->normal_work)){+.+.}-{0:0}, at: rcu_read_lock include/linux/rcupdate.h:849 [inline]
 #1: ffffc90009d07c40 ((work_completion)(&work->normal_work)){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3361 [inline]
 #1: ffffc90009d07c40 ((work_completion)(&work->normal_work)){+.+.}-{0:0}, at: process_scheduled_works+0x97a/0x1630 kernel/workqueue.c:3479
 #2: ffff8880207aa798 (btrfs_ordered_extent){++++}-{0:0}, at: btrfs_finish_one_ordered+0x39e/0x1f00 fs/btrfs/inode.c:3240
 #3: ffff88807ceb4650 (sb_internal#4){++++}-{0:0}, at: btrfs_finish_one_ordered+0x8bb/0x1f00 fs/btrfs/inode.c:3278

stack backtrace:
CPU: 0 UID: 0 PID: 25551 Comm: kworker/u8:25 Tainted: G             L      syzkaller #0 PREEMPT(full) 
Tainted: [L]=SOFTLOCKUP
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/16/2026
Workqueue: btrfs-endio-write btrfs_work_helper
Call Trace:
 <TASK>
 dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120
 print_circular_bug+0x2e2/0x300 kernel/locking/lockdep.c:2087
 check_noncircular+0x12f/0x150 kernel/locking/lockdep.c:2219
 check_prev_add kernel/locking/lockdep.c:3209 [inline]
 check_prevs_add kernel/locking/lockdep.c:3328 [inline]
 validate_chain kernel/locking/lockdep.c:3952 [inline]
 __lock_acquire+0x164c/0x2de0 kernel/locking/lockdep.c:5288
 lock_acquire+0x115/0x350 kernel/locking/lockdep.c:5942
 join_transaction+0x6cf/0xd40 fs/btrfs/transaction.c:299
 start_transaction+0x6ed/0x17d0 fs/btrfs/transaction.c:730
 btrfs_finish_one_ordered+0x8bb/0x1f00 fs/btrfs/inode.c:3278
 btrfs_work_helper+0x3a2/0xc50 fs/btrfs/async-thread.c:312
 process_one_work kernel/workqueue.c:3396 [inline]
 process_scheduled_works+0xc3d/0x1630 kernel/workqueue.c:3479
 worker_thread+0xa47/0xfb0 kernel/workqueue.c:3560
 kthread+0x38b/0x480 kernel/kthread.c:436
 ret_from_fork+0x514/0xb70 arch/x86/kernel/process.c:158
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
 </TASK>

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/10/08 23:28 upstream 7b63ef2d55f2 b2734a59 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root possible deadlock in join_transaction
2026/09/10 19:38 upstream 50d05c7c76c9 1fe56c0a .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root possible deadlock in join_transaction
* Struck through repros no longer work on HEAD.