======================================================
WARNING: possible circular locking dependency detected
syzkaller #0 Not tainted
------------------------------------------------------
syz.0.100/6489 is trying to acquire lock:
ffff8881200106f8 (&oi->ip_xattr_sem){++++}-{4:4}, at: ocfs2_calc_xattr_init+0x20a/0xd80

but task is already holding lock:
ffff888120131840 (&ocfs2_sysfile_lock_key[INODE_ALLOC_SYSTEM_INODE]){+.+.}-{4:4}, at: ocfs2_reserve_suballoc_bits+0x15e/0x4640

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 (&ocfs2_sysfile_lock_key[INODE_ALLOC_SYSTEM_INODE]){+.+.}-{4:4}:
       lock_acquire+0x120/0x360
       down_write+0x96/0x1f0
       ocfs2_evict_inode+0x153d/0x4100
       evict+0x504/0x9c0
       ocfs2_dentry_iput+0x247/0x370
       __dentry_kill+0x209/0x660
       dput+0x19f/0x2b0
       __fput+0x68e/0xa70
       task_work_run+0x1d4/0x260
       exit_to_user_mode_loop+0xe9/0x130
       do_syscall_64+0x2bd/0xfa0
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #2 (&ocfs2_sysfile_lock_key[ORPHAN_DIR_SYSTEM_INODE]){+.+.}-{4:4}:
       lock_acquire+0x120/0x360
       down_write+0x96/0x1f0
       ocfs2_del_inode_from_orphan+0x134/0x740
       ocfs2_dio_end_io+0x479/0x10f0
       dio_complete+0x25b/0x790
       __blockdev_direct_IO+0x2e63/0x3490
       ocfs2_direct_IO+0x25f/0x2d0
       generic_file_direct_write+0x1db/0x3e0
       __generic_file_write_iter+0x11d/0x230
       ocfs2_file_write_iter+0x157a/0x1d10
       iter_file_splice_write+0x975/0x10e0
       direct_splice_actor+0x101/0x160
       splice_direct_to_actor+0x5a8/0xcc0
       do_splice_direct+0x181/0x270
       do_sendfile+0x4da/0x7e0
       __se_sys_sendfile64+0x13e/0x190
       do_syscall_64+0xfa/0xfa0
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #1 (&oi->ip_alloc_sem){++++}-{4:4}:
       lock_acquire+0x120/0x360
       down_write+0x96/0x1f0
       ocfs2_try_remove_refcount_tree+0xb6/0x320
       ocfs2_truncate_file+0xda0/0x1420
       ocfs2_setattr+0x1520/0x1b40
       notify_change+0xc1a/0xf40
       do_truncate+0x1a4/0x220
       vfs_truncate+0x493/0x520
       do_sys_truncate+0xdb/0x190
       __x64_sys_truncate+0x5b/0x70
       do_syscall_64+0xfa/0xfa0
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #0 (&oi->ip_xattr_sem){++++}-{4:4}:
       validate_chain+0xb9b/0x2140
       __lock_acquire+0xab9/0xd20
       lock_acquire+0x120/0x360
       down_read+0x46/0x2e0
       ocfs2_calc_xattr_init+0x20a/0xd80
       ocfs2_mknod+0xc92/0x2050
       vfs_mknod+0x37f/0x3c0
       do_mknodat+0x385/0x4d0
       __x64_sys_mknod+0x8c/0xa0
       do_syscall_64+0xfa/0xfa0
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

other info that might help us debug this:

Chain exists of:
  &oi->ip_xattr_sem --> &ocfs2_sysfile_lock_key[ORPHAN_DIR_SYSTEM_INODE] --> &ocfs2_sysfile_lock_key[INODE_ALLOC_SYSTEM_INODE]

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&ocfs2_sysfile_lock_key[INODE_ALLOC_SYSTEM_INODE]);
                               lock(&ocfs2_sysfile_lock_key[ORPHAN_DIR_SYSTEM_INODE]);
                               lock(&ocfs2_sysfile_lock_key[INODE_ALLOC_SYSTEM_INODE]);
  rlock(&oi->ip_xattr_sem);

 *** DEADLOCK ***

3 locks held by syz.0.100/6489:
 #0: ffff88810bf4e420 (sb_writers#25){.+.+}-{0:0}, at: mnt_want_write+0x41/0x90
 #1: ffff8881200109c0 (&type->i_mutex_dir_key#18/1){+.+.}-{4:4}, at: filename_create+0x1f8/0x3c0
 #2: ffff888120131840 (&ocfs2_sysfile_lock_key[INODE_ALLOC_SYSTEM_INODE]){+.+.}-{4:4}, at: ocfs2_reserve_suballoc_bits+0x15e/0x4640

stack backtrace:
CPU: 0 UID: 0 PID: 6489 Comm: syz.0.100 Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.2-debian-1.16.2-1 04/01/2014
Call Trace:
 <TASK>
 dump_stack_lvl+0x189/0x250
 print_circular_bug+0x2ee/0x310
 check_noncircular+0x134/0x160
 validate_chain+0xb9b/0x2140
 __lock_acquire+0xab9/0xd20
 lock_acquire+0x120/0x360
 down_read+0x46/0x2e0
 ocfs2_calc_xattr_init+0x20a/0xd80
 ocfs2_mknod+0xc92/0x2050
 vfs_mknod+0x37f/0x3c0
 do_mknodat+0x385/0x4d0
 __x64_sys_mknod+0x8c/0xa0
 do_syscall_64+0xfa/0xfa0
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f219258efc9
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:00007f2193379038 EFLAGS: 00000246 ORIG_RAX: 0000000000000085
RAX: ffffffffffffffda RBX: 00007f21927e5fa0 RCX: 00007f219258efc9
RDX: 0000000000000701 RSI: 0000000000002000 RDI: 00002000000009c0
RBP: 00007f2192611f91 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f21927e6038 R14: 00007f21927e5fa0 R15: 00007fff0a4d6e58
 </TASK>
syz.0.100: attempt to access beyond end of device
loop0: rw=2051, sector=28680, nr_sectors = 28664 limit=32768
(syz.0.100,6489,1):ocfs2_trim_group:7529 ERROR: status = -5
(syz.0.100,6489,1):ocfs2_trim_mainbm:7640 ERROR: status = -5
overlayfs: upper fs does not support tmpfile.
overlayfs: upper fs does not support RENAME_WHITEOUT.
overlayfs: upper fs missing required features.
