====================================================== WARNING: possible circular locking dependency detected 6.12.0-rc6-next-20241108-syzkaller #0 Not tainted ------------------------------------------------------ syz.1.776/9062 is trying to acquire lock: ffff888144bea430 (&q->limits_lock){+.+.}-{4:4}, at: queue_limits_start_update include/linux/blkdev.h:944 [inline] ffff888144bea430 (&q->limits_lock){+.+.}-{4:4}, at: loop_reconfigure_limits+0x287/0x9f0 drivers/block/loop.c:1003 but task is already holding lock: ffff888144be9de8 (&q->q_usage_counter(io)#17){++++}-{0:0}, at: loop_set_block_size drivers/block/loop.c:1472 [inline] ffff888144be9de8 (&q->q_usage_counter(io)#17){++++}-{0:0}, at: lo_simple_ioctl drivers/block/loop.c:1496 [inline] ffff888144be9de8 (&q->q_usage_counter(io)#17){++++}-{0:0}, at: lo_ioctl+0x1344/0x1f50 drivers/block/loop.c:1559 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #2 (&q->q_usage_counter(io)#17){++++}-{0:0}: lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849 bio_queue_enter block/blk.h:75 [inline] blk_mq_submit_bio+0x1510/0x2490 block/blk-mq.c:3095 __submit_bio+0x2c2/0x560 block/blk-core.c:629 __submit_bio_noacct_mq block/blk-core.c:710 [inline] submit_bio_noacct_nocheck+0x4d3/0xe30 block/blk-core.c:739 submit_bh fs/buffer.c:2819 [inline] __bh_read fs/buffer.c:3088 [inline] bh_readahead include/linux/buffer_head.h:433 [inline] __breadahead+0x1a4/0x240 fs/buffer.c:1444 sb_breadahead include/linux/buffer_head.h:358 [inline] fat_ent_reada+0x37b/0x570 fs/fat/fatent.c:705 fat_count_free_clusters+0x6f8/0xe70 fs/fat/fatent.c:734 fat_statfs+0x139/0x450 fs/fat/inode.c:834 statfs_by_dentry fs/statfs.c:66 [inline] vfs_get_fsid+0x187/0x280 fs/statfs.c:77 fanotify_test_fsid+0xb5/0x470 fs/notify/fanotify/fanotify_user.c:1579 do_fanotify_mark+0x775/0xda0 fs/notify/fanotify/fanotify_user.c:1839 __do_sys_fanotify_mark fs/notify/fanotify/fanotify_user.c:1917 [inline] __se_sys_fanotify_mark fs/notify/fanotify/fanotify_user.c:1913 [inline] __x64_sys_fanotify_mark+0xb5/0xd0 fs/notify/fanotify/fanotify_user.c:1913 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #1 (&sbi->fat_lock){+.+.}-{4:4}: lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849 __mutex_lock_common kernel/locking/mutex.c:585 [inline] __mutex_lock+0x1ac/0xee0 kernel/locking/mutex.c:735 lock_fat fs/fat/fatent.c:281 [inline] fat_count_free_clusters+0x156/0xe70 fs/fat/fatent.c:724 fat_statfs+0x139/0x450 fs/fat/inode.c:834 statfs_by_dentry fs/statfs.c:66 [inline] vfs_statfs+0x13b/0x2c0 fs/statfs.c:90 loop_config_discard drivers/block/loop.c:798 [inline] loop_reconfigure_limits+0x5fe/0x9f0 drivers/block/loop.c:1012 loop_configure+0x77e/0xeb0 drivers/block/loop.c:1093 lo_ioctl+0x846/0x1f50 blkdev_ioctl+0x57d/0x6a0 block/ioctl.c:693 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:906 [inline] __se_sys_ioctl+0xf5/0x170 fs/ioctl.c:892 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #0 (&q->limits_lock){+.+.}-{4:4}: check_prev_add kernel/locking/lockdep.c:3161 [inline] check_prevs_add kernel/locking/lockdep.c:3280 [inline] validate_chain+0x18ef/0x5920 kernel/locking/lockdep.c:3904 __lock_acquire+0x1397/0x2100 kernel/locking/lockdep.c:5226 lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849 __mutex_lock_common kernel/locking/mutex.c:585 [inline] __mutex_lock+0x1ac/0xee0 kernel/locking/mutex.c:735 queue_limits_start_update include/linux/blkdev.h:944 [inline] loop_reconfigure_limits+0x287/0x9f0 drivers/block/loop.c:1003 loop_set_block_size drivers/block/loop.c:1473 [inline] lo_simple_ioctl drivers/block/loop.c:1496 [inline] lo_ioctl+0x1351/0x1f50 drivers/block/loop.c:1559 blkdev_ioctl+0x57d/0x6a0 block/ioctl.c:693 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:906 [inline] __se_sys_ioctl+0xf5/0x170 fs/ioctl.c:892 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f other info that might help us debug this: Chain exists of: &q->limits_lock --> &sbi->fat_lock --> &q->q_usage_counter(io)#17 Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&q->q_usage_counter(io)#17); lock(&sbi->fat_lock); lock(&q->q_usage_counter(io)#17); lock(&q->limits_lock); *** DEADLOCK *** 3 locks held by syz.1.776/9062: #0: ffff88802033d360 (&lo->lo_mutex){+.+.}-{4:4}, at: lo_simple_ioctl drivers/block/loop.c:1485 [inline] #0: ffff88802033d360 (&lo->lo_mutex){+.+.}-{4:4}, at: lo_ioctl+0x606/0x1f50 drivers/block/loop.c:1559 #1: ffff888144be9de8 (&q->q_usage_counter(io)#17){++++}-{0:0}, at: loop_set_block_size drivers/block/loop.c:1472 [inline] #1: ffff888144be9de8 (&q->q_usage_counter(io)#17){++++}-{0:0}, at: lo_simple_ioctl drivers/block/loop.c:1496 [inline] #1: ffff888144be9de8 (&q->q_usage_counter(io)#17){++++}-{0:0}, at: lo_ioctl+0x1344/0x1f50 drivers/block/loop.c:1559 #2: ffff888144be9e20 (&q->q_usage_counter(queue)){+.+.}-{0:0}, at: loop_set_block_size drivers/block/loop.c:1472 [inline] #2: ffff888144be9e20 (&q->q_usage_counter(queue)){+.+.}-{0:0}, at: lo_simple_ioctl drivers/block/loop.c:1496 [inline] #2: ffff888144be9e20 (&q->q_usage_counter(queue)){+.+.}-{0:0}, at: lo_ioctl+0x1344/0x1f50 drivers/block/loop.c:1559 stack backtrace: CPU: 0 UID: 0 PID: 9062 Comm: syz.1.776 Not tainted 6.12.0-rc6-next-20241108-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/30/2024 Call Trace: __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120 print_circular_bug+0x13a/0x1b0 kernel/locking/lockdep.c:2074 check_noncircular+0x36a/0x4a0 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+0x18ef/0x5920 kernel/locking/lockdep.c:3904 __lock_acquire+0x1397/0x2100 kernel/locking/lockdep.c:5226 lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849 __mutex_lock_common kernel/locking/mutex.c:585 [inline] __mutex_lock+0x1ac/0xee0 kernel/locking/mutex.c:735 queue_limits_start_update include/linux/blkdev.h:944 [inline] loop_reconfigure_limits+0x287/0x9f0 drivers/block/loop.c:1003 loop_set_block_size drivers/block/loop.c:1473 [inline] lo_simple_ioctl drivers/block/loop.c:1496 [inline] lo_ioctl+0x1351/0x1f50 drivers/block/loop.c:1559 blkdev_ioctl+0x57d/0x6a0 block/ioctl.c:693 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:906 [inline] __se_sys_ioctl+0xf5/0x170 fs/ioctl.c:892 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7fbd39b7e719 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:00007fbd3a909038 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 00007fbd39d36058 RCX: 00007fbd39b7e719 RDX: 0000000000000000 RSI: 0000000000004c09 RDI: 000000000000000b RBP: 00007fbd39bf1616 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007fbd39d36058 R15: 00007ffef64c3e18