loop4: detected capacity change from 0 to 2048
EXT4-fs (loop4): mounted filesystem 00000000-0000-0000-0000-000000000000 r/w without journal. Quota mode: none.
======================================================
WARNING: possible circular locking dependency detected
syzkaller #0 Not tainted
------------------------------------------------------
syz.4.612/8822 is trying to acquire lock:
ffff8881be57f388 (&ei->xattr_sem){++++}-{4:4}, at: ext4_destroy_inline_data+0x28/0xe0

but task is already holding lock:
ffff8881b1c76b98 (&sbi->s_writepages_rwsem){++++}-{0:0}, at: ext4_writepages+0x204/0x3b0

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&sbi->s_writepages_rwsem){++++}-{0:0}:
       lock_acquire+0x11f/0x350
       percpu_down_read_internal+0x48/0x1c0
       ext4_writepages+0x204/0x3b0
       do_writepages+0x32e/0x550
       __writeback_single_inode+0x145/0xfe0
       writeback_single_inode+0x1f9/0x6a0
       write_inode_now+0x1c2/0x290
       iput+0x82c/0xc50
       ext4_xattr_block_set+0x2359/0x2ad0
       ext4_expand_extra_isize_ea+0x12cf/0x1ea0
       __ext4_expand_extra_isize+0x30d/0x400
       __ext4_mark_inode_dirty+0x46c/0x700
       ext4_evict_inode+0x812/0xee0
       evict+0x53c/0xa00
       ext4_orphan_cleanup+0xc38/0x1470
       ext4_fill_super+0x5a71/0x6330
       get_tree_bdev_flags+0x431/0x4f0
       vfs_get_tree+0x92/0x2b0
       do_new_mount+0x329/0xa50
       __se_sys_mount+0x31d/0x420
       do_syscall_64+0xf0/0xfa0
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #0 (&ei->xattr_sem){++++}-{4:4}:
       validate_chain+0xb9a/0x2130
       __lock_acquire+0xab8/0xd20
       lock_acquire+0x11f/0x350
       down_write+0x96/0x200
       ext4_destroy_inline_data+0x28/0xe0
       ext4_do_writepages+0x55f/0x4710
       ext4_writepages+0x23d/0x3b0
       do_writepages+0x32e/0x550
       filemap_flush+0x1e1/0x2e0
       ext4_convert_inline_data+0x18e/0x600
       ext4_page_mkwrite+0x237/0x11a0
       do_page_mkwrite+0x14d/0x310
       do_wp_page+0x1b10/0x59d0
       __handle_mm_fault+0x1085/0x5940
       handle_mm_fault+0x409/0x8d0
       do_user_addr_fault+0x75b/0x1360
       exc_page_fault+0x7e/0xf0
       asm_exc_page_fault+0x26/0x30
       filldir+0x29b/0x690
       ext4_readdir+0x162c/0x3c50
       iterate_dir+0x399/0x570
       __se_sys_getdents+0xf1/0x270
       do_syscall_64+0xf0/0xfa0
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

other info that might help us debug this:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  rlock(&sbi->s_writepages_rwsem);
                               lock(&ei->xattr_sem);
                               lock(&sbi->s_writepages_rwsem);
  lock(&ei->xattr_sem);

 *** DEADLOCK ***

6 locks held by syz.4.612/8822:
 #0: ffff8881718d6ef8 (&f->f_pos_lock){+.+.}-{4:4}, at: fdget_pos+0x246/0x320
 #1: ffff8881be57aa20 (&type->i_mutex_dir_key#3){++++}-{4:4}, at: iterate_dir+0x292/0x570
 #2: ffff888102f2cd20 (&mm->mmap_lock){++++}-{4:4}, at: lock_mm_and_find_vma+0x36/0x340
 #3: ffff8881b1c74518 (sb_pagefaults){.+.+}-{0:0}, at: ext4_page_mkwrite+0x201/0x11a0
 #4: ffff8881be57f840 (mapping.invalidate_lock#2){++++}-{4:4}, at: ext4_page_mkwrite+0x22a/0x11a0
 #5: ffff8881b1c76b98 (&sbi->s_writepages_rwsem){++++}-{0:0}, at: ext4_writepages+0x204/0x3b0

stack backtrace:
CPU: 0 UID: 0 PID: 8822 Comm: syz.4.612 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+0x1a9/0x280
 print_circular_bug+0x2ed/0x300
 check_noncircular+0x134/0x160
 validate_chain+0xb9a/0x2130
 __lock_acquire+0xab8/0xd20
 lock_acquire+0x11f/0x350
 down_write+0x96/0x200
 ext4_destroy_inline_data+0x28/0xe0
 ext4_do_writepages+0x55f/0x4710
 ext4_writepages+0x23d/0x3b0
 do_writepages+0x32e/0x550
 filemap_flush+0x1e1/0x2e0
 ext4_convert_inline_data+0x18e/0x600
 ext4_page_mkwrite+0x237/0x11a0
 do_page_mkwrite+0x14d/0x310
 do_wp_page+0x1b10/0x59d0
 __handle_mm_fault+0x1085/0x5940
 handle_mm_fault+0x409/0x8d0
 do_user_addr_fault+0x75b/0x1360
 exc_page_fault+0x7e/0xf0
 asm_exc_page_fault+0x26/0x30
RIP: 0010:filldir+0x29b/0x690
Code: 81 ff 4c 89 ff 4c 89 e6 e8 a2 30 81 ff 4d 39 e7 0f 82 7c 02 00 00 49 39 ef 0f 87 73 02 00 00 0f 1f 00 0f ae e8 48 8b 44 24 50 <49> 89 44 24 08 48 8b 4c 24 08 48 8b 44 24 58 48 89 01 48 8b 04 24
RSP: 0018:ffffc9000752fa48 EFLAGS: 00010287
RAX: 0000000000000000 RBX: ffffc9000752fe38 RCX: ffff888173a01d00
RDX: 0000000000000002 RSI: 0000200000001fc0 RDI: 0000200000001fd8
RBP: 00007ffffffff000 R08: 0000000000000002 R09: 0000000000000004
R10: 000000000000002e R11: ffffffff82424320 R12: 0000200000001fc0
R13: ffff888175ef0008 R14: 0000000000000001 R15: 0000200000001fd8
 ext4_readdir+0x162c/0x3c50
 iterate_dir+0x399/0x570
 __se_sys_getdents+0xf1/0x270
 do_syscall_64+0xf0/0xfa0
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7efcff99cdd9
Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 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 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007efd00841028 EFLAGS: 00000246 ORIG_RAX: 000000000000004e
RAX: ffffffffffffffda RBX: 00007efcffc15fa0 RCX: 00007efcff99cdd9
RDX: 00000000000000b8 RSI: 0000200000001fc0 RDI: 0000000000000006
RBP: 00007efcffa32d69 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007efcffc16038 R14: 00007efcffc15fa0 R15: 00007ffc20b10b18
 </TASK>
EXT4-fs error (device loop4): ext4_mb_generate_buddy:1289: group 0, block bitmap and bg descriptor inconsistent: 25 vs 281 free clusters
EXT4-fs (loop4): Delayed block allocation failed for inode 15 at logical offset 0 with max blocks 498 with error 28
EXT4-fs (loop4): This should not happen!! Data will be lost

EXT4-fs (loop4): Total free blocks count 0
EXT4-fs (loop4): Free/Dirty block details
EXT4-fs (loop4): free_blocks=4096
EXT4-fs (loop4): dirty_blocks=512
EXT4-fs (loop4): Block reservation details
EXT4-fs (loop4): i_reserved_data_blocks=32
