syzbot


possible deadlock in ocfs2_calc_xattr_init

Status: upstream: reported on 2024/09/14 01:52
Reported-by: syzbot+4a9db841e5508bea2296@syzkaller.appspotmail.com
First crash: 142d, last: 13d
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in ocfs2_calc_xattr_init ocfs2 92 3h33m 122d 0/28 upstream: reported on 2024/10/04 01:35
linux-6.1 possible deadlock in ocfs2_calc_xattr_init 6 28d 62d 0/3 upstream: reported on 2024/12/03 04:25

Sample crash report:
loop1: detected capacity change from 0 to 32768
ocfs2: Mounting device (7,1) on (node local, slot 0) with ordered data mode.
======================================================
WARNING: possible circular locking dependency detected
5.15.176-syzkaller #0 Not tainted
------------------------------------------------------
syz.1.15/4331 is trying to acquire lock:
ffff888060679538 (&oi->ip_xattr_sem){++++}-{3:3}, at: ocfs2_calc_xattr_init+0x204/0xd60 fs/ocfs2/xattr.c:631

but task is already holding lock:
ffff88805f0b9808 (&ocfs2_sysfile_lock_key[args->fi_sysfile_type]#2){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:789 [inline]
ffff88805f0b9808 (&ocfs2_sysfile_lock_key[args->fi_sysfile_type]#2){+.+.}-{3:3}, at: ocfs2_reserve_suballoc_bits+0x18e/0x4c70 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}:
       lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
       down_write+0x38/0x60 kernel/locking/rwsem.c:1551
       inode_lock include/linux/fs.h:789 [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+0x2023/0x4500 fs/ocfs2/inode.c:1216
       evict+0x529/0x930 fs/inode.c:622
       d_delete_notify include/linux/fsnotify.h:267 [inline]
       vfs_rmdir+0x33c/0x460 fs/namei.c:4162
       do_rmdir+0x368/0x670 fs/namei.c:4210
       __do_sys_unlinkat fs/namei.c:4390 [inline]
       __se_sys_unlinkat fs/namei.c:4384 [inline]
       __x64_sys_unlinkat+0xdc/0xf0 fs/namei.c:4384
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x66/0xd0

-> #2 (&ocfs2_sysfile_lock_key[args->fi_sysfile_type]){+.+.}-{3:3}:
       lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
       down_write+0x38/0x60 kernel/locking/rwsem.c:1551
       inode_lock include/linux/fs.h:789 [inline]
       ocfs2_del_inode_from_orphan+0x155/0x7f0 fs/ocfs2/namei.c:2713
       ocfs2_dio_end_io_write fs/ocfs2/aops.c:2333 [inline]
       ocfs2_dio_end_io+0x556/0x1250 fs/ocfs2/aops.c:2431
       dio_complete+0x25b/0x6e0 fs/direct-io.c:272
       do_blockdev_direct_IO fs/direct-io.c:1336 [inline]
       __blockdev_direct_IO+0x41f2/0x4f40 fs/direct-io.c:1368
       ocfs2_direct_IO+0x250/0x2c0 fs/ocfs2/aops.c:2468
       generic_file_direct_write+0x204/0x460 mm/filemap.c:3687
       __generic_file_write_iter+0x2a2/0x4f0 mm/filemap.c:3869
       ocfs2_file_write_iter+0x1980/0x2120 fs/ocfs2/file.c:2472
       do_iter_readv_writev+0x594/0x7a0
       do_iter_write+0x1e6/0x760 fs/read_write.c:855
       vfs_writev fs/read_write.c:928 [inline]
       do_pwritev+0x219/0x360 fs/read_write.c:1025
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x66/0xd0

-> #1 (&oi->ip_alloc_sem){++++}-{3:3}:
       lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
       down_write+0x38/0x60 kernel/locking/rwsem.c:1551
       ocfs2_try_remove_refcount_tree+0xb2/0x330 fs/ocfs2/refcounttree.c:932
       ocfs2_truncate_file+0xe3c/0x14f0 fs/ocfs2/file.c:517
       ocfs2_setattr+0x16dd/0x1ce0 fs/ocfs2/file.c:1215
       notify_change+0xc6d/0xf50 fs/attr.c:505
       do_truncate+0x21c/0x300 fs/open.c:65
       handle_truncate fs/namei.c:3265 [inline]
       do_open fs/namei.c:3612 [inline]
       path_openat+0x28a3/0x2f20 fs/namei.c:3742
       do_filp_open+0x21c/0x460 fs/namei.c:3769
       do_sys_openat2+0x13b/0x4f0 fs/open.c:1253
       do_sys_open fs/open.c:1269 [inline]
       __do_sys_creat fs/open.c:1345 [inline]
       __se_sys_creat fs/open.c:1339 [inline]
       __x64_sys_creat+0x11f/0x160 fs/open.c:1339
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x3b/0xb0 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+0x1649/0x5930 kernel/locking/lockdep.c:3788
       __lock_acquire+0x1295/0x1ff0 kernel/locking/lockdep.c:5012
       lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
       down_read+0x45/0x2e0 kernel/locking/rwsem.c:1498
       ocfs2_calc_xattr_init+0x204/0xd60 fs/ocfs2/xattr.c:631
       ocfs2_mknod+0x1303/0x2cd0 fs/ocfs2/namei.c:330
       ocfs2_create+0x194/0x430 fs/ocfs2/namei.c:674
       lookup_open fs/namei.c:3462 [inline]
       open_last_lookups fs/namei.c:3532 [inline]
       path_openat+0x130a/0x2f20 fs/namei.c:3739
       do_filp_open+0x21c/0x460 fs/namei.c:3769
       do_sys_openat2+0x13b/0x4f0 fs/open.c:1253
       do_sys_open fs/open.c:1269 [inline]
       __do_sys_open fs/open.c:1277 [inline]
       __se_sys_open fs/open.c:1273 [inline]
       __x64_sys_open+0x221/0x270 fs/open.c:1273
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x3b/0xb0 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.15/4331:
 #0: ffff888075aa2460 (sb_writers#13){.+.+}-{0:0}, at: mnt_want_write+0x3b/0x80 fs/namespace.c:377
 #1: ffff888060679808 (&type->i_mutex_dir_key#9){++++}-{3:3}, at: inode_lock include/linux/fs.h:789 [inline]
 #1: ffff888060679808 (&type->i_mutex_dir_key#9){++++}-{3:3}, at: open_last_lookups fs/namei.c:3529 [inline]
 #1: ffff888060679808 (&type->i_mutex_dir_key#9){++++}-{3:3}, at: path_openat+0x824/0x2f20 fs/namei.c:3739
 #2: ffff88805f0b9808 (&ocfs2_sysfile_lock_key[args->fi_sysfile_type]#2){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:789 [inline]
 #2: ffff88805f0b9808 (&ocfs2_sysfile_lock_key[args->fi_sysfile_type]#2){+.+.}-{3:3}, at: ocfs2_reserve_suballoc_bits+0x18e/0x4c70 fs/ocfs2/suballoc.c:782

stack backtrace:
CPU: 1 PID: 4331 Comm: syz.1.15 Not tainted 5.15.176-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 12/27/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2d0 lib/dump_stack.c:106
 check_noncircular+0x2f8/0x3b0 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+0x1649/0x5930 kernel/locking/lockdep.c:3788
 __lock_acquire+0x1295/0x1ff0 kernel/locking/lockdep.c:5012
 lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
 down_read+0x45/0x2e0 kernel/locking/rwsem.c:1498
 ocfs2_calc_xattr_init+0x204/0xd60 fs/ocfs2/xattr.c:631
 ocfs2_mknod+0x1303/0x2cd0 fs/ocfs2/namei.c:330
 ocfs2_create+0x194/0x430 fs/ocfs2/namei.c:674
 lookup_open fs/namei.c:3462 [inline]
 open_last_lookups fs/namei.c:3532 [inline]
 path_openat+0x130a/0x2f20 fs/namei.c:3739
 do_filp_open+0x21c/0x460 fs/namei.c:3769
 do_sys_openat2+0x13b/0x4f0 fs/open.c:1253
 do_sys_open fs/open.c:1269 [inline]
 __do_sys_open fs/open.c:1277 [inline]
 __se_sys_open fs/open.c:1273 [inline]
 __x64_sys_open+0x221/0x270 fs/open.c:1273
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0
RIP: 0033:0x7f9ed1369d29
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:00007f9ecf1da038 EFLAGS: 00000246 ORIG_RAX: 0000000000000002
RAX: ffffffffffffffda RBX: 00007f9ed1559fa0 RCX: 00007f9ed1369d29
RDX: 0000000000000000 RSI: 0000000000145142 RDI: 0000000020000240
RBP: 00007f9ed13e5b08 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f9ed1559fa0 R15: 00007ffde929ac68
 </TASK>

Crashes (12):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/01/21 11:20 linux-5.15.y 4735586da88e 6e87cfa2 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in ocfs2_calc_xattr_init
2025/01/21 11:18 linux-5.15.y 4735586da88e 6e87cfa2 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in ocfs2_calc_xattr_init
2025/01/21 11:15 linux-5.15.y 4735586da88e 6e87cfa2 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in ocfs2_calc_xattr_init
2025/01/09 21:15 linux-5.15.y 4735586da88e 9220929f .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in ocfs2_calc_xattr_init
2024/12/28 22:47 linux-5.15.y 91786f140358 d3ccff63 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in ocfs2_calc_xattr_init
2024/12/04 01:04 linux-5.15.y 0a51d2d4527b b50eb251 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in ocfs2_calc_xattr_init
2024/12/02 17:57 linux-5.15.y 0a51d2d4527b b499ea68 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in ocfs2_calc_xattr_init
2024/12/02 17:56 linux-5.15.y 0a51d2d4527b b499ea68 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in ocfs2_calc_xattr_init
2024/11/18 19:13 linux-5.15.y 0a51d2d4527b e7bb5d6e .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in ocfs2_calc_xattr_init
2024/10/15 01:27 linux-5.15.y 3a5928702e71 b01b6661 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in ocfs2_calc_xattr_init
2024/09/14 04:28 linux-5.15.y 3a5928702e71 b58f933c .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in ocfs2_calc_xattr_init
2024/09/14 01:51 linux-5.15.y 3a5928702e71 b58f933c .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.