======================================================
WARNING: possible circular locking dependency detected
6.2.0-rc1-next-20221226 #1 Not tainted
------------------------------------------------------
syz-executor.4/13567 is trying to acquire lock:
ffff88800ff1c170 (&journal->j_barrier){+.+.}-{3:3}, at: jbd2_journal_lock_updates+0x162/0x310
but task is already holding lock:
ffff88800ff1ab90 (&sbi->s_writepages_rwsem){++++}-{0:0}, at: ext4_change_inode_journal_flag+0x17f/0x550
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #3 (&sbi->s_writepages_rwsem){++++}-{0:0}:
percpu_down_write+0x51/0x350
ext4_ind_migrate+0x23b/0x840
ext4_fileattr_set+0x1521/0x19f0
vfs_fileattr_set+0x780/0xb90
do_vfs_ioctl+0xfa6/0x15d0
__x64_sys_ioctl+0x110/0x210
do_syscall_64+0x3f/0x90
entry_SYSCALL_64_after_hwframe+0x72/0xdc
-> #2 (&sb->s_type->i_mutex_key#6){++++}-{3:3}:
down_read+0x9c/0x450
ext4_bmap+0x52/0x470
bmap+0xb0/0x130
jbd2_journal_bmap+0xac/0x190
jbd2_journal_flush+0x857/0xc10
__ext4_ioctl+0x9db/0x43b0
__x64_sys_ioctl+0x19e/0x210
do_syscall_64+0x3f/0x90
entry_SYSCALL_64_after_hwframe+0x72/0xdc
-> #1 (&journal->j_checkpoint_mutex){+.+.}-{3:3}:
mutex_lock_io_nested+0x14c/0x1330
jbd2_journal_flush+0x19e/0xc10
ext4_ioctl_group_add+0x2b3/0x580
__ext4_ioctl+0x6a2/0x43b0
__x64_sys_ioctl+0x19e/0x210
do_syscall_64+0x3f/0x90
entry_SYSCALL_64_after_hwframe+0x72/0xdc
-> #0 (&journal->j_barrier){+.+.}-{3:3}:
__lock_acquire+0x2a02/0x5e70
lock_acquire.part.0+0x11e/0x340
__mutex_lock+0x136/0x14e0
jbd2_journal_lock_updates+0x162/0x310
ext4_change_inode_journal_flag+0x187/0x550
ext4_fileattr_set+0x14fa/0x19f0
vfs_fileattr_set+0x780/0xb90
do_vfs_ioctl+0xfa6/0x15d0
__x64_sys_ioctl+0x110/0x210
do_syscall_64+0x3f/0x90
entry_SYSCALL_64_after_hwframe+0x72/0xdc
other info that might help us debug this:
Chain exists of:
&journal->j_barrier --> &sb->s_type->i_mutex_key#6 --> &sbi->s_writepages_rwsem
Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(&sbi->s_writepages_rwsem);
lock(&sb->s_type->i_mutex_key#6);
lock(&sbi->s_writepages_rwsem);
lock(&journal->j_barrier);
*** DEADLOCK ***
4 locks held by syz-executor.4/13567:
#0: ffff88800ff18438 (sb_writers#3){.+.+}-{0:0}, at: do_vfs_ioctl+0xf6b/0x15d0
#1: ffff888019d24990 (&sb->s_type->i_mutex_key#6){++++}-{3:3}, at: vfs_fileattr_set+0x14c/0xb90
#2: ffff888019d24b30 (mapping.invalidate_lock){++++}-{3:3}, at: ext4_change_inode_journal_flag+0x126/0x550
#3: ffff88800ff1ab90 (&sbi->s_writepages_rwsem){++++}-{0:0}, at: ext4_change_inode_journal_flag+0x17f/0x550
stack backtrace:
CPU: 0 PID: 13567 Comm: syz-executor.4 Not tainted 6.2.0-rc1-next-20221226 #1
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014
Call Trace:
dump_stack_lvl+0x8f/0xb7
check_noncircular+0x263/0x2e0
__lock_acquire+0x2a02/0x5e70
lock_acquire.part.0+0x11e/0x340
__mutex_lock+0x136/0x14e0
jbd2_journal_lock_updates+0x162/0x310
ext4_change_inode_journal_flag+0x187/0x550
ext4_fileattr_set+0x14fa/0x19f0
vfs_fileattr_set+0x780/0xb90
do_vfs_ioctl+0xfa6/0x15d0
__x64_sys_ioctl+0x110/0x210
do_syscall_64+0x3f/0x90
entry_SYSCALL_64_after_hwframe+0x72/0xdc
RIP: 0033:0x7fe9f6539b19
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 bc ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fe9f3aaf188 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007fe9f664cf60 RCX: 00007fe9f6539b19
RDX: 0000000020000040 RSI: 0000000040086602 RDI: 0000000000000005
RBP: 00007fe9f6593f6d R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffc8156902f R14: 00007fe9f3aaf300 R15: 0000000000022000
loop6: detected capacity change from 0 to 16
EXT4-fs (loop6): VFS: Can't find ext4 filesystem
loop6: detected capacity change from 0 to 16
sg_write: data in/out 917468/251 bytes for SCSI command 0x0-- guessing data in;
program syz-executor.5 not setting count and/or reply_len properly
------------[ cut here ]------------
WARNING: CPU: 0 PID: 13591 at lib/iov_iter.c:629 _copy_from_iter+0x2bf/0x1150
Modules linked in:
CPU: 0 PID: 13591 Comm: syz-executor.5 Not tainted 6.2.0-rc1-next-20221226 #1
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014
RIP: 0010:_copy_from_iter+0x2bf/0x1150
Code: 5d 41 5e 41 5f e9 a5 9f 2f 02 e8 9c a3 37 ff be 79 02 00 00 48 c7 c7 80 cb 9e 84 e8 6b 18 5b ff e9 48 fe ff ff e8 81 a3 37 ff <0f> 0b 45 31 f6 eb 87 e8 75 a3 37 ff 31 ff 89 ee e8 3c 9f 37 ff 40
RSP: 0018:ffff888043a4f5e8 EFLAGS: 00010212
RAX: 0000000000003814 RBX: 0000000000000000 RCX: ffffc90004fef000
RDX: 0000000000040000 RSI: ffffffff821139ff RDI: 0000000000000001
RBP: 0000000000000000 R08: 0000000000000001 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000001 R12: ffff888043a4f818
R13: ffffea000124a000 R14: 0000000000001000 R15: ffff888043a4f818
FS: 00007fa6a392c700(0000) GS:ffff88806ce00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000001b2fc24000 CR3: 0000000039ccc000 CR4: 0000000000350ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000600
Call Trace:
copy_page_from_iter+0xe3/0x180
blk_rq_map_user_iov+0xb0c/0x1650
blk_rq_map_user_io+0x1ee/0x220
sg_common_write.constprop.0+0xd84/0x15e0
sg_write.part.0+0x698/0xa90
sg_write+0x88/0xe0
vfs_write+0x2cf/0xd90
ksys_write+0x12b/0x260
do_syscall_64+0x3f/0x90
entry_SYSCALL_64_after_hwframe+0x72/0xdc
RIP: 0033:0x7fa6a63b6b19
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 bc ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fa6a392c188 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007fa6a64c9f60 RCX: 00007fa6a63b6b19
RDX: 0000000000000125 RSI: 00000000200003c0 RDI: 0000000000000005
RBP: 00007fa6a6410f6d R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007fff026cad2f R14: 00007fa6a392c300 R15: 0000000000022000
irq event stamp: 0
hardirqs last enabled at (0): [<0000000000000000>] 0x0
hardirqs last disabled at (0): [] copy_process+0x1b05/0x7160
softirqs last enabled at (0): [] copy_process+0x1b49/0x7160
softirqs last disabled at (0): [<0000000000000000>] 0x0
---[ end trace 0000000000000000 ]---
EXT4-fs (loop6): VFS: Can't find ext4 filesystem
loop6: detected capacity change from 0 to 16
EXT4-fs (loop6): invalid first ino: 0
loop6: detected capacity change from 0 to 16
EXT4-fs (loop6): invalid first ino: 0