loop0: detected capacity change from 0 to 262144
JBD2: Ignoring recovery information on journal
ocfs2: Mounting device (7,0) on (node local, slot 0) with writeback data mode.
======================================================
WARNING: possible circular locking dependency detected
6.15.0-rc4-syzkaller-00052-g4f79eaa2ceac #0 Not tainted
------------------------------------------------------
syz.0.0/5321 is trying to acquire lock:
ffff88805881bf60 (&oi->ip_alloc_sem){++++}-{4:4}, at: ocfs2_xattr_ibody_find+0x14b/0x7c0 fs/ocfs2/xattr.c:2689

but task is already holding lock:
ffff88805881bff8 (&oi->ip_xattr_sem){++++}-{4:4}, at: ocfs2_xattr_set+0x40f/0x11f0 fs/ocfs2/xattr.c:3583

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #4 (&oi->ip_xattr_sem){++++}-{4:4}:
       lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5866
       down_read+0x46/0x2e0 kernel/locking/rwsem.c:1524
       ocfs2_init_acl+0x2f9/0x720 fs/ocfs2/acl.c:366
       ocfs2_mknod+0x1321/0x2050 fs/ocfs2/namei.c:410
       ocfs2_create+0x1a5/0x440 fs/ocfs2/namei.c:673
       lookup_open fs/namei.c:3701 [inline]
       open_last_lookups fs/namei.c:3800 [inline]
       path_openat+0x14f1/0x3830 fs/namei.c:4036
       do_filp_open+0x1fa/0x410 fs/namei.c:4066
       do_sys_openat2+0x121/0x1c0 fs/open.c:1429
       do_sys_open fs/open.c:1444 [inline]
       __do_sys_open fs/open.c:1452 [inline]
       __se_sys_open fs/open.c:1448 [inline]
       __x64_sys_open+0x11e/0x150 fs/open.c:1448
       do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
       do_syscall_64+0xf6/0x210 arch/x86/entry/syscall_64.c:94
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #3 (jbd2_handle){++++}-{0:0}:
       lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5866
       start_this_handle+0x1fa7/0x21c0 fs/jbd2/transaction.c:444
       jbd2__journal_start+0x2c1/0x5b0 fs/jbd2/transaction.c:501
       jbd2_journal_start+0x2a/0x40 fs/jbd2/transaction.c:540
       ocfs2_start_trans+0x376/0x6d0 fs/ocfs2/journal.c:352
       ocfs2_mknod+0xe93/0x2050 fs/ocfs2/namei.c:361
       ocfs2_create+0x1a5/0x440 fs/ocfs2/namei.c:673
       lookup_open fs/namei.c:3701 [inline]
       open_last_lookups fs/namei.c:3800 [inline]
       path_openat+0x14f1/0x3830 fs/namei.c:4036
       do_filp_open+0x1fa/0x410 fs/namei.c:4066
       do_sys_openat2+0x121/0x1c0 fs/open.c:1429
       do_sys_open fs/open.c:1444 [inline]
       __do_sys_open fs/open.c:1452 [inline]
       __se_sys_open fs/open.c:1448 [inline]
       __x64_sys_open+0x11e/0x150 fs/open.c:1448
       do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
       do_syscall_64+0xf6/0x210 arch/x86/entry/syscall_64.c:94
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #2 (&journal->j_trans_barrier){.+.+}-{4:4}:
       lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5866
       down_read+0x46/0x2e0 kernel/locking/rwsem.c:1524
       ocfs2_start_trans+0x36a/0x6d0 fs/ocfs2/journal.c:350
       ocfs2_mknod+0xe93/0x2050 fs/ocfs2/namei.c:361
       ocfs2_create+0x1a5/0x440 fs/ocfs2/namei.c:673
       lookup_open fs/namei.c:3701 [inline]
       open_last_lookups fs/namei.c:3800 [inline]
       path_openat+0x14f1/0x3830 fs/namei.c:4036
       do_filp_open+0x1fa/0x410 fs/namei.c:4066
       do_sys_openat2+0x121/0x1c0 fs/open.c:1429
       do_sys_open fs/open.c:1444 [inline]
       __do_sys_open fs/open.c:1452 [inline]
       __se_sys_open fs/open.c:1448 [inline]
       __x64_sys_open+0x11e/0x150 fs/open.c:1448
       do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
       do_syscall_64+0xf6/0x210 arch/x86/entry/syscall_64.c:94
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #1 (sb_internal#2){.+.+}-{0:0}:
       reacquire_held_locks+0x127/0x1d0 kernel/locking/lockdep.c:5383
       __lock_release kernel/locking/lockdep.c:5572 [inline]
       lock_release+0x1b4/0x3e0 kernel/locking/lockdep.c:5887
       up_write+0x2d/0x420 kernel/locking/rwsem.c:1629
       inode_unlock include/linux/fs.h:872 [inline]
       ocfs2_free_ac_resource fs/ocfs2/suballoc.c:130 [inline]
       ocfs2_free_alloc_context+0x97/0x1a0 fs/ocfs2/suballoc.c:144
       ocfs2_write_begin_nolock+0x4296/0x4340 fs/ocfs2/aops.c:1803
       ocfs2_dio_wr_get_block+0xb6f/0x1770 fs/ocfs2/aops.c:2211
       get_more_blocks fs/direct-io.c:648 [inline]
       do_direct_IO fs/direct-io.c:936 [inline]
       __blockdev_direct_IO+0x1649/0x3310 fs/direct-io.c:1243
       ocfs2_direct_IO+0x25f/0x2d0 fs/ocfs2/aops.c:2438
       generic_file_direct_write+0x1d8/0x3e0 mm/filemap.c:4037
       __generic_file_write_iter+0x11d/0x230 mm/filemap.c:4206
       ocfs2_file_write_iter+0x157a/0x1d10 fs/ocfs2/file.c:2469
       do_iter_readv_writev+0x56b/0x7f0 fs/read_write.c:-1
       vfs_writev+0x306/0x9a0 fs/read_write.c:1055
       do_pwritev fs/read_write.c:1151 [inline]
       __do_sys_pwritev2 fs/read_write.c:1209 [inline]
       __se_sys_pwritev2+0x179/0x290 fs/read_write.c:1200
       do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
       do_syscall_64+0xf6/0x210 arch/x86/entry/syscall_64.c:94
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #0 (&oi->ip_alloc_sem){++++}-{4:4}:
       check_prev_add kernel/locking/lockdep.c:3166 [inline]
       check_prevs_add kernel/locking/lockdep.c:3285 [inline]
       validate_chain+0xb9b/0x2140 kernel/locking/lockdep.c:3909
       __lock_acquire+0xaac/0xd20 kernel/locking/lockdep.c:5235
       lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5866
       down_read+0x46/0x2e0 kernel/locking/rwsem.c:1524
       ocfs2_xattr_ibody_find+0x14b/0x7c0 fs/ocfs2/xattr.c:2689
       ocfs2_xattr_set+0x426/0x11f0 fs/ocfs2/xattr.c:3588
       __vfs_setxattr+0x439/0x480 fs/xattr.c:200
       __vfs_setxattr_noperm+0x12d/0x660 fs/xattr.c:234
       vfs_setxattr+0x16b/0x2f0 fs/xattr.c:321
       do_setxattr fs/xattr.c:636 [inline]
       filename_setxattr+0x274/0x600 fs/xattr.c:665
       path_setxattrat+0x364/0x3a0 fs/xattr.c:713
       __do_sys_setxattr fs/xattr.c:747 [inline]
       __se_sys_setxattr fs/xattr.c:743 [inline]
       __x64_sys_setxattr+0xbc/0xe0 fs/xattr.c:743
       do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
       do_syscall_64+0xf6/0x210 arch/x86/entry/syscall_64.c:94
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

other info that might help us debug this:

Chain exists of:
  &oi->ip_alloc_sem --> jbd2_handle --> &oi->ip_xattr_sem

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&oi->ip_xattr_sem);
                               lock(jbd2_handle);
                               lock(&oi->ip_xattr_sem);
  rlock(&oi->ip_alloc_sem);

 *** DEADLOCK ***

3 locks held by syz.0.0/5321:
 #0: ffff88801e1d6420 (sb_writers#12){.+.+}-{0:0}, at: mnt_want_write+0x41/0x90 fs/namespace.c:556
 #1: ffff88805881c2c0 (&sb->s_type->i_mutex_key#20){+.+.}-{4:4}, at: inode_lock include/linux/fs.h:867 [inline]
 #1: ffff88805881c2c0 (&sb->s_type->i_mutex_key#20){+.+.}-{4:4}, at: vfs_setxattr+0x144/0x2f0 fs/xattr.c:320
 #2: ffff88805881bff8 (&oi->ip_xattr_sem){++++}-{4:4}, at: ocfs2_xattr_set+0x40f/0x11f0 fs/ocfs2/xattr.c:3583

stack backtrace:
CPU: 0 UID: 0 PID: 5321 Comm: syz.0.0 Not tainted 6.15.0-rc4-syzkaller-00052-g4f79eaa2ceac #0 PREEMPT(full) 
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
Call Trace:
 <TASK>
 dump_stack_lvl+0x189/0x250 lib/dump_stack.c:120
 print_circular_bug+0x2ee/0x310 kernel/locking/lockdep.c:2079
 check_noncircular+0x134/0x160 kernel/locking/lockdep.c:2211
 check_prev_add kernel/locking/lockdep.c:3166 [inline]
 check_prevs_add kernel/locking/lockdep.c:3285 [inline]
 validate_chain+0xb9b/0x2140 kernel/locking/lockdep.c:3909
 __lock_acquire+0xaac/0xd20 kernel/locking/lockdep.c:5235
 lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5866
 down_read+0x46/0x2e0 kernel/locking/rwsem.c:1524
 ocfs2_xattr_ibody_find+0x14b/0x7c0 fs/ocfs2/xattr.c:2689
 ocfs2_xattr_set+0x426/0x11f0 fs/ocfs2/xattr.c:3588
 __vfs_setxattr+0x439/0x480 fs/xattr.c:200
 __vfs_setxattr_noperm+0x12d/0x660 fs/xattr.c:234
 vfs_setxattr+0x16b/0x2f0 fs/xattr.c:321
 do_setxattr fs/xattr.c:636 [inline]
 filename_setxattr+0x274/0x600 fs/xattr.c:665
 path_setxattrat+0x364/0x3a0 fs/xattr.c:713
 __do_sys_setxattr fs/xattr.c:747 [inline]
 __se_sys_setxattr fs/xattr.c:743 [inline]
 __x64_sys_setxattr+0xbc/0xe0 fs/xattr.c:743
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0xf6/0x210 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fabba78e969
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:00007fabbb6b0038 EFLAGS: 00000246 ORIG_RAX: 00000000000000bc
RAX: ffffffffffffffda RBX: 00007fabba9b5fa0 RCX: 00007fabba78e969
RDX: 0000200000000480 RSI: 0000200000000140 RDI: 0000200000000580
RBP: 00007fabba810ab1 R08: 0000000000000001 R09: 0000000000000000
R10: 0000000000000063 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007fabba9b5fa0 R15: 00007ffded384558
 </TASK>
syz.0.0 (5321) used greatest stack depth: 19272 bytes left