syzbot


possible deadlock in ocfs2_calc_xattr_init (2)

Status: upstream: reported on 2025/07/12 15:36
Reported-by: syzbot+58526ea8b63f3d5f4b8a@syzkaller.appspotmail.com
First crash: 6d10h, last: 6d10h
Similar bugs (4)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-6.6 possible deadlock in ocfs2_calc_xattr_init 4 1 5d20h 5d20h 0/2 upstream: reported on 2025/07/13 05:28
upstream possible deadlock in ocfs2_calc_xattr_init ocfs2 4 158 4d12h 288d 0/29 upstream: reported on 2024/10/04 01:35
linux-6.1 possible deadlock in ocfs2_calc_xattr_init 4 6 194d 227d 0/3 auto-obsoleted due to no activity on 2025/04/15 19:53
linux-5.15 possible deadlock in ocfs2_calc_xattr_init 4 14 131d 307d 0/3 auto-obsoleted due to no activity on 2025/06/17 06:29

Sample crash report:
ocfs2: Mounting device (7,1) on (node local, slot 0) with ordered data mode.
======================================================
WARNING: possible circular locking dependency detected
5.15.187-syzkaller #0 Not tainted
------------------------------------------------------
syz.1.264/5884 is trying to acquire lock:
ffff8880741b4e38 (&oi->ip_xattr_sem){++++}-{3:3}, at: ocfs2_calc_xattr_init+0x204/0xd70 fs/ocfs2/xattr.c:631

but task is already holding lock:
ffff88805580ed88 (&ocfs2_sysfile_lock_key[args->fi_sysfile_type]#2){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:787 [inline]
ffff88805580ed88 (&ocfs2_sysfile_lock_key[args->fi_sysfile_type]#2){+.+.}-{3:3}, at: ocfs2_reserve_suballoc_bits+0x161/0x4350 fs/ocfs2/suballoc.c:782

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 (&ocfs2_sysfile_lock_key[args->fi_sysfile_type]#2){+.+.}-{3:3}:
       down_write+0x38/0x60 kernel/locking/rwsem.c:1551
       inode_lock include/linux/fs.h:787 [inline]
       ocfs2_remove_inode fs/ocfs2/inode.c:655 [inline]
       ocfs2_wipe_inode fs/ocfs2/inode.c:818 [inline]
       ocfs2_delete_inode fs/ocfs2/inode.c:1079 [inline]
       ocfs2_evict_inode+0x130f/0x3e40 fs/ocfs2/inode.c:1216
       evict+0x485/0x870 fs/inode.c:647
       do_unlinkat+0x3d8/0x6f0 fs/namei.c:4355
       __do_sys_unlink fs/namei.c:4396 [inline]
       __se_sys_unlink fs/namei.c:4394 [inline]
       __x64_sys_unlink+0x45/0x50 fs/namei.c:4394
       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 (&ocfs2_sysfile_lock_key[args->fi_sysfile_type]){+.+.}-{3:3}:
       down_write+0x38/0x60 kernel/locking/rwsem.c:1551
       inode_lock include/linux/fs.h:787 [inline]
       ocfs2_del_inode_from_orphan+0x131/0x730 fs/ocfs2/namei.c:2713
       ocfs2_dio_end_io_write fs/ocfs2/aops.c:2333 [inline]
       ocfs2_dio_end_io+0x475/0x10f0 fs/ocfs2/aops.c:2431
       dio_complete+0x249/0x720 fs/direct-io.c:272
       do_blockdev_direct_IO fs/direct-io.c:1336 [inline]
       __blockdev_direct_IO+0x30a7/0x3c90 fs/direct-io.c:1368
       ocfs2_direct_IO+0x23e/0x2b0 fs/ocfs2/aops.c:2468
       generic_file_direct_write+0x22c/0x490 mm/filemap.c:3687
       __generic_file_write_iter+0x2b1/0x4e0 mm/filemap.c:3869
       ocfs2_file_write_iter+0x1578/0x1cf0 fs/ocfs2/file.c:2472
       call_write_iter include/linux/fs.h:2172 [inline]
       new_sync_write fs/read_write.c:507 [inline]
       vfs_write+0x712/0xd00 fs/read_write.c:594
       ksys_write+0x14d/0x250 fs/read_write.c:647
       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 (&oi->ip_alloc_sem){++++}-{3:3}:
       down_write+0x38/0x60 kernel/locking/rwsem.c:1551
       ocfs2_try_remove_refcount_tree+0xb3/0x320 fs/ocfs2/refcounttree.c:932
       ocfs2_truncate_file+0xda2/0x13b0 fs/ocfs2/file.c:517
       ocfs2_setattr+0x143b/0x1a10 fs/ocfs2/file.c:1215
       notify_change+0xbcd/0xee0 fs/attr.c:505
       do_truncate+0x197/0x220 fs/open.c:65
       handle_truncate fs/namei.c:3265 [inline]
       do_open fs/namei.c:3612 [inline]
       path_openat+0x28af/0x2f30 fs/namei.c:3742
       do_filp_open+0x1b3/0x3e0 fs/namei.c:3769
       do_sys_openat2+0x142/0x4a0 fs/open.c:1253
       do_sys_open fs/open.c:1269 [inline]
       __do_sys_openat fs/open.c:1285 [inline]
       __se_sys_openat fs/open.c:1280 [inline]
       __x64_sys_openat+0x135/0x160 fs/open.c:1280
       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 (&oi->ip_xattr_sem){++++}-{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+0x2c33/0x7c60 kernel/locking/lockdep.c:5012
       lock_acquire+0x197/0x3f0 kernel/locking/lockdep.c:5623
       down_read+0x44/0x2e0 kernel/locking/rwsem.c:1498
       ocfs2_calc_xattr_init+0x204/0xd70 fs/ocfs2/xattr.c:631
       ocfs2_mknod+0xc7f/0x22b0 fs/ocfs2/namei.c:330
       ocfs2_mkdir+0x192/0x410 fs/ocfs2/namei.c:657
       vfs_mkdir+0x387/0x570 fs/namei.c:4065
       do_mkdirat+0x1d7/0x5a0 fs/namei.c:4090
       __do_sys_mkdirat fs/namei.c:4105 [inline]
       __se_sys_mkdirat fs/namei.c:4103 [inline]
       __x64_sys_mkdirat+0x85/0x90 fs/namei.c:4103
       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:
  &oi->ip_xattr_sem --> &ocfs2_sysfile_lock_key[args->fi_sysfile_type] --> &ocfs2_sysfile_lock_key[args->fi_sysfile_type]#2

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&ocfs2_sysfile_lock_key[args->fi_sysfile_type]#2);
                               lock(&ocfs2_sysfile_lock_key[args->fi_sysfile_type]);
                               lock(&ocfs2_sysfile_lock_key[args->fi_sysfile_type]#2);
  lock(&oi->ip_xattr_sem);

 *** DEADLOCK ***

3 locks held by syz.1.264/5884:
 #0: ffff888064b12460 (sb_writers#18){.+.+}-{0:0}, at: mnt_want_write+0x3d/0x90 fs/namespace.c:377
 #1: ffff8880741b5108 (&type->i_mutex_dir_key#11/1){+.+.}-{3:3}, at: inode_lock_nested include/linux/fs.h:822 [inline]
 #1: ffff8880741b5108 (&type->i_mutex_dir_key#11/1){+.+.}-{3:3}, at: filename_create+0x1f2/0x450 fs/namei.c:3835
 #2: ffff88805580ed88 (&ocfs2_sysfile_lock_key[args->fi_sysfile_type]#2){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:787 [inline]
 #2: ffff88805580ed88 (&ocfs2_sysfile_lock_key[args->fi_sysfile_type]#2){+.+.}-{3:3}, at: ocfs2_reserve_suballoc_bits+0x161/0x4350 fs/ocfs2/suballoc.c:782

stack backtrace:
CPU: 1 PID: 5884 Comm: syz.1.264 Not tainted 5.15.187-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/2025
Call Trace:
 <TASK>
 dump_stack_lvl+0x168/0x230 lib/dump_stack.c:106
 check_noncircular+0x274/0x310 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+0x2c33/0x7c60 kernel/locking/lockdep.c:5012
 lock_acquire+0x197/0x3f0 kernel/locking/lockdep.c:5623
 down_read+0x44/0x2e0 kernel/locking/rwsem.c:1498
 ocfs2_calc_xattr_init+0x204/0xd70 fs/ocfs2/xattr.c:631
 ocfs2_mknod+0xc7f/0x22b0 fs/ocfs2/namei.c:330
 ocfs2_mkdir+0x192/0x410 fs/ocfs2/namei.c:657
 vfs_mkdir+0x387/0x570 fs/namei.c:4065
 do_mkdirat+0x1d7/0x5a0 fs/namei.c:4090
 __do_sys_mkdirat fs/namei.c:4105 [inline]
 __se_sys_mkdirat fs/namei.c:4103 [inline]
 __x64_sys_mkdirat+0x85/0x90 fs/namei.c:4103
 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:0x7f92c519f929
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 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 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f92c3007038 EFLAGS: 00000246 ORIG_RAX: 0000000000000102
RAX: ffffffffffffffda RBX: 00007f92c53c6fa0 RCX: 00007f92c519f929
RDX: 0000000000000000 RSI: 0000200000000100 RDI: ffffffffffffff9c
RBP: 00007f92c5221b39 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f92c53c6fa0 R15: 00007ffe15ef2a28
 </TASK>

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/07/12 15:35 linux-5.15.y 2f693b607545 3cda49cf .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in ocfs2_calc_xattr_init
* Struck through repros no longer work on HEAD.