======================================================
WARNING: possible circular locking dependency detected
5.15.164-syzkaller #0 Not tainted
------------------------------------------------------
syz.0.1148/8702 is trying to acquire lock:
ffff8880701353b0 (&ea_inode->i_rwsem#9/1){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:789 [inline]
ffff8880701353b0 (&ea_inode->i_rwsem#9/1){+.+.}-{3:3}, at: ext4_xattr_inode_iget+0x425/0x5e0 fs/ext4/xattr.c:425

but task is already holding lock:
ffff888070136628 (&ei->i_data_sem/3){++++}-{3:3}, at: ext4_truncate+0x974/0x1130 fs/ext4/inode.c:4233

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&ei->i_data_sem/3){++++}-{3:3}:
       lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
       down_write+0x38/0x60 kernel/locking/rwsem.c:1551
       ext4_update_i_disksize fs/ext4/ext4.h:3401 [inline]
       ext4_xattr_inode_write fs/ext4/xattr.c:1397 [inline]
       ext4_xattr_inode_lookup_create fs/ext4/xattr.c:1545 [inline]
       ext4_xattr_set_entry+0x34be/0x3fb0 fs/ext4/xattr.c:1669
       ext4_xattr_block_set+0xb10/0x36a0 fs/ext4/xattr.c:1989
       ext4_xattr_set_handle+0xdac/0x1560 fs/ext4/xattr.c:2406
       ext4_xattr_set+0x231/0x3d0 fs/ext4/xattr.c:2507
       __vfs_setxattr+0x3e7/0x420 fs/xattr.c:182
       __vfs_setxattr_noperm+0x12a/0x5e0 fs/xattr.c:216
       vfs_setxattr+0x21d/0x420 fs/xattr.c:303
       do_setxattr fs/xattr.c:588 [inline]
       setxattr+0x27e/0x2e0 fs/xattr.c:611
       path_setxattr+0x1bc/0x2a0 fs/xattr.c:630
       __do_sys_setxattr fs/xattr.c:646 [inline]
       __se_sys_setxattr fs/xattr.c:642 [inline]
       __x64_sys_setxattr+0xb7/0xd0 fs/xattr.c:642
       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 (&ea_inode->i_rwsem#9/1){+.+.}-{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_write+0x38/0x60 kernel/locking/rwsem.c:1551
       inode_lock include/linux/fs.h:789 [inline]
       ext4_xattr_inode_iget+0x425/0x5e0 fs/ext4/xattr.c:425
       ext4_xattr_inode_get+0x17d/0x9a0 fs/ext4/xattr.c:485
       ext4_xattr_move_to_block fs/ext4/xattr.c:2589 [inline]
       ext4_xattr_make_inode_space fs/ext4/xattr.c:2691 [inline]
       ext4_expand_extra_isize_ea+0xe70/0x1bb0 fs/ext4/xattr.c:2783
       __ext4_expand_extra_isize+0x2f7/0x3d0 fs/ext4/inode.c:5840
       ext4_try_to_expand_extra_isize fs/ext4/inode.c:5883 [inline]
       __ext4_mark_inode_dirty+0x539/0x860 fs/ext4/inode.c:5961
       ext4_ext_truncate+0x9a/0x250 fs/ext4/extents.c:4431
       ext4_truncate+0x9fd/0x1130 fs/ext4/inode.c:4238
       ext4_evict_inode+0xba1/0x1100 fs/ext4/inode.c:289
       evict+0x2a4/0x620 fs/inode.c:587
       __dentry_kill+0x436/0x650 fs/dcache.c:586
       dentry_kill+0xbb/0x290
       dput+0xd8/0x1a0 fs/dcache.c:893
       do_renameat2+0xe1c/0x1700 fs/namei.c:4987
       __do_sys_renameat2 fs/namei.c:5018 [inline]
       __se_sys_renameat2 fs/namei.c:5015 [inline]
       __x64_sys_renameat2+0xce/0xe0 fs/namei.c:5015
       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:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&ei->i_data_sem/3);
                               lock(&ea_inode->i_rwsem#9/1);
                               lock(&ei->i_data_sem/3);
  lock(&ea_inode->i_rwsem#9/1);

 *** DEADLOCK ***

7 locks held by syz.0.1148/8702:
 #0: ffff88805901a460 (sb_writers#5){++++}-{0:0}, at: mnt_want_write+0x3b/0x80 fs/namespace.c:377
 #1: ffff88805901a748 (&type->s_vfs_rename_key#6){+.+.}-{3:3}, at: lock_rename fs/namei.c:3016 [inline]
 #1: ffff88805901a748 (&type->s_vfs_rename_key#6){+.+.}-{3:3}, at: do_renameat2+0x5b7/0x1700 fs/namei.c:4924
 #2: ffff888058ddc9b8 (&type->i_mutex_dir_key#4/1){+.+.}-{3:3}, at: lock_rename fs/namei.c:3017 [inline]
 #2: ffff888058ddc9b8 (&type->i_mutex_dir_key#4/1){+.+.}-{3:3}, at: do_renameat2+0x644/0x1700 fs/namei.c:4924
 #3: ffff888070130de8 (&type->i_mutex_dir_key#4/5){+.+.}-{3:3}, at: do_renameat2+0x67e/0x1700 fs/namei.c:4924
 #4: ffff88805901a650 (sb_internal){++++}-{0:0}, at: __sb_start_write include/linux/fs.h:1811 [inline]
 #4: ffff88805901a650 (sb_internal){++++}-{0:0}, at: sb_start_intwrite include/linux/fs.h:1928 [inline]
 #4: ffff88805901a650 (sb_internal){++++}-{0:0}, at: ext4_evict_inode+0x375/0x1100 fs/ext4/inode.c:243
 #5: ffff888070136628 (&ei->i_data_sem/3){++++}-{3:3}, at: ext4_truncate+0x974/0x1130 fs/ext4/inode.c:4233
 #6: ffff888070136478 (&ei->xattr_sem){++++}-{3:3}, at: ext4_write_trylock_xattr fs/ext4/xattr.h:162 [inline]
 #6: ffff888070136478 (&ei->xattr_sem){++++}-{3:3}, at: ext4_try_to_expand_extra_isize fs/ext4/inode.c:5880 [inline]
 #6: ffff888070136478 (&ei->xattr_sem){++++}-{3:3}, at: __ext4_mark_inode_dirty+0x4a0/0x860 fs/ext4/inode.c:5961

stack backtrace:
CPU: 0 PID: 8702 Comm: syz.0.1148 Not tainted 5.15.164-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/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_write+0x38/0x60 kernel/locking/rwsem.c:1551
 inode_lock include/linux/fs.h:789 [inline]
 ext4_xattr_inode_iget+0x425/0x5e0 fs/ext4/xattr.c:425
 ext4_xattr_inode_get+0x17d/0x9a0 fs/ext4/xattr.c:485
 ext4_xattr_move_to_block fs/ext4/xattr.c:2589 [inline]
 ext4_xattr_make_inode_space fs/ext4/xattr.c:2691 [inline]
 ext4_expand_extra_isize_ea+0xe70/0x1bb0 fs/ext4/xattr.c:2783
 __ext4_expand_extra_isize+0x2f7/0x3d0 fs/ext4/inode.c:5840
 ext4_try_to_expand_extra_isize fs/ext4/inode.c:5883 [inline]
 __ext4_mark_inode_dirty+0x539/0x860 fs/ext4/inode.c:5961
 ext4_ext_truncate+0x9a/0x250 fs/ext4/extents.c:4431
 ext4_truncate+0x9fd/0x1130 fs/ext4/inode.c:4238
 ext4_evict_inode+0xba1/0x1100 fs/ext4/inode.c:289
 evict+0x2a4/0x620 fs/inode.c:587
 __dentry_kill+0x436/0x650 fs/dcache.c:586
 dentry_kill+0xbb/0x290
 dput+0xd8/0x1a0 fs/dcache.c:893
 do_renameat2+0xe1c/0x1700 fs/namei.c:4987
 __do_sys_renameat2 fs/namei.c:5018 [inline]
 __se_sys_renameat2 fs/namei.c:5015 [inline]
 __x64_sys_renameat2+0xce/0xe0 fs/namei.c:5015
 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:0x7fdec4d5d9f9
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:00007fdec31dc048 EFLAGS: 00000246 ORIG_RAX: 000000000000013c
RAX: ffffffffffffffda RBX: 00007fdec4eebf80 RCX: 00007fdec4d5d9f9
RDX: 0000000000000005 RSI: 0000000020000080 RDI: 0000000000000006
RBP: 00007fdec4dcb8ee R08: 0000000000000000 R09: 0000000000000000
R10: 00000000200000c0 R11: 0000000000000246 R12: 0000000000000000
R13: 000000000000000b R14: 00007fdec4eebf80 R15: 00007ffc3255ee28
 </TASK>