====================================================== WARNING: possible circular locking dependency detected 6.13.0-rc2-syzkaller-00036-g231825b2e1ff #0 Not tainted ------------------------------------------------------ syz.0.626/9617 is trying to acquire lock: ffff88807e9e59a0 (&mm->mmap_lock){++++}-{4:4}, at: gup_fast_fallback+0x11bf/0x2690 mm/gup.c:3416 but task is already holding lock: ffff888058d1ed50 (&sb->s_type->i_mutex_key#25){++++}-{4:4}, at: inode_lock include/linux/fs.h:818 [inline] ffff888058d1ed50 (&sb->s_type->i_mutex_key#25){++++}-{4:4}, at: generic_file_write_iter+0x8c/0x340 mm/filemap.c:4179 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #4 (&sb->s_type->i_mutex_key#25){++++}-{4:4}: down_write+0x93/0x200 kernel/locking/rwsem.c:1577 inode_lock include/linux/fs.h:818 [inline] __generic_file_fsync+0xb0/0x1f0 fs/libfs.c:1536 fat_file_fsync+0x70/0x210 fs/fat/file.c:191 vfs_fsync_range fs/sync.c:187 [inline] vfs_fsync+0x12d/0x1f0 fs/sync.c:201 __loop_update_dio+0x182/0x570 drivers/block/loop.c:204 loop_set_status+0x2a4/0x700 drivers/block/loop.c:1289 loop_set_status_old+0x163/0x1d0 drivers/block/loop.c:1388 lo_ioctl+0x65c/0x18b0 drivers/block/loop.c:1541 blkdev_ioctl+0x279/0x6d0 block/ioctl.c:693 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:906 [inline] __se_sys_ioctl fs/ioctl.c:892 [inline] __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:892 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #3 (&q->q_usage_counter(io)#26){++++}-{0:0}: bio_queue_enter block/blk.h:75 [inline] blk_mq_submit_bio+0x1fb6/0x24c0 block/blk-mq.c:3092 __submit_bio+0x384/0x540 block/blk-core.c:629 __submit_bio_noacct_mq block/blk-core.c:710 [inline] submit_bio_noacct_nocheck+0x698/0xd70 block/blk-core.c:739 submit_bio_noacct+0x93a/0x1e20 block/blk-core.c:868 submit_bh fs/buffer.c:2819 [inline] __sync_dirty_buffer+0x173/0x370 fs/buffer.c:2857 __ext4_handle_dirty_metadata+0x2b8/0x8f0 fs/ext4/ext4_jbd2.c:386 ext4_alloc_branch fs/ext4/indirect.c:385 [inline] ext4_ind_map_blocks+0xef7/0x28d0 fs/ext4/indirect.c:635 ext4_map_create_blocks fs/ext4/inode.c:518 [inline] ext4_map_blocks+0x6c8/0x1370 fs/ext4/inode.c:702 _ext4_get_block+0x250/0x5a0 fs/ext4/inode.c:781 ext4_block_write_begin+0x3f4/0xf20 fs/ext4/inode.c:1063 ext4_write_begin+0x5ed/0x1140 fs/ext4/inode.c:1217 generic_perform_write+0x2bd/0x920 mm/filemap.c:4055 ext4_buffered_write_iter+0x119/0x3c0 fs/ext4/file.c:299 ext4_file_write_iter+0x9e1/0x1be0 fs/ext4/file.c:717 new_sync_write fs/read_write.c:586 [inline] vfs_write+0x5b1/0x1150 fs/read_write.c:679 ksys_write+0x12b/0x250 fs/read_write.c:731 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #2 (&ei->i_data_sem){++++}-{4:4}: down_write+0x93/0x200 kernel/locking/rwsem.c:1577 ext4_truncate+0xdd5/0x1270 fs/ext4/inode.c:4212 ext4_setattr+0x1c64/0x2a70 fs/ext4/inode.c:5541 notify_change+0x6a9/0x1230 fs/attr.c:552 do_truncate+0x15c/0x220 fs/open.c:65 do_ftruncate+0x5d9/0x720 fs/open.c:181 do_sys_ftruncate+0x61/0xb0 fs/open.c:196 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #1 (jbd2_handle){++++}-{0:0}: start_this_handle+0xf92/0x1430 fs/jbd2/transaction.c:448 jbd2__journal_start+0x394/0x6a0 fs/jbd2/transaction.c:505 __ext4_journal_start_sb+0x19f/0x660 fs/ext4/ext4_jbd2.c:112 __ext4_journal_start fs/ext4/ext4_jbd2.h:326 [inline] ext4_dirty_inode+0xa1/0x130 fs/ext4/inode.c:6038 __mark_inode_dirty+0x1ef/0xe50 fs/fs-writeback.c:2515 generic_update_time+0xcf/0xf0 fs/inode.c:2112 inode_update_time fs/inode.c:2125 [inline] touch_atime+0x4ee/0x5d0 fs/inode.c:2197 file_accessed include/linux/fs.h:2539 [inline] ext4_file_mmap+0x4fc/0x6b0 fs/ext4/file.c:816 call_mmap include/linux/fs.h:2183 [inline] mmap_file mm/internal.h:124 [inline] __mmap_new_file_vma mm/vma.c:2291 [inline] __mmap_new_vma mm/vma.c:2355 [inline] __mmap_region+0x1789/0x2670 mm/vma.c:2456 mmap_region+0x270/0x320 mm/mmap.c:1348 do_mmap+0xc00/0xfc0 mm/mmap.c:496 vm_mmap_pgoff+0x1ba/0x360 mm/util.c:580 ksys_mmap_pgoff+0x32c/0x5c0 mm/mmap.c:542 __do_sys_mmap arch/x86/kernel/sys_x86_64.c:89 [inline] __se_sys_mmap arch/x86/kernel/sys_x86_64.c:82 [inline] __x64_sys_mmap+0x125/0x190 arch/x86/kernel/sys_x86_64.c:82 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #0 (&mm->mmap_lock){++++}-{4:4}: check_prev_add kernel/locking/lockdep.c:3161 [inline] check_prevs_add kernel/locking/lockdep.c:3280 [inline] validate_chain kernel/locking/lockdep.c:3904 [inline] __lock_acquire+0x249e/0x3c40 kernel/locking/lockdep.c:5226 lock_acquire.part.0+0x11b/0x380 kernel/locking/lockdep.c:5849 gup_fast_fallback+0x11f8/0x2690 mm/gup.c:3416 pin_user_pages_fast+0xa8/0x100 mm/gup.c:3540 iov_iter_extract_user_pages lib/iov_iter.c:1844 [inline] iov_iter_extract_pages+0x3a5/0x2010 lib/iov_iter.c:1907 dio_refill_pages fs/direct-io.c:172 [inline] dio_get_page fs/direct-io.c:213 [inline] do_direct_IO fs/direct-io.c:915 [inline] __blockdev_direct_IO+0x2ec5/0x40b0 fs/direct-io.c:1243 blockdev_direct_IO include/linux/fs.h:3313 [inline] fat_direct_IO+0x1df/0x390 fs/fat/inode.c:281 generic_file_direct_write+0x19a/0x410 mm/filemap.c:3978 __generic_file_write_iter+0x11b/0x240 mm/filemap.c:4142 generic_file_write_iter+0xe1/0x340 mm/filemap.c:4182 aio_write+0x3b5/0x8c0 fs/aio.c:1633 __io_submit_one fs/aio.c:2005 [inline] io_submit_one+0x1248/0x1da0 fs/aio.c:2052 __do_sys_io_submit fs/aio.c:2111 [inline] __se_sys_io_submit fs/aio.c:2081 [inline] __x64_sys_io_submit+0x1b2/0x340 fs/aio.c:2081 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f other info that might help us debug this: Chain exists of: &mm->mmap_lock --> &q->q_usage_counter(io)#26 --> &sb->s_type->i_mutex_key#25 Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&sb->s_type->i_mutex_key#25); lock(&q->q_usage_counter(io)#26); lock(&sb->s_type->i_mutex_key#25); rlock(&mm->mmap_lock); *** DEADLOCK *** 1 lock held by syz.0.626/9617: #0: ffff888058d1ed50 (&sb->s_type->i_mutex_key#25){++++}-{4:4}, at: inode_lock include/linux/fs.h:818 [inline] #0: ffff888058d1ed50 (&sb->s_type->i_mutex_key#25){++++}-{4:4}, at: generic_file_write_iter+0x8c/0x340 mm/filemap.c:4179 stack backtrace: CPU: 0 UID: 0 PID: 9617 Comm: syz.0.626 Not tainted 6.13.0-rc2-syzkaller-00036-g231825b2e1ff #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/25/2024 Call Trace: __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120 print_circular_bug+0x419/0x5d0 kernel/locking/lockdep.c:2074 check_noncircular+0x31a/0x400 kernel/locking/lockdep.c:2206 check_prev_add kernel/locking/lockdep.c:3161 [inline] check_prevs_add kernel/locking/lockdep.c:3280 [inline] validate_chain kernel/locking/lockdep.c:3904 [inline] __lock_acquire+0x249e/0x3c40 kernel/locking/lockdep.c:5226 lock_acquire.part.0+0x11b/0x380 kernel/locking/lockdep.c:5849 gup_fast_fallback+0x11f8/0x2690 mm/gup.c:3416 pin_user_pages_fast+0xa8/0x100 mm/gup.c:3540 iov_iter_extract_user_pages lib/iov_iter.c:1844 [inline] iov_iter_extract_pages+0x3a5/0x2010 lib/iov_iter.c:1907 dio_refill_pages fs/direct-io.c:172 [inline] dio_get_page fs/direct-io.c:213 [inline] do_direct_IO fs/direct-io.c:915 [inline] __blockdev_direct_IO+0x2ec5/0x40b0 fs/direct-io.c:1243 blockdev_direct_IO include/linux/fs.h:3313 [inline] fat_direct_IO+0x1df/0x390 fs/fat/inode.c:281 generic_file_direct_write+0x19a/0x410 mm/filemap.c:3978 __generic_file_write_iter+0x11b/0x240 mm/filemap.c:4142 generic_file_write_iter+0xe1/0x340 mm/filemap.c:4182 aio_write+0x3b5/0x8c0 fs/aio.c:1633 __io_submit_one fs/aio.c:2005 [inline] io_submit_one+0x1248/0x1da0 fs/aio.c:2052 __do_sys_io_submit fs/aio.c:2111 [inline] __se_sys_io_submit fs/aio.c:2081 [inline] __x64_sys_io_submit+0x1b2/0x340 fs/aio.c:2081 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f6b37585d19 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:00007f6b38469038 EFLAGS: 00000246 ORIG_RAX: 00000000000000d1 RAX: ffffffffffffffda RBX: 00007f6b37776080 RCX: 00007f6b37585d19 RDX: 0000000020000540 RSI: 000000000000003b RDI: 00007f6b3846a000 RBP: 00007f6b37601a20 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000001 R14: 00007f6b37776080 R15: 00007ffd681fd368 syz.0.626: attempt to access beyond end of device loop0: rw=34817, sector=97, nr_sectors = 32 limit=128