====================================================== WARNING: possible circular locking dependency detected 6.13.0-rc3-syzkaller-00017-gf44d154d6e3d #0 Not tainted ------------------------------------------------------ syz.0.727/8486 is trying to acquire lock: ffff8880338af6e0 (&mm->mmap_lock){++++}-{4:4}, at: gup_fast_fallback+0x11bf/0x2690 mm/gup.c:3416 but task is already holding lock: ffff888058c947a0 (&sb->s_type->i_mutex_key#31){++++}-{4:4}, at: inode_lock include/linux/fs.h:818 [inline] ffff888058c947a0 (&sb->s_type->i_mutex_key#31){++++}-{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#31){++++}-{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:3090 __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 __ext4_read_bh fs/ext4/super.c:181 [inline] ext4_read_bh_nowait+0x199/0x250 fs/ext4/super.c:193 ext4_read_block_bitmap_nowait+0xeac/0x1810 fs/ext4/balloc.c:551 ext4_mb_init_cache+0x290/0x15c0 fs/ext4/mballoc.c:1337 ext4_mb_init_group+0x331/0x840 fs/ext4/mballoc.c:1543 ext4_mb_load_buddy_gfp+0xc23/0x10c0 fs/ext4/mballoc.c:1613 ext4_mb_clear_bb fs/ext4/mballoc.c:6451 [inline] ext4_free_blocks+0x832/0x1c80 fs/ext4/mballoc.c:6652 ext4_clear_blocks+0x325/0x430 fs/ext4/indirect.c:888 ext4_free_data+0x33f/0x3f0 fs/ext4/indirect.c:962 ext4_ind_truncate+0x6d7/0x980 fs/ext4/indirect.c:1154 ext4_truncate+0xeaa/0x1270 fs/ext4/inode.c:4219 ext4_evict_inode+0x7af/0x18c0 fs/ext4/inode.c:263 evict+0x40c/0x960 fs/inode.c:796 iput_final fs/inode.c:1946 [inline] iput fs/inode.c:1972 [inline] iput+0x52a/0x890 fs/inode.c:1958 do_unlinkat+0x5c3/0x760 fs/namei.c:4594 __do_sys_unlinkat fs/namei.c:4630 [inline] __se_sys_unlinkat fs/namei.c:4623 [inline] __x64_sys_unlinkat+0xbf/0x130 fs/namei.c:4623 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#31 Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&sb->s_type->i_mutex_key#31); lock(&q->q_usage_counter(io)#26); lock(&sb->s_type->i_mutex_key#31); rlock(&mm->mmap_lock); *** DEADLOCK *** 1 lock held by syz.0.727/8486: #0: ffff888058c947a0 (&sb->s_type->i_mutex_key#31){++++}-{4:4}, at: inode_lock include/linux/fs.h:818 [inline] #0: ffff888058c947a0 (&sb->s_type->i_mutex_key#31){++++}-{4:4}, at: generic_file_write_iter+0x8c/0x340 mm/filemap.c:4179 stack backtrace: CPU: 1 UID: 0 PID: 8486 Comm: syz.0.727 Not tainted 6.13.0-rc3-syzkaller-00017-gf44d154d6e3d #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:0x7ffa13185d29 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:00007ffa1406c038 EFLAGS: 00000246 ORIG_RAX: 00000000000000d1 RAX: ffffffffffffffda RBX: 00007ffa13376080 RCX: 00007ffa13185d29 RDX: 0000000020000540 RSI: 000000000000003b RDI: 00007ffa1406d000 RBP: 00007ffa13201a20 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000001 R14: 00007ffa13376080 R15: 00007fff19e2d1d8 syz.0.727: attempt to access beyond end of device loop0: rw=34817, sector=97, nr_sectors = 944 limit=128