possible deadlock in ocfs2_remove_btree_range (3)

Status: upstream: reported on 2026/07/28 02:59
Reported-by: syzbot+5ef4e438a0104b474f2c@syzkaller.appspotmail.com
First crash: 23d, last: 5d16h
Similar bugs (5)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in ocfs2_remove_btree_range (2) ocfs2 4 1 288d 284d 0/29 auto-obsoleted due to no activity on 2026/02/13 02:43
linux-6.1 possible deadlock in ocfs2_remove_btree_range 4 20 1d10h 202d 0/3 upstream: reported on 2026/01/29 20:10
linux-5.15 possible deadlock in ocfs2_remove_btree_range (2) 4 4 127d 192d 0/3 auto-obsoleted due to no activity on 2026/07/23 14:33
linux-5.15 possible deadlock in ocfs2_remove_btree_range 4 1 704d 704d 0/3 auto-obsoleted due to no activity on 2024/12/24 02:14
upstream possible deadlock in ocfs2_remove_btree_range ocfs2 4 2 634d 661d 0/29 auto-obsoleted due to no activity on 2025/03/03 19:57

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
syzkaller #0 Not tainted
------------------------------------------------------
syz.5.689/6340 is trying to acquire lock:
ffff8880534609c8 (&ocfs2_sysfile_lock_key[args->fi_sysfile_type]#2){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:787 [inline]
ffff8880534609c8 (&ocfs2_sysfile_lock_key[args->fi_sysfile_type]#2){+.+.}-{3:3}, at: ocfs2_remove_btree_range+0x64f/0x15e0 fs/ocfs2/alloc.c:5742

but task is already holding lock:
ffff888077191098
 (&new->rf_sem){+.+.}-{3:3}, at: __ocfs2_lock_refcount_tree fs/ocfs2/refcounttree.c:428 [inline]
 (&new->rf_sem){+.+.}-{3:3}, at: ocfs2_lock_refcount_tree+0x1aa/0x9d0 fs/ocfs2/refcounttree.c:463

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #5 (&new->rf_sem){+.+.}-{3:3}:
       down_write+0x38/0x60 kernel/locking/rwsem.c:1551
       __ocfs2_lock_refcount_tree fs/ocfs2/refcounttree.c:428 [inline]
       ocfs2_lock_refcount_tree+0x1aa/0x9d0 fs/ocfs2/refcounttree.c:463
       ocfs2_reflink_remap_extent fs/ocfs2/refcounttree.c:4581 [inline]
       ocfs2_reflink_remap_blocks+0xce2/0x1aa0 fs/ocfs2/refcounttree.c:4718
       ocfs2_remap_file_range+0x4a7/0x740 fs/ocfs2/file.c:2706
       do_clone_file_range+0x265/0x2d0 fs/remap_range.c:395
       vfs_clone_file_range+0x1ee/0x4f0 fs/remap_range.c:413
       ioctl_file_clone fs/ioctl.c:242 [inline]
       ioctl_file_clone_range fs/ioctl.c:262 [inline]
       do_vfs_ioctl+0x16de/0x1f40 fs/ioctl.c:827
       __do_sys_ioctl fs/ioctl.c:872 [inline]
       __se_sys_ioctl+0x83/0x170 fs/ioctl.c:860
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x66/0xd0

-> #4 (&ocfs2_quota_ip_alloc_sem_key){++++}-{3:3}:
       down_write+0x38/0x60 kernel/locking/rwsem.c:1551
       ocfs2_create_local_dquot+0x199/0x18d0 fs/ocfs2/quota_local.c:1224
       ocfs2_acquire_dquot+0x822/0xb30 fs/ocfs2/quota_global.c:871
       dqget+0x713/0xbb0 fs/quota/dquot.c:1010
       dquot_set_dqblk+0x27/0xfb0 fs/quota/dquot.c:2848
       quota_setquota+0x4d6/0x590 fs/quota/quota.c:309
       __do_sys_quotactl fs/quota/quota.c:959 [inline]
       __se_sys_quotactl+0x28b/0x6f0 fs/quota/quota.c:915
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x66/0xd0

-> #3 (&dquot->dq_lock){+.+.}-{3:3}:
       __mutex_lock_common+0x1e5/0x2400 kernel/locking/mutex.c:596
       __mutex_lock kernel/locking/mutex.c:729 [inline]
       mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:743
       dquot_commit+0x5a/0x410 fs/quota/dquot.c:532
       ext4_write_dquot+0x1f0/0x360 fs/ext4/super.c:6212
       mark_dquot_dirty fs/quota/dquot.c:397 [inline]
       mark_all_dquot_dirty+0xf9/0x400 fs/quota/dquot.c:437
       __dquot_free_space+0x7c3/0xb80 fs/quota/dquot.c:1964
       dquot_free_space_nodirty include/linux/quotaops.h:369 [inline]
       dquot_free_space include/linux/quotaops.h:374 [inline]
       dquot_free_block include/linux/quotaops.h:385 [inline]
       ext4_mb_clear_bb fs/ext4/mballoc.c:6164 [inline]
       ext4_free_blocks+0x1b1b/0x24c0 fs/ext4/mballoc.c:6294
       ext4_remove_blocks fs/ext4/extents.c:2540 [inline]
       ext4_ext_rm_leaf fs/ext4/extents.c:2706 [inline]
       ext4_ext_remove_space+0x2106/0x41a0 fs/ext4/extents.c:2954
       ext4_ext_truncate+0x182/0x230 fs/ext4/extents.c:4504
       ext4_truncate+0xa41/0x1190 fs/ext4/inode.c:4263
       ext4_process_orphan+0x1a9/0x2e0 fs/ext4/orphan.c:337
       ext4_orphan_cleanup+0xad8/0x1320 fs/ext4/orphan.c:472
       ext4_fill_super+0x8c65/0x93f0 fs/ext4/super.c:5006
       mount_bdev+0x28a/0x3c0 fs/super.c:1400
       legacy_get_tree+0xe6/0x180 fs/fs_context.c:611
       vfs_get_tree+0x88/0x270 fs/super.c:1530
       do_new_mount+0x247/0xa40 fs/namespace.c:3034
       do_mount fs/namespace.c:3377 [inline]
       __do_sys_mount fs/namespace.c:3585 [inline]
       __se_sys_mount+0x2e3/0x3d0 fs/namespace.c:3562
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x66/0xd0

-> #2 (&ei->i_data_sem){++++}-{3:3}:
       down_read+0x44/0x2e0 kernel/locking/rwsem.c:1498
       ext4_map_blocks+0x350/0x1a50 fs/ext4/inode.c:600
       ext4_append+0x22d/0x560 fs/ext4/namei.c:75
       ext4_init_new_dir+0x2a7/0x910 fs/ext4/namei.c:3030
       ext4_mkdir+0x4c3/0xc90 fs/ext4/namei.c:3076
       vfs_mkdir+0x386/0x570 fs/namei.c:4073
       do_mkdirat+0x1dd/0x5c0 fs/namei.c:4098
       __do_sys_mkdir fs/namei.c:4118 [inline]
       __se_sys_mkdir fs/namei.c:4116 [inline]
       __x64_sys_mkdir+0x6a/0x80 fs/namei.c:4116
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x66/0xd0

-> #1 (jbd2_handle){++++}-{0:0}:
       jbd2_journal_lock_updates+0xa4/0x390 fs/jbd2/transaction.c:881
       __ocfs2_flush_truncate_log+0x2b4/0x1110 fs/ocfs2/alloc.c:6027
       ocfs2_flush_truncate_log+0x4b/0x60 fs/ocfs2/alloc.c:6074
       ocfs2_sync_fs+0x119/0x330 fs/ocfs2/super.c:403
       sync_filesystem+0x1be/0x220 fs/sync.c:66
       ocfs2_remount+0x123/0xb30 fs/ocfs2/super.c:612
       reconfigure_super+0x224/0x8d0 fs/super.c:938
       do_remount fs/namespace.c:2697 [inline]
       path_mount+0xc5a/0xfe0 fs/namespace.c:3356
       do_mount fs/namespace.c:3377 [inline]
       __do_sys_mount fs/namespace.c:3585 [inline]
       __se_sys_mount+0x2e3/0x3d0 fs/namespace.c:3562
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x66/0xd0

-> #0 (&ocfs2_sysfile_lock_key[args->fi_sysfile_type]#2){+.+.}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3053 [inline]
       check_prevs_add kernel/locking/lockdep.c:3172 [inline]
       validate_chain kernel/locking/lockdep.c:3788 [inline]
       __lock_acquire+0x2c66/0x7b50 kernel/locking/lockdep.c:5012
       lock_acquire+0x19e/0x400 kernel/locking/lockdep.c:5623
       down_write+0x38/0x60 kernel/locking/rwsem.c:1551
       inode_lock include/linux/fs.h:787 [inline]
       ocfs2_remove_btree_range+0x64f/0x15e0 fs/ocfs2/alloc.c:5742
       ocfs2_commit_truncate+0xb62/0x1d30 fs/ocfs2/alloc.c:7346
       ocfs2_truncate_file+0xd89/0x1540 fs/ocfs2/file.c:505
       ocfs2_setattr+0x1545/0x1b40 fs/ocfs2/file.c:1215
       notify_change+0xbc6/0xee0 fs/attr.c:505
       do_truncate+0x1ac/0x240 fs/open.c:65
       handle_truncate fs/namei.c:3273 [inline]
       do_open fs/namei.c:3620 [inline]
       path_openat+0x293b/0x2fb0 fs/namei.c:3750
       do_filp_open+0x1df/0x400 fs/namei.c:3777
       do_sys_openat2+0x14b/0x500 fs/open.c:1255
       do_sys_open fs/open.c:1271 [inline]
       __do_sys_creat fs/open.c:1347 [inline]
       __se_sys_creat fs/open.c:1341 [inline]
       __x64_sys_creat+0x8c/0xb0 fs/open.c:1341
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x66/0xd0

other info that might help us debug this:

Chain exists of:
  &ocfs2_sysfile_lock_key[args->fi_sysfile_type]#2 --> &ocfs2_quota_ip_alloc_sem_key --> &new->rf_sem

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&new->rf_sem);
                               lock(&ocfs2_quota_ip_alloc_sem_key);
                               lock(&new->rf_sem);
  lock(&ocfs2_sysfile_lock_key[args->fi_sysfile_type]#2);

 *** DEADLOCK ***

4 locks held by syz.5.689/6340:
 #0: ffff8880754da460 (sb_writers#29){.+.+}-{0:0}, at: mnt_want_write+0x3d/0x90 fs/namespace.c:386
 #1: ffff88807246d108 (&sb->s_type->i_mutex_key#35){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:787 [inline]
 #1: ffff88807246d108 (&sb->s_type->i_mutex_key#35){+.+.}-{3:3}, at: do_truncate+0x198/0x240 fs/open.c:63
 #2: ffff88807246cda0 (&ocfs2_quota_ip_alloc_sem_key){++++}-{3:3}, at: ocfs2_truncate_file+0x335/0x1540 fs/ocfs2/file.c:467
 #3: ffff888077191098 (&new->rf_sem){+.+.}-{3:3}, at: __ocfs2_lock_refcount_tree fs/ocfs2/refcounttree.c:428 [inline]
 #3: ffff888077191098 (&new->rf_sem){+.+.}-{3:3}, at: ocfs2_lock_refcount_tree+0x1aa/0x9d0 fs/ocfs2/refcounttree.c:463

stack backtrace:
CPU: 1 PID: 6340 Comm: syz.5.689 Not tainted syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/24/2026
Call Trace:
 <TASK>
 dump_stack_lvl+0x188/0x250 lib/dump_stack.c:106
 check_noncircular+0x296/0x330 kernel/locking/lockdep.c:2133
 check_prev_add kernel/locking/lockdep.c:3053 [inline]
 check_prevs_add kernel/locking/lockdep.c:3172 [inline]
 validate_chain kernel/locking/lockdep.c:3788 [inline]
 __lock_acquire+0x2c66/0x7b50 kernel/locking/lockdep.c:5012
 lock_acquire+0x19e/0x400 kernel/locking/lockdep.c:5623
 down_write+0x38/0x60 kernel/locking/rwsem.c:1551
 inode_lock include/linux/fs.h:787 [inline]
 ocfs2_remove_btree_range+0x64f/0x15e0 fs/ocfs2/alloc.c:5742
 ocfs2_commit_truncate+0xb62/0x1d30 fs/ocfs2/alloc.c:7346
 ocfs2_truncate_file+0xd89/0x1540 fs/ocfs2/file.c:505
 ocfs2_setattr+0x1545/0x1b40 fs/ocfs2/file.c:1215
 notify_change+0xbc6/0xee0 fs/attr.c:505
 do_truncate+0x1ac/0x240 fs/open.c:65
 handle_truncate fs/namei.c:3273 [inline]
 do_open fs/namei.c:3620 [inline]
 path_openat+0x293b/0x2fb0 fs/namei.c:3750
 do_filp_open+0x1df/0x400 fs/namei.c:3777
 do_sys_openat2+0x14b/0x500 fs/open.c:1255
 do_sys_open fs/open.c:1271 [inline]
 __do_sys_creat fs/open.c:1347 [inline]
 __se_sys_creat fs/open.c:1341 [inline]
 __x64_sys_creat+0x8c/0xb0 fs/open.c:1341
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0
RIP: 0033:0x7f44da5a20d9
Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f44d87fa028 EFLAGS: 00000246 ORIG_RAX: 0000000000000055
RAX: ffffffffffffffda RBX: 00007f44da829fa0 RCX: 00007f44da5a20d9
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000200000000380
RBP: 00007f44da639024 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f44da82a038 R14: 00007f44da829fa0 R15: 00007ffda2c2aae8
 </TASK>

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/08/14 13:20 linux-5.15.y aabd761612db 6f9b3e89 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in ocfs2_remove_btree_range
2026/07/28 02:58 linux-5.15.y 674f684f7c61 45ae1df4 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in ocfs2_remove_btree_range
* Struck through repros no longer work on HEAD.