syzbot


possible deadlock in ocfs2_calc_xattr_init

Status: upstream: reported on 2024/12/03 04:25
Reported-by: syzbot+7cae27e9271be0915070@syzkaller.appspotmail.com
First crash: 18d, last: 11d
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in ocfs2_calc_xattr_init ocfs2 71 6d03h 79d 0/28 upstream: reported on 2024/10/04 01:35
linux-5.15 possible deadlock in ocfs2_calc_xattr_init 7 18d 99d 0/3 upstream: reported on 2024/09/14 01:52

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

but task is already holding lock:
ffff88805364df48 (&ocfs2_sysfile_lock_key[args->fi_sysfile_type]#2){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:758 [inline]
ffff88805364df48 (&ocfs2_sysfile_lock_key[args->fi_sysfile_type]#2){+.+.}-{3:3}, at: ocfs2_reserve_suballoc_bits+0x182/0x5190 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+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
       down_write+0x36/0x60 kernel/locking/rwsem.c:1573
       inode_lock include/linux/fs.h:758 [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+0x17ce/0x4c30 fs/ocfs2/inode.c:1216
       evict+0x529/0x930 fs/inode.c:701
       ocfs2_dentry_iput+0x22e/0x380 fs/ocfs2/dcache.c:418
       __dentry_kill+0x436/0x650 fs/dcache.c:611
       dentry_kill+0xbb/0x290
       dput+0xfb/0x1d0 fs/dcache.c:918
       ovl_check_rename_whiteout fs/overlayfs/super.c:1325 [inline]
       ovl_make_workdir fs/overlayfs/super.c:1424 [inline]
       ovl_get_workdir+0xcc1/0x17b0 fs/overlayfs/super.c:1539
       ovl_fill_super+0x1b85/0x2a20 fs/overlayfs/super.c:2095
       mount_nodev+0x52/0xe0 fs/super.c:1489
       legacy_get_tree+0xeb/0x180 fs/fs_context.c:632
       vfs_get_tree+0x88/0x270 fs/super.c:1573
       do_new_mount+0x2ba/0xb40 fs/namespace.c:3056
       do_mount fs/namespace.c:3399 [inline]
       __do_sys_mount fs/namespace.c:3607 [inline]
       __se_sys_mount+0x2d5/0x3c0 fs/namespace.c:3584
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

-> #2 (&ocfs2_sysfile_lock_key[args->fi_sysfile_type]){+.+.}-{3:3}:
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
       down_write+0x36/0x60 kernel/locking/rwsem.c:1573
       inode_lock include/linux/fs.h:758 [inline]
       ocfs2_del_inode_from_orphan+0x155/0x7f0 fs/ocfs2/namei.c:2711
       ocfs2_dio_end_io_write fs/ocfs2/aops.c:2333 [inline]
       ocfs2_dio_end_io+0x556/0x1250 fs/ocfs2/aops.c:2431
       dio_complete+0x24a/0x7b0 fs/direct-io.c:271
       __blockdev_direct_IO+0x3ffb/0x4810 fs/direct-io.c:1326
       ocfs2_direct_IO+0x250/0x2c0 fs/ocfs2/aops.c:2468
       generic_file_direct_write+0x204/0x460 mm/filemap.c:3769
       __generic_file_write_iter+0x1c4/0x400 mm/filemap.c:3929
       ocfs2_file_write_iter+0x17c6/0x2020 fs/ocfs2/file.c:2467
       call_write_iter include/linux/fs.h:2265 [inline]
       new_sync_write fs/read_write.c:491 [inline]
       vfs_write+0x857/0xbc0 fs/read_write.c:584
       ksys_write+0x19c/0x2c0 fs/read_write.c:637
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

-> #1 (&oi->ip_alloc_sem){++++}-{3:3}:
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
       down_write+0x36/0x60 kernel/locking/rwsem.c:1573
       ocfs2_try_remove_refcount_tree+0xb2/0x330 fs/ocfs2/refcounttree.c:932
       ocfs2_truncate_file+0xea2/0x1630 fs/ocfs2/file.c:517
       ocfs2_setattr+0x17c5/0x1e60 fs/ocfs2/file.c:1212
       notify_change+0xce3/0xfc0 fs/attr.c:499
       do_truncate+0x21c/0x300 fs/open.c:65
       handle_truncate fs/namei.c:3285 [inline]
       do_open fs/namei.c:3630 [inline]
       path_openat+0x27e2/0x2e60 fs/namei.c:3783
       do_filp_open+0x230/0x480 fs/namei.c:3810
       do_sys_openat2+0x13b/0x4f0 fs/open.c:1318
       do_sys_open fs/open.c:1334 [inline]
       __do_sys_openat fs/open.c:1350 [inline]
       __se_sys_openat fs/open.c:1345 [inline]
       __x64_sys_openat+0x243/0x290 fs/open.c:1345
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

-> #0 (&oi->ip_xattr_sem){++++}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3090 [inline]
       check_prevs_add kernel/locking/lockdep.c:3209 [inline]
       validate_chain+0x1661/0x5950 kernel/locking/lockdep.c:3825
       __lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5049
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
       down_read+0xad/0xa30 kernel/locking/rwsem.c:1520
       ocfs2_calc_xattr_init+0x204/0xd60 fs/ocfs2/xattr.c:631
       ocfs2_mknod+0x137c/0x2e20 fs/ocfs2/namei.c:328
       ocfs2_mkdir+0x1c0/0x4e0 fs/ocfs2/namei.c:655
       vfs_mkdir+0x3b6/0x590 fs/namei.c:4106
       do_mkdirat+0x225/0x360 fs/namei.c:4131
       __do_sys_mkdirat fs/namei.c:4146 [inline]
       __se_sys_mkdirat fs/namei.c:4144 [inline]
       __x64_sys_mkdirat+0x85/0x90 fs/namei.c:4144
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

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.0.1753/13615:
 #0: ffff888028402460 (sb_writers#35){.+.+}-{0:0}, at: mnt_want_write+0x3b/0x80 fs/namespace.c:393
 #1: ffff88807bbfb488 (&type->i_mutex_dir_key#22/1){+.+.}-{3:3}, at: inode_lock_nested include/linux/fs.h:793 [inline]
 #1: ffff88807bbfb488 (&type->i_mutex_dir_key#22/1){+.+.}-{3:3}, at: filename_create+0x25c/0x530 fs/namei.c:3876
 #2: ffff88805364df48 (&ocfs2_sysfile_lock_key[args->fi_sysfile_type]#2){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:758 [inline]
 #2: ffff88805364df48 (&ocfs2_sysfile_lock_key[args->fi_sysfile_type]#2){+.+.}-{3:3}, at: ocfs2_reserve_suballoc_bits+0x182/0x5190 fs/ocfs2/suballoc.c:782

stack backtrace:
CPU: 0 PID: 13615 Comm: syz.0.1753 Not tainted 6.1.119-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 check_noncircular+0x2fa/0x3b0 kernel/locking/lockdep.c:2170
 check_prev_add kernel/locking/lockdep.c:3090 [inline]
 check_prevs_add kernel/locking/lockdep.c:3209 [inline]
 validate_chain+0x1661/0x5950 kernel/locking/lockdep.c:3825
 __lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5049
 lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
 down_read+0xad/0xa30 kernel/locking/rwsem.c:1520
 ocfs2_calc_xattr_init+0x204/0xd60 fs/ocfs2/xattr.c:631
 ocfs2_mknod+0x137c/0x2e20 fs/ocfs2/namei.c:328
 ocfs2_mkdir+0x1c0/0x4e0 fs/ocfs2/namei.c:655
 vfs_mkdir+0x3b6/0x590 fs/namei.c:4106
 do_mkdirat+0x225/0x360 fs/namei.c:4131
 __do_sys_mkdirat fs/namei.c:4146 [inline]
 __se_sys_mkdirat fs/namei.c:4144 [inline]
 __x64_sys_mkdirat+0x85/0x90 fs/namei.c:4144
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2
RIP: 0033:0x7f549eb7ff19
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:00007f549f8c2058 EFLAGS: 00000246 ORIG_RAX: 0000000000000102
RAX: ffffffffffffffda RBX: 00007f549ed45fa0 RCX: 00007f549eb7ff19
RDX: 0000000000000000 RSI: 00000000200000c0 RDI: ffffffffffffff9c
RBP: 00007f549ebf3cc8 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f549ed45fa0 R15: 00007ffc3d446ea8
 </TASK>

Crashes (5):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/12/10 07:53 linux-6.1.y e4d90d63d385 cfc402b4 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in ocfs2_calc_xattr_init
2024/12/06 13:01 linux-6.1.y e4d90d63d385 946d28f0 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in ocfs2_calc_xattr_init
2024/12/06 13:01 linux-6.1.y e4d90d63d385 946d28f0 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in ocfs2_calc_xattr_init
2024/12/03 04:24 linux-6.1.y e4d90d63d385 578925bc .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in ocfs2_calc_xattr_init
2024/12/03 04:24 linux-6.1.y e4d90d63d385 578925bc .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in ocfs2_calc_xattr_init
* Struck through repros no longer work on HEAD.