====================================================== WARNING: possible circular locking dependency detected 5.16.0-rc2-next-20211125-syzkaller #0 Not tainted ------------------------------------------------------ syz-executor.5/29218 is trying to acquire lock: ffff88809df77228 (&dquot->dq_lock){+.+.}-{3:3}, at: dquot_commit+0x4d/0x420 fs/quota/dquot.c:474 but task is already holding lock: ffff88808c4af020 (&ei->i_data_sem/2){++++}-{3:3}, at: ext4_truncate+0x631/0x1440 fs/ext4/inode.c:4196 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #2 (&ei->i_data_sem/2){++++}-{3:3}: down_read+0x98/0x440 kernel/locking/rwsem.c:1474 ext4_map_blocks+0x381/0x17d0 fs/ext4/inode.c:560 ext4_getblk+0x144/0x6b0 fs/ext4/inode.c:847 ext4_bread+0x2a/0x1c0 fs/ext4/inode.c:900 ext4_quota_write+0x26d/0x690 fs/ext4/super.c:6486 write_blk+0x12e/0x220 fs/quota/quota_tree.c:64 get_free_dqblk+0x104/0x2c0 fs/quota/quota_tree.c:93 do_insert_tree+0x63a/0x11f0 fs/quota/quota_tree.c:300 do_insert_tree+0xd90/0x11f0 fs/quota/quota_tree.c:331 do_insert_tree+0x6fd/0x11f0 fs/quota/quota_tree.c:331 do_insert_tree+0x6fd/0x11f0 fs/quota/quota_tree.c:331 dq_insert_tree fs/quota/quota_tree.c:357 [inline] qtree_write_dquot+0x3b0/0x570 fs/quota/quota_tree.c:376 v2_write_dquot+0x11c/0x250 fs/quota/quota_v2.c:358 dquot_acquire+0x2c5/0x590 fs/quota/dquot.c:441 ext4_acquire_dquot+0x254/0x3b0 fs/ext4/super.c:6155 dqget+0x679/0x1080 fs/quota/dquot.c:899 __dquot_initialize+0x560/0xbe0 fs/quota/dquot.c:1477 dquot_initialize fs/quota/dquot.c:1535 [inline] dquot_file_open fs/quota/dquot.c:2159 [inline] dquot_file_open+0x92/0xb0 fs/quota/dquot.c:2153 ext4_file_open fs/ext4/file.c:874 [inline] ext4_file_open+0x33b/0xb50 fs/ext4/file.c:844 do_dentry_open+0x4c8/0x1250 fs/open.c:822 do_open fs/namei.c:3426 [inline] path_openat+0x1cad/0x2750 fs/namei.c:3559 do_filp_open+0x1aa/0x400 fs/namei.c:3586 do_sys_openat2+0x16d/0x4d0 fs/open.c:1212 do_sys_open fs/open.c:1228 [inline] __do_sys_creat fs/open.c:1304 [inline] __se_sys_creat fs/open.c:1298 [inline] __x64_sys_creat+0xc9/0x120 fs/open.c:1298 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae -> #1 (&s->s_dquot.dqio_sem){++++}-{3:3}: down_read+0x98/0x440 kernel/locking/rwsem.c:1474 v2_read_dquot+0x49/0x120 fs/quota/quota_v2.c:332 dquot_acquire+0x12e/0x590 fs/quota/dquot.c:432 ext4_acquire_dquot+0x254/0x3b0 fs/ext4/super.c:6155 dqget+0x679/0x1080 fs/quota/dquot.c:899 __dquot_initialize+0x560/0xbe0 fs/quota/dquot.c:1477 dquot_initialize fs/quota/dquot.c:1535 [inline] dquot_file_open fs/quota/dquot.c:2159 [inline] dquot_file_open+0x92/0xb0 fs/quota/dquot.c:2153 ext4_file_open fs/ext4/file.c:874 [inline] ext4_file_open+0x33b/0xb50 fs/ext4/file.c:844 do_dentry_open+0x4c8/0x1250 fs/open.c:822 do_open fs/namei.c:3426 [inline] path_openat+0x1cad/0x2750 fs/namei.c:3559 do_filp_open+0x1aa/0x400 fs/namei.c:3586 do_sys_openat2+0x16d/0x4d0 fs/open.c:1212 do_sys_open fs/open.c:1228 [inline] __do_sys_creat fs/open.c:1304 [inline] __se_sys_creat fs/open.c:1298 [inline] __x64_sys_creat+0xc9/0x120 fs/open.c:1298 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae -> #0 (&dquot->dq_lock){+.+.}-{3:3}: check_prev_add kernel/locking/lockdep.c:3063 [inline] check_prevs_add kernel/locking/lockdep.c:3186 [inline] validate_chain kernel/locking/lockdep.c:3801 [inline] __lock_acquire+0x2a07/0x54a0 kernel/locking/lockdep.c:5027 lock_acquire kernel/locking/lockdep.c:5637 [inline] lock_acquire+0x1ab/0x510 kernel/locking/lockdep.c:5602 __mutex_lock_common kernel/locking/mutex.c:607 [inline] __mutex_lock+0x12f/0x12f0 kernel/locking/mutex.c:740 dquot_commit+0x4d/0x420 fs/quota/dquot.c:474 ext4_write_dquot+0x24e/0x310 fs/ext4/super.c:6139 ext4_mark_dquot_dirty fs/ext4/super.c:6187 [inline] ext4_mark_dquot_dirty+0x111/0x1b0 fs/ext4/super.c:6181 mark_dquot_dirty fs/quota/dquot.c:345 [inline] mark_all_dquot_dirty fs/quota/dquot.c:383 [inline] __dquot_free_space+0x74b/0xab0 fs/quota/dquot.c:1892 dquot_free_space_nodirty include/linux/quotaops.h:376 [inline] dquot_free_space include/linux/quotaops.h:381 [inline] dquot_free_block include/linux/quotaops.h:392 [inline] ext4_free_blocks+0xe22/0x2300 fs/ext4/mballoc.c:6084 ext4_remove_blocks fs/ext4/extents.c:2523 [inline] ext4_ext_rm_leaf fs/ext4/extents.c:2707 [inline] ext4_ext_remove_space+0x3323/0x44c0 fs/ext4/extents.c:2955 ext4_ext_truncate+0x33f/0x400 fs/ext4/extents.c:4416 ext4_truncate+0xecc/0x1440 fs/ext4/inode.c:4201 ext4_setattr+0x1301/0x21a0 fs/ext4/inode.c:5474 notify_change+0xaef/0x10c0 fs/attr.c:410 do_truncate+0x13c/0x200 fs/open.c:64 handle_truncate fs/namei.c:3082 [inline] do_open fs/namei.c:3430 [inline] path_openat+0x20a9/0x2750 fs/namei.c:3559 do_filp_open+0x1aa/0x400 fs/namei.c:3586 do_sys_openat2+0x16d/0x4d0 fs/open.c:1212 do_sys_open fs/open.c:1228 [inline] __do_sys_creat fs/open.c:1304 [inline] __se_sys_creat fs/open.c:1298 [inline] __x64_sys_creat+0xc9/0x120 fs/open.c:1298 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae other info that might help us debug this: Chain exists of: &dquot->dq_lock --> &s->s_dquot.dqio_sem --> &ei->i_data_sem/2 Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&ei->i_data_sem/2); lock(&s->s_dquot.dqio_sem); lock(&ei->i_data_sem/2); lock(&dquot->dq_lock); *** DEADLOCK *** 5 locks held by syz-executor.5/29218: #0: ffff88808ca28460 (sb_writers#5){.+.+}-{0:0}, at: do_open fs/namei.c:3419 [inline] #0: ffff88808ca28460 (sb_writers#5){.+.+}-{0:0}, at: path_openat+0x1b78/0x2750 fs/namei.c:3559 #1: ffff88808c4af198 (&sb->s_type->i_mutex_key#10){++++}-{3:3}, at: inode_lock include/linux/fs.h:783 [inline] #1: ffff88808c4af198 (&sb->s_type->i_mutex_key#10){++++}-{3:3}, at: do_truncate+0x12a/0x200 fs/open.c:62 #2: ffff88808c4af338 (mapping.invalidate_lock){++++}-{3:3}, at: filemap_invalidate_lock include/linux/fs.h:828 [inline] #2: ffff88808c4af338 (mapping.invalidate_lock){++++}-{3:3}, at: ext4_setattr+0xd92/0x21a0 fs/ext4/inode.c:5399 #3: ffff88808c4af020 (&ei->i_data_sem/2){++++}-{3:3}, at: ext4_truncate+0x631/0x1440 fs/ext4/inode.c:4196 #4: ffffffff8bd48398 (dquot_srcu){....}-{0:0}, at: i_dquot fs/quota/dquot.c:924 [inline] #4: ffffffff8bd48398 (dquot_srcu){....}-{0:0}, at: __dquot_free_space+0x1a4/0xab0 fs/quota/dquot.c:1865 stack backtrace: CPU: 1 PID: 29218 Comm: syz-executor.5 Not tainted 5.16.0-rc2-next-20211125-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106 check_noncircular+0x25f/0x2e0 kernel/locking/lockdep.c:2143 check_prev_add kernel/locking/lockdep.c:3063 [inline] check_prevs_add kernel/locking/lockdep.c:3186 [inline] validate_chain kernel/locking/lockdep.c:3801 [inline] __lock_acquire+0x2a07/0x54a0 kernel/locking/lockdep.c:5027 lock_acquire kernel/locking/lockdep.c:5637 [inline] lock_acquire+0x1ab/0x510 kernel/locking/lockdep.c:5602 __mutex_lock_common kernel/locking/mutex.c:607 [inline] __mutex_lock+0x12f/0x12f0 kernel/locking/mutex.c:740 dquot_commit+0x4d/0x420 fs/quota/dquot.c:474 ext4_write_dquot+0x24e/0x310 fs/ext4/super.c:6139 ext4_mark_dquot_dirty fs/ext4/super.c:6187 [inline] ext4_mark_dquot_dirty+0x111/0x1b0 fs/ext4/super.c:6181 mark_dquot_dirty fs/quota/dquot.c:345 [inline] mark_all_dquot_dirty fs/quota/dquot.c:383 [inline] __dquot_free_space+0x74b/0xab0 fs/quota/dquot.c:1892 dquot_free_space_nodirty include/linux/quotaops.h:376 [inline] dquot_free_space include/linux/quotaops.h:381 [inline] dquot_free_block include/linux/quotaops.h:392 [inline] ext4_free_blocks+0xe22/0x2300 fs/ext4/mballoc.c:6084 ext4_remove_blocks fs/ext4/extents.c:2523 [inline] ext4_ext_rm_leaf fs/ext4/extents.c:2707 [inline] ext4_ext_remove_space+0x3323/0x44c0 fs/ext4/extents.c:2955 ext4_ext_truncate+0x33f/0x400 fs/ext4/extents.c:4416 ext4_truncate+0xecc/0x1440 fs/ext4/inode.c:4201 ext4_setattr+0x1301/0x21a0 fs/ext4/inode.c:5474 notify_change+0xaef/0x10c0 fs/attr.c:410 do_truncate+0x13c/0x200 fs/open.c:64 handle_truncate fs/namei.c:3082 [inline] do_open fs/namei.c:3430 [inline] path_openat+0x20a9/0x2750 fs/namei.c:3559 do_filp_open+0x1aa/0x400 fs/namei.c:3586 do_sys_openat2+0x16d/0x4d0 fs/open.c:1212 do_sys_open fs/open.c:1228 [inline] __do_sys_creat fs/open.c:1304 [inline] __se_sys_creat fs/open.c:1298 [inline] __x64_sys_creat+0xc9/0x120 fs/open.c:1298 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae RIP: 0033:0x7f98fff18ae9 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:00007f98fd46d188 EFLAGS: 00000246 ORIG_RAX: 0000000000000055 RAX: ffffffffffffffda RBX: 00007f990002c020 RCX: 00007f98fff18ae9 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000020000400 RBP: 00007f98fff72f6d R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007ffd398a3b5f R14: 00007f98fd46d300 R15: 0000000000022000