possible deadlock in __ocfs2_reflink

Status: upstream: reported on 2026/10/15 05:17
Reported-by: syzbot+9586878cf9d8a637a33b@syzkaller.appspotmail.com
First crash: 4h48m, last: 4h48m
▶ ▼ Similar bugs (2)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in __ocfs2_reflink prio:high ocfs2 4 4 78d 74d 0/29 upstream: reported on 2026/08/02 00:06
linux-6.1 possible deadlock in __ocfs2_reflink 4 2 58d 66d 0/3 upstream: reported on 2026/08/09 16:23

Sample crash report:
ocfs2: Mounting device (7,8) on (node local, slot 0) with ordered data mode.
======================================================
WARNING: possible circular locking dependency detected
syzkaller #0 Not tainted
------------------------------------------------------
syz.8.2093/14276 is trying to acquire lock:
ffff88805d48b498 (&sb->s_type->i_mutex_key#40/2){+.+.}-{3:3}, at: inode_lock_nested include/linux/fs.h:839 [inline]
ffff88805d48b498 (&sb->s_type->i_mutex_key#40/2){+.+.}-{3:3}, at: __ocfs2_reflink+0xca8/0x16e0 fs/ocfs2/refcounttree.c:4203

but task is already holding lock:
ffff88805d488660 (&ocfs2_file_ip_alloc_sem_key){++++}-{3:3}, at: ocfs2_reflink+0x4cf/0x920 fs/ocfs2/refcounttree.c:4301

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&ocfs2_file_ip_alloc_sem_key){++++}-{3:3}:
       down_read+0x46/0x2e0 kernel/locking/rwsem.c:1520
       ocfs2_inode_lock_for_extent_tree+0xd6/0x190 fs/ocfs2/file.c:2209
       ocfs2_prepare_inode_for_write fs/ocfs2/file.c:2265 [inline]
       ocfs2_file_write_iter+0x6d0/0x1ef0 fs/ocfs2/file.c:2450
       call_write_iter include/linux/fs.h:2018 [inline]
       new_sync_write fs/read_write.c:491 [inline]
       vfs_write+0x474/0x9a0 fs/read_write.c:584
       ksys_pwrite64 fs/read_write.c:699 [inline]
       __do_sys_pwrite64 fs/read_write.c:709 [inline]
       __se_sys_pwrite64 fs/read_write.c:706 [inline]
       __x64_sys_pwrite64+0x198/0x220 fs/read_write.c:706
       do_syscall_x64 arch/x86/entry/common.c:46 [inline]
       do_syscall_64+0x55/0xb0 arch/x86/entry/common.c:76
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

-> #1 (&sb->s_type->i_mutex_key#40){+.+.}-{3:3}:
       down_write+0x97/0x200 kernel/locking/rwsem.c:1573
       inode_lock include/linux/fs.h:804 [inline]
       vfs_rename+0x6f4/0xe60 fs/namei.c:-1
       do_renameat2+0x8b0/0xc80 fs/namei.c:5080
       __do_sys_renameat2 fs/namei.c:5113 [inline]
       __se_sys_renameat2 fs/namei.c:5110 [inline]
       __x64_sys_renameat2+0xd2/0xe0 fs/namei.c:5110
       do_syscall_x64 arch/x86/entry/common.c:46 [inline]
       do_syscall_64+0x55/0xb0 arch/x86/entry/common.c:76
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

-> #0 (&sb->s_type->i_mutex_key#40/2){+.+.}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3162 [inline]
       check_prevs_add kernel/locking/lockdep.c:3281 [inline]
       validate_chain kernel/locking/lockdep.c:3897 [inline]
       __lock_acquire+0x3a07/0x7eb0 kernel/locking/lockdep.c:5171
       lock_acquire+0x19e/0x420 kernel/locking/lockdep.c:5790
       down_write_nested+0x9e/0x200 kernel/locking/rwsem.c:1689
       inode_lock_nested include/linux/fs.h:839 [inline]
       __ocfs2_reflink+0xca8/0x16e0 fs/ocfs2/refcounttree.c:4203
       ocfs2_reflink+0x4e8/0x920 fs/ocfs2/refcounttree.c:4302
       ocfs2_vfs_reflink+0x333/0x450 fs/ocfs2/refcounttree.c:4428
       ocfs2_reflink_ioctl+0x3a0/0x450 fs/ocfs2/refcounttree.c:4468
       ocfs2_ioctl+0x5b9/0x7e0 fs/ocfs2/ioctl.c:923
       vfs_ioctl fs/ioctl.c:51 [inline]
       __do_sys_ioctl fs/ioctl.c:871 [inline]
       __se_sys_ioctl+0xfd/0x170 fs/ioctl.c:857
       do_syscall_x64 arch/x86/entry/common.c:46 [inline]
       do_syscall_64+0x55/0xb0 arch/x86/entry/common.c:76
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

other info that might help us debug this:

Chain exists of:
  &sb->s_type->i_mutex_key#40/2 --> &sb->s_type->i_mutex_key#40 --> &ocfs2_file_ip_alloc_sem_key

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&ocfs2_file_ip_alloc_sem_key);
                               lock(&sb->s_type->i_mutex_key#40);
                               lock(&ocfs2_file_ip_alloc_sem_key);
  lock(&sb->s_type->i_mutex_key#40/2);

 *** DEADLOCK ***

5 locks held by syz.8.2093/14276:
 #0: ffff888057de2418 (sb_writers#15){.+.+}-{0:0}, at: mnt_want_write+0x41/0x90 fs/namespace.c:412
 #1: ffff888051a59818 (&type->i_mutex_dir_key#8/1){+.+.}-{3:3}, at: inode_lock_nested include/linux/fs.h:839 [inline]
 #1: ffff888051a59818 (&type->i_mutex_dir_key#8/1){+.+.}-{3:3}, at: filename_create+0x20f/0x450 fs/namei.c:3937
 #2: ffff88805d4889d8 (&sb->s_type->i_mutex_key#40){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:804 [inline]
 #2: ffff88805d4889d8 (&sb->s_type->i_mutex_key#40){+.+.}-{3:3}, at: ocfs2_vfs_reflink+0x2f3/0x450 fs/ocfs2/refcounttree.c:4425
 #3: ffff88805d4886f8 (&oi->ip_xattr_sem){++++}-{3:3}, at: ocfs2_reflink+0x4c0/0x920 fs/ocfs2/refcounttree.c:4300
 #4: ffff88805d488660 (&ocfs2_file_ip_alloc_sem_key){++++}-{3:3}, at: ocfs2_reflink+0x4cf/0x920 fs/ocfs2/refcounttree.c:4301

stack backtrace:
CPU: 0 PID: 14276 Comm: syz.8.2093 Not tainted syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/24/2026
Call Trace:
 <TASK>
 dump_stack_lvl+0x18c/0x250 lib/dump_stack.c:106
 check_noncircular+0x2fc/0x400 kernel/locking/lockdep.c:2215
 check_prev_add kernel/locking/lockdep.c:3162 [inline]
 check_prevs_add kernel/locking/lockdep.c:3281 [inline]
 validate_chain kernel/locking/lockdep.c:3897 [inline]
 __lock_acquire+0x3a07/0x7eb0 kernel/locking/lockdep.c:5171
 lock_acquire+0x19e/0x420 kernel/locking/lockdep.c:5790
 down_write_nested+0x9e/0x200 kernel/locking/rwsem.c:1689
 inode_lock_nested include/linux/fs.h:839 [inline]
 __ocfs2_reflink+0xca8/0x16e0 fs/ocfs2/refcounttree.c:4203
 ocfs2_reflink+0x4e8/0x920 fs/ocfs2/refcounttree.c:4302
 ocfs2_vfs_reflink+0x333/0x450 fs/ocfs2/refcounttree.c:4428
 ocfs2_reflink_ioctl+0x3a0/0x450 fs/ocfs2/refcounttree.c:4468
 ocfs2_ioctl+0x5b9/0x7e0 fs/ocfs2/ioctl.c:923
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:871 [inline]
 __se_sys_ioctl+0xfd/0x170 fs/ioctl.c:857
 do_syscall_x64 arch/x86/entry/common.c:46 [inline]
 do_syscall_64+0x55/0xb0 arch/x86/entry/common.c:76
 entry_SYSCALL_64_after_hwframe+0x68/0xd2
RIP: 0033:0x7f5a8799e559
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:00007f5a887ec028 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f5a87c25fa0 RCX: 00007f5a8799e559
RDX: 00002000000001c0 RSI: 0000000040186f04 RDI: 0000000000000004
RBP: 00007f5a87a358b0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f5a87c26038 R14: 00007f5a87c25fa0 R15: 00007ffc88898108
 </TASK>

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/10/15 05:17 linux-6.6.y a91a6aa9253c 8fb0ae89 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan possible deadlock in __ocfs2_reflink
2026/10/15 05:17 linux-6.6.y a91a6aa9253c 8fb0ae89 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan possible deadlock in __ocfs2_reflink
* Struck through repros no longer work on HEAD.