======================================================
WARNING: possible circular locking dependency detected
6.2.0-syzkaller-18295-ga9b06ec42c0f #0 Not tainted
------------------------------------------------------
syz-executor308/15533 is trying to acquire lock:
ffff0000d8d163f8 (&journal->j_checkpoint_mutex){+.+.}-{3:3}, at: __jbd2_log_wait_for_space+0x1a4/0x5cc fs/jbd2/checkpoint.c:110

but task is already holding lock:
ffff0000e062d440 (&sb->s_type->i_mutex_key#8){++++}-{3:3}, at: inode_lock include/linux/fs.h:756 [inline]
ffff0000e062d440 (&sb->s_type->i_mutex_key#8){++++}-{3:3}, at: ext4_buffered_write_iter+0x9c/0x538 fs/ext4/file.c:279

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&sb->s_type->i_mutex_key#8){++++}-{3:3}:
       down_read+0x5c/0x78 kernel/locking/rwsem.c:1509
       inode_lock_shared include/linux/fs.h:766 [inline]
       ext4_bmap+0x58/0x35c fs/ext4/inode.c:3243
       bmap+0xa8/0xe8 fs/inode.c:1798
       jbd2_journal_bmap fs/jbd2/journal.c:977 [inline]
       __jbd2_journal_erase fs/jbd2/journal.c:1789 [inline]
       jbd2_journal_flush+0x4c0/0xa60 fs/jbd2/journal.c:2492
       ext4_ioctl_checkpoint fs/ext4/ioctl.c:1082 [inline]
       __ext4_ioctl fs/ext4/ioctl.c:1590 [inline]
       ext4_ioctl+0x38b0/0x6eec fs/ext4/ioctl.c:1610
       vfs_ioctl fs/ioctl.c:51 [inline]
       __do_sys_ioctl fs/ioctl.c:870 [inline]
       __se_sys_ioctl fs/ioctl.c:856 [inline]
       __arm64_sys_ioctl+0x14c/0x1c8 fs/ioctl.c:856
       __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
       invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
       el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
       do_el0_svc+0x64/0x198 arch/arm64/kernel/syscall.c:193
       el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
       el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
       el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:591

-> #0 (&journal->j_checkpoint_mutex){+.+.}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3097 [inline]
       check_prevs_add kernel/locking/lockdep.c:3216 [inline]
       validate_chain kernel/locking/lockdep.c:3831 [inline]
       __lock_acquire+0x3338/0x764c kernel/locking/lockdep.c:5055
       lock_acquire+0x2e8/0x8c0 kernel/locking/lockdep.c:5668
       __mutex_lock_common+0x190/0x21a0 kernel/locking/mutex.c:603
       mutex_lock_io_nested+0x6c/0x88 kernel/locking/mutex.c:833
       __jbd2_log_wait_for_space+0x1a4/0x5cc fs/jbd2/checkpoint.c:110
       add_transaction_credits+0x7dc/0xafc fs/jbd2/transaction.c:298
       start_this_handle+0x5c4/0x13ac fs/jbd2/transaction.c:422
       jbd2__journal_start+0x298/0x544 fs/jbd2/transaction.c:520
       __ext4_journal_start_sb+0x598/0xd54 fs/ext4/ext4_jbd2.c:111
       __ext4_journal_start fs/ext4/ext4_jbd2.h:326 [inline]
       ext4_dirty_inode+0xa0/0x104 fs/ext4/inode.c:6107
       __mark_inode_dirty+0x460/0x18b4 fs/fs-writeback.c:2419
       mark_inode_dirty include/linux/fs.h:2465 [inline]
       generic_write_end+0x15c/0x414 fs/buffer.c:2184
       ext4_da_write_end+0x680/0x9fc fs/ext4/inode.c:3175
       generic_perform_write+0x384/0x55c mm/filemap.c:3784
       ext4_buffered_write_iter+0x2e0/0x538 fs/ext4/file.c:285
       ext4_file_write_iter+0x188/0x16c0
       __kernel_write_iter+0x264/0x5f8 fs/read_write.c:517
       __kernel_write+0x11c/0x174 fs/read_write.c:537
       __dump_emit fs/coredump.c:811 [inline]
       dump_emit+0x248/0x358 fs/coredump.c:848
       writenote+0x150/0x334 fs/binfmt_elf.c:1481
       write_note_info fs/binfmt_elf.c:1967 [inline]
       elf_core_dump+0x2aa8/0x3640 fs/binfmt_elf.c:2124
       do_coredump+0x14d4/0x22dc fs/coredump.c:762
       get_signal+0xfe8/0x159c kernel/signal.c:2845
       do_signal arch/arm64/kernel/signal.c:1246 [inline]
       do_notify_resume+0x338/0x3c90 arch/arm64/kernel/signal.c:1299
       prepare_exit_to_user_mode arch/arm64/kernel/entry-common.c:137 [inline]
       exit_to_user_mode arch/arm64/kernel/entry-common.c:142 [inline]
       el0_da+0xb8/0x184 arch/arm64/kernel/entry-common.c:516
       el0t_64_sync_handler+0xcc/0xf0 arch/arm64/kernel/entry-common.c:658
       el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:591

other info that might help us debug this:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&sb->s_type->i_mutex_key#8);
                               lock(&journal->j_checkpoint_mutex);
                               lock(&sb->s_type->i_mutex_key#8);
  lock(&journal->j_checkpoint_mutex);

 *** DEADLOCK ***

2 locks held by syz-executor308/15533:
 #0: ffff0000d8d10460 (sb_writers#3){.+.+}-{0:0}, at: do_coredump+0x14b4/0x22dc fs/coredump.c:761
 #1: ffff0000e062d440 (&sb->s_type->i_mutex_key#8){++++}-{3:3}, at: inode_lock include/linux/fs.h:756 [inline]
 #1: ffff0000e062d440 (&sb->s_type->i_mutex_key#8){++++}-{3:3}, at: ext4_buffered_write_iter+0x9c/0x538 fs/ext4/file.c:279

stack backtrace:
CPU: 0 PID: 15533 Comm: syz-executor308 Not tainted 6.2.0-syzkaller-18295-ga9b06ec42c0f #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/21/2023
Call trace:
 dump_backtrace+0x1c8/0x1f4 arch/arm64/kernel/stacktrace.c:158
 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:165
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xd0/0x124 lib/dump_stack.c:106
 dump_stack+0x1c/0x28 lib/dump_stack.c:113
 print_circular_bug+0x150/0x1b8 kernel/locking/lockdep.c:2055
 check_noncircular+0x2cc/0x378 kernel/locking/lockdep.c:2177
 check_prev_add kernel/locking/lockdep.c:3097 [inline]
 check_prevs_add kernel/locking/lockdep.c:3216 [inline]
 validate_chain kernel/locking/lockdep.c:3831 [inline]
 __lock_acquire+0x3338/0x764c kernel/locking/lockdep.c:5055
 lock_acquire+0x2e8/0x8c0 kernel/locking/lockdep.c:5668
 __mutex_lock_common+0x190/0x21a0 kernel/locking/mutex.c:603
 mutex_lock_io_nested+0x6c/0x88 kernel/locking/mutex.c:833
 __jbd2_log_wait_for_space+0x1a4/0x5cc fs/jbd2/checkpoint.c:110
 add_transaction_credits+0x7dc/0xafc fs/jbd2/transaction.c:298
 start_this_handle+0x5c4/0x13ac fs/jbd2/transaction.c:422
 jbd2__journal_start+0x298/0x544 fs/jbd2/transaction.c:520
 __ext4_journal_start_sb+0x598/0xd54 fs/ext4/ext4_jbd2.c:111
 __ext4_journal_start fs/ext4/ext4_jbd2.h:326 [inline]
 ext4_dirty_inode+0xa0/0x104 fs/ext4/inode.c:6107
 __mark_inode_dirty+0x460/0x18b4 fs/fs-writeback.c:2419
 mark_inode_dirty include/linux/fs.h:2465 [inline]
 generic_write_end+0x15c/0x414 fs/buffer.c:2184
 ext4_da_write_end+0x680/0x9fc fs/ext4/inode.c:3175
 generic_perform_write+0x384/0x55c mm/filemap.c:3784
 ext4_buffered_write_iter+0x2e0/0x538 fs/ext4/file.c:285
 ext4_file_write_iter+0x188/0x16c0
 __kernel_write_iter+0x264/0x5f8 fs/read_write.c:517
 __kernel_write+0x11c/0x174 fs/read_write.c:537
 __dump_emit fs/coredump.c:811 [inline]
 dump_emit+0x248/0x358 fs/coredump.c:848
 writenote+0x150/0x334 fs/binfmt_elf.c:1481
 write_note_info fs/binfmt_elf.c:1967 [inline]
 elf_core_dump+0x2aa8/0x3640 fs/binfmt_elf.c:2124
 do_coredump+0x14d4/0x22dc fs/coredump.c:762
 get_signal+0xfe8/0x159c kernel/signal.c:2845
 do_signal arch/arm64/kernel/signal.c:1246 [inline]
 do_notify_resume+0x338/0x3c90 arch/arm64/kernel/signal.c:1299
 prepare_exit_to_user_mode arch/arm64/kernel/entry-common.c:137 [inline]
 exit_to_user_mode arch/arm64/kernel/entry-common.c:142 [inline]
 el0_da+0xb8/0x184 arch/arm64/kernel/entry-common.c:516
 el0t_64_sync_handler+0xcc/0xf0 arch/arm64/kernel/entry-common.c:658
 el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:591