[syzbot] possible deadlock in dquot_commit (2)

15 views
Skip to first unread message

syzbot

unread,
Oct 8, 2022, 3:13:40 PM10/8/22
to ja...@suse.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 4c86114194e6 Merge tag 'iomap-6.1-merge-1' of git://git.ke..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=17fde8b2880000
kernel config: https://syzkaller.appspot.com/x/.config?x=9905c889cc4ad738
dashboard link: https://syzkaller.appspot.com/bug?extid=70ff52e51b7e7714db8a
compiler: Debian clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU Binutils for Debian) 2.35.2

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/bf7f1dcd539b/disk-4c861141.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/c214481af743/vmlinux-4c861141.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+70ff52...@syzkaller.appspotmail.com

loop3: detected capacity change from 0 to 4096
EXT4-fs (loop3): mounted filesystem without journal. Quota mode: writeback.
======================================================
WARNING: possible circular locking dependency detected
6.0.0-syzkaller-06475-g4c86114194e6 #0 Not tainted
------------------------------------------------------
syz-executor.3/12343 is trying to acquire lock:
ffff88802bd4bca8 (&dquot->dq_lock){+.+.}-{3:3}, at: dquot_commit+0x58/0x4e0 fs/quota/dquot.c:479

but task is already holding lock:
ffff88804c4cc8c0 (&ei->i_data_sem/2){++++}-{3:3}, at: ext4_map_blocks+0x971/0x1cc0 fs/ext4/inode.c:638

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&ei->i_data_sem/2){++++}-{3:3}:
lock_acquire+0x182/0x3c0 kernel/locking/lockdep.c:5666
down_read+0x39/0x50 kernel/locking/rwsem.c:1499
ext4_map_blocks+0x398/0x1cc0 fs/ext4/inode.c:568
ext4_getblk+0x1b9/0x770 fs/ext4/inode.c:858
ext4_bread+0x2a/0x170 fs/ext4/inode.c:914
ext4_quota_write+0x225/0x570 fs/ext4/super.c:7087
write_blk fs/quota/quota_tree.c:64 [inline]
get_free_dqblk+0x357/0x6a0 fs/quota/quota_tree.c:93
do_insert_tree+0x26c/0x1a40 fs/quota/quota_tree.c:300
do_insert_tree+0x693/0x1a40 fs/quota/quota_tree.c:331
do_insert_tree+0x693/0x1a40 fs/quota/quota_tree.c:331
do_insert_tree+0x693/0x1a40 fs/quota/quota_tree.c:331
dq_insert_tree fs/quota/quota_tree.c:357 [inline]
qtree_write_dquot+0x3b6/0x530 fs/quota/quota_tree.c:376
v2_write_dquot+0x11b/0x190 fs/quota/quota_v2.c:358
dquot_acquire+0x348/0x670 fs/quota/dquot.c:444
ext4_acquire_dquot+0x2e0/0x400 fs/ext4/super.c:6743
dqget+0x999/0xdc0 fs/quota/dquot.c:914
__dquot_initialize+0x291/0xcf0 fs/quota/dquot.c:1492
ext4_process_orphan+0x57/0x2d0 fs/ext4/orphan.c:329
ext4_orphan_cleanup+0xb60/0x1340 fs/ext4/orphan.c:474
__ext4_fill_super fs/ext4/super.c:5520 [inline]
ext4_fill_super+0x82e8/0x8810 fs/ext4/super.c:5648
get_tree_bdev+0x400/0x620 fs/super.c:1323
vfs_get_tree+0x88/0x270 fs/super.c:1530
do_new_mount+0x289/0xad0 fs/namespace.c:3040
do_mount fs/namespace.c:3383 [inline]
__do_sys_mount fs/namespace.c:3591 [inline]
__se_sys_mount+0x2d3/0x3c0 fs/namespace.c:3568
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

-> #1 (&s->s_dquot.dqio_sem){++++}-{3:3}:
lock_acquire+0x182/0x3c0 kernel/locking/lockdep.c:5666
down_read+0x39/0x50 kernel/locking/rwsem.c:1499
v2_read_dquot+0x4a/0x100 fs/quota/quota_v2.c:332
dquot_acquire+0x186/0x670 fs/quota/dquot.c:435
ext4_acquire_dquot+0x2e0/0x400 fs/ext4/super.c:6743
dqget+0x999/0xdc0 fs/quota/dquot.c:914
__dquot_initialize+0x291/0xcf0 fs/quota/dquot.c:1492
ext4_process_orphan+0x57/0x2d0 fs/ext4/orphan.c:329
ext4_orphan_cleanup+0xb60/0x1340 fs/ext4/orphan.c:474
__ext4_fill_super fs/ext4/super.c:5520 [inline]
ext4_fill_super+0x82e8/0x8810 fs/ext4/super.c:5648
get_tree_bdev+0x400/0x620 fs/super.c:1323
vfs_get_tree+0x88/0x270 fs/super.c:1530
do_new_mount+0x289/0xad0 fs/namespace.c:3040
do_mount fs/namespace.c:3383 [inline]
__do_sys_mount fs/namespace.c:3591 [inline]
__se_sys_mount+0x2d3/0x3c0 fs/namespace.c:3568
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

-> #0 (&dquot->dq_lock){+.+.}-{3:3}:
check_prev_add kernel/locking/lockdep.c:3095 [inline]
check_prevs_add kernel/locking/lockdep.c:3214 [inline]
validate_chain+0x18c1/0x6bd0 kernel/locking/lockdep.c:3829
__lock_acquire+0x1292/0x1f60 kernel/locking/lockdep.c:5053
lock_acquire+0x182/0x3c0 kernel/locking/lockdep.c:5666
__mutex_lock_common+0x1bd/0x26e0 kernel/locking/mutex.c:603
__mutex_lock kernel/locking/mutex.c:747 [inline]
mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:799
dquot_commit+0x58/0x4e0 fs/quota/dquot.c:479
ext4_write_dquot+0x1e4/0x2b0 fs/ext4/super.c:6727
mark_dquot_dirty fs/quota/dquot.c:346 [inline]
mark_all_dquot_dirty fs/quota/dquot.c:384 [inline]
__dquot_alloc_space+0xa09/0x1030 fs/quota/dquot.c:1722
dquot_alloc_space_nodirty include/linux/quotaops.h:300 [inline]
dquot_alloc_space include/linux/quotaops.h:313 [inline]
dquot_alloc_block include/linux/quotaops.h:337 [inline]
ext4_mb_new_blocks+0x106f/0x3e80 fs/ext4/mballoc.c:5573
ext4_ext_map_blocks+0x1868/0x6880 fs/ext4/extents.c:4287
ext4_map_blocks+0xa49/0x1cc0 fs/ext4/inode.c:645
_ext4_get_block+0x233/0x660 fs/ext4/inode.c:802
ext4_block_write_begin+0x6a8/0x2290 fs/ext4/inode.c:1092
ext4_write_begin+0x5cc/0xd50
ext4_da_write_begin+0x326/0x760 fs/ext4/inode.c:2979
generic_perform_write+0x2a8/0x5b0 mm/filemap.c:3738
ext4_buffered_write_iter+0x122/0x3a0 fs/ext4/file.c:285
ext4_file_write_iter+0x1d0/0x18d0
call_write_iter include/linux/fs.h:2188 [inline]
new_sync_write fs/read_write.c:491 [inline]
vfs_write+0x7dc/0xc50 fs/read_write.c:584
ksys_write+0x177/0x2a0 fs/read_write.c:637
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

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.3/12343:
#0: ffff888020f78368 (&f->f_pos_lock){+.+.}-{3:3}, at: __fdget_pos+0x242/0x2e0 fs/file.c:1036
#1: ffff88803337a460 (sb_writers#4){.+.+}-{0:0}, at: vfs_write+0x287/0xc50 fs/read_write.c:580
#2: ffff88804c4cca38 (&sb->s_type->i_mutex_key#8){++++}-{3:3}, at: inode_lock include/linux/fs.h:756 [inline]
#2: ffff88804c4cca38 (&sb->s_type->i_mutex_key#8){++++}-{3:3}, at: ext4_buffered_write_iter+0xae/0x3a0 fs/ext4/file.c:279
#3: ffff88804c4cc8c0 (&ei->i_data_sem/2){++++}-{3:3}, at: ext4_map_blocks+0x971/0x1cc0 fs/ext4/inode.c:638
#4: ffffffff8cc63528 (dquot_srcu){....}-{0:0}, at: rcu_lock_acquire+0x5/0x30 include/linux/rcupdate.h:303

stack backtrace:
CPU: 1 PID: 12343 Comm: syz-executor.3 Not tainted 6.0.0-syzkaller-06475-g4c86114194e6 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/22/2022
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x1b1/0x28e lib/dump_stack.c:106
check_noncircular+0x2cc/0x390 kernel/locking/lockdep.c:2175
check_prev_add kernel/locking/lockdep.c:3095 [inline]
check_prevs_add kernel/locking/lockdep.c:3214 [inline]
validate_chain+0x18c1/0x6bd0 kernel/locking/lockdep.c:3829
__lock_acquire+0x1292/0x1f60 kernel/locking/lockdep.c:5053
lock_acquire+0x182/0x3c0 kernel/locking/lockdep.c:5666
__mutex_lock_common+0x1bd/0x26e0 kernel/locking/mutex.c:603
__mutex_lock kernel/locking/mutex.c:747 [inline]
mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:799
dquot_commit+0x58/0x4e0 fs/quota/dquot.c:479
ext4_write_dquot+0x1e4/0x2b0 fs/ext4/super.c:6727
mark_dquot_dirty fs/quota/dquot.c:346 [inline]
mark_all_dquot_dirty fs/quota/dquot.c:384 [inline]
__dquot_alloc_space+0xa09/0x1030 fs/quota/dquot.c:1722
dquot_alloc_space_nodirty include/linux/quotaops.h:300 [inline]
dquot_alloc_space include/linux/quotaops.h:313 [inline]
dquot_alloc_block include/linux/quotaops.h:337 [inline]
ext4_mb_new_blocks+0x106f/0x3e80 fs/ext4/mballoc.c:5573
ext4_ext_map_blocks+0x1868/0x6880 fs/ext4/extents.c:4287
ext4_map_blocks+0xa49/0x1cc0 fs/ext4/inode.c:645
_ext4_get_block+0x233/0x660 fs/ext4/inode.c:802
ext4_block_write_begin+0x6a8/0x2290 fs/ext4/inode.c:1092
ext4_write_begin+0x5cc/0xd50
ext4_da_write_begin+0x326/0x760 fs/ext4/inode.c:2979
generic_perform_write+0x2a8/0x5b0 mm/filemap.c:3738
ext4_buffered_write_iter+0x122/0x3a0 fs/ext4/file.c:285
ext4_file_write_iter+0x1d0/0x18d0
call_write_iter include/linux/fs.h:2188 [inline]
new_sync_write fs/read_write.c:491 [inline]
vfs_write+0x7dc/0xc50 fs/read_write.c:584
ksys_write+0x177/0x2a0 fs/read_write.c:637
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f54cd28a5a9
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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f54ce4d3168 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007f54cd3abf80 RCX: 00007f54cd28a5a9
RDX: 000000000208e24b RSI: 0000000020000380 RDI: 0000000000000006
RBP: 00007f54cd2e5580 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffe81cd1cbf R14: 00007f54ce4d3300 R15: 0000000000022000
</TASK>
fuse: Bad value for 'group_id'
syz-executor.3 (12343) used greatest stack depth: 15352 bytes left


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

syzbot

unread,
Oct 10, 2022, 6:21:40 PM10/10/22
to ja...@suse.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: bbed346d5a96 Merge branch 'for-next/core' into for-kernelci
git tree: git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci
console output: https://syzkaller.appspot.com/x/log.txt?x=12a6f83a880000
kernel config: https://syzkaller.appspot.com/x/.config?x=3a4a45d2d827c1e
dashboard link: https://syzkaller.appspot.com/bug?extid=70ff52e51b7e7714db8a
compiler: Debian clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU Binutils for Debian) 2.35.2
userspace arch: arm64
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13002db2880000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=14fce2dc880000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/e8e91bc79312/disk-bbed346d.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/c1cb3fb3b77e/vmlinux-bbed346d.xz
mounted in repro #1: https://storage.googleapis.com/syzbot-assets/05209e29dc74/mount_0.gz
mounted in repro #2: https://storage.googleapis.com/syzbot-assets/9644b6673e5e/mount_4.gz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+70ff52...@syzkaller.appspotmail.com

======================================================
WARNING: possible circular locking dependency detected
6.0.0-rc7-syzkaller-18095-gbbed346d5a96 #0 Not tainted
------------------------------------------------------
syz-executor252/3082 is trying to acquire lock:
ffff0000c6c8c0a8 (&dquot->dq_lock){+.+.}-{3:3}, at: dquot_commit+0x34/0x1e4 fs/quota/dquot.c:479

but task is already holding lock:
ffff0000ca4f8c18 (&ei->i_data_sem/2){++++}-{3:3}, at: ext4_map_blocks+0x444/0xaec fs/ext4/inode.c:638

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+0x5c/0x78 kernel/locking/rwsem.c:1499
ext4_map_blocks+0x15c/0xaec fs/ext4/inode.c:568
ext4_getblk+0xc4/0x448 fs/ext4/inode.c:858
ext4_bread+0x3c/0x164 fs/ext4/inode.c:914
ext4_quota_write+0x120/0x31c fs/ext4/super.c:6956
write_blk fs/quota/quota_tree.c:64 [inline]
get_free_dqblk+0xec/0x1a0 fs/quota/quota_tree.c:93
do_insert_tree+0xdc/0x838 fs/quota/quota_tree.c:300
do_insert_tree+0x24c/0x838 fs/quota/quota_tree.c:331
do_insert_tree+0x24c/0x838 fs/quota/quota_tree.c:331
do_insert_tree+0x24c/0x838 fs/quota/quota_tree.c:331
dq_insert_tree fs/quota/quota_tree.c:357 [inline]
qtree_write_dquot+0x188/0x204 fs/quota/quota_tree.c:376
v2_write_dquot+0x70/0xb0 fs/quota/quota_v2.c:358
dquot_acquire+0x158/0x23c fs/quota/dquot.c:444
ext4_acquire_dquot+0xd4/0x11c fs/ext4/super.c:6612
dqget+0x44c/0x5c0 fs/quota/dquot.c:914
__dquot_initialize+0x15c/0x588 fs/quota/dquot.c:1492
dquot_initialize+0x24/0x34 fs/quota/dquot.c:1550
ext4_create+0x50/0x26c fs/ext4/namei.c:2789
lookup_open fs/namei.c:3413 [inline]
open_last_lookups fs/namei.c:3481 [inline]
path_openat+0x804/0x11c4 fs/namei.c:3688
do_filp_open+0xdc/0x1b8 fs/namei.c:3718
file_open_name fs/open.c:1258 [inline]
filp_open+0x104/0x144 fs/open.c:1278
do_coredump+0xd98/0x10a0 fs/coredump.c:697
get_signal+0x7c4/0xb40 kernel/signal.c:2843
do_signal+0xd4/0x438 arch/arm64/kernel/signal.c:1071
do_notify_resume+0xc0/0x1f0 arch/arm64/kernel/signal.c:1124
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/0x16c arch/arm64/kernel/entry-common.c:515
el0t_64_sync_handler+0xcc/0xf0 arch/arm64/kernel/entry-common.c:657
el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581

-> #1 (&s->s_dquot.dqio_sem){++++}-{3:3}:
down_read+0x5c/0x78 kernel/locking/rwsem.c:1499
v2_read_dquot+0x28/0x64 fs/quota/quota_v2.c:332
dquot_acquire+0x74/0x23c fs/quota/dquot.c:435
ext4_acquire_dquot+0xd4/0x11c fs/ext4/super.c:6612
dqget+0x44c/0x5c0 fs/quota/dquot.c:914
__dquot_initialize+0x1b8/0x588 fs/quota/dquot.c:1492
dquot_initialize+0x24/0x34 fs/quota/dquot.c:1550
ext4_create+0x50/0x26c fs/ext4/namei.c:2789
lookup_open fs/namei.c:3413 [inline]
open_last_lookups fs/namei.c:3481 [inline]
path_openat+0x804/0x11c4 fs/namei.c:3688
do_filp_open+0xdc/0x1b8 fs/namei.c:3718
file_open_name fs/open.c:1258 [inline]
filp_open+0x104/0x144 fs/open.c:1278
do_coredump+0xd98/0x10a0 fs/coredump.c:697
get_signal+0x7c4/0xb40 kernel/signal.c:2843
do_signal+0xd4/0x438 arch/arm64/kernel/signal.c:1071
do_notify_resume+0xc0/0x1f0 arch/arm64/kernel/signal.c:1124
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/0x16c arch/arm64/kernel/entry-common.c:515
el0t_64_sync_handler+0xcc/0xf0 arch/arm64/kernel/entry-common.c:657
el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581

-> #0 (&dquot->dq_lock){+.+.}-{3:3}:
check_prev_add kernel/locking/lockdep.c:3095 [inline]
check_prevs_add kernel/locking/lockdep.c:3214 [inline]
validate_chain kernel/locking/lockdep.c:3829 [inline]
__lock_acquire+0x1530/0x30a4 kernel/locking/lockdep.c:5053
lock_acquire+0x100/0x1f8 kernel/locking/lockdep.c:5666
__mutex_lock_common+0xd4/0xca8 kernel/locking/mutex.c:603
__mutex_lock kernel/locking/mutex.c:747 [inline]
mutex_lock_nested+0x38/0x44 kernel/locking/mutex.c:799
dquot_commit+0x34/0x1e4 fs/quota/dquot.c:479
ext4_write_dquot fs/ext4/super.c:6596 [inline]
ext4_mark_dquot_dirty+0xdc/0x148 fs/ext4/super.c:6644
mark_dquot_dirty fs/quota/dquot.c:346 [inline]
mark_all_dquot_dirty fs/quota/dquot.c:384 [inline]
__dquot_alloc_space+0x2a8/0x644 fs/quota/dquot.c:1722
dquot_alloc_space_nodirty include/linux/quotaops.h:300 [inline]
dquot_alloc_space include/linux/quotaops.h:313 [inline]
dquot_alloc_block include/linux/quotaops.h:337 [inline]
ext4_mb_new_blocks+0x5fc/0x9e4 fs/ext4/mballoc.c:5574
ext4_ext_map_blocks+0x7d8/0x10a0 fs/ext4/extents.c:4285
ext4_map_blocks+0x4a8/0xaec fs/ext4/inode.c:645
_ext4_get_block+0xb4/0x248 fs/ext4/inode.c:802
ext4_get_block+0x4c/0x60 fs/ext4/inode.c:819
ext4_block_write_begin+0x2d8/0x112c fs/ext4/inode.c:1092
ext4_write_begin+0x21c/0xc38
ext4_da_write_begin+0x1ac/0x4d0 fs/ext4/inode.c:2972
generic_perform_write+0xf0/0x2cc mm/filemap.c:3738
ext4_buffered_write_iter+0x15c/0x294 fs/ext4/file.c:270
ext4_file_write_iter+0x544/0xc6c
__kernel_write+0x128/0x2cc fs/read_write.c:523
__dump_emit fs/coredump.c:805 [inline]
dump_emit+0x210/0x4d4 fs/coredump.c:842
elf_core_dump+0x111c/0x16dc fs/binfmt_elf.c:2263
do_coredump+0x91c/0x10a0 fs/coredump.c:756
get_signal+0x7c4/0xb40 kernel/signal.c:2843
do_signal+0xd4/0x438 arch/arm64/kernel/signal.c:1071
do_notify_resume+0xc0/0x1f0 arch/arm64/kernel/signal.c:1124
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/0x16c arch/arm64/kernel/entry-common.c:515
el0t_64_sync_handler+0xcc/0xf0 arch/arm64/kernel/entry-common.c:657
el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581

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 ***

4 locks held by syz-executor252/3082:
#0: ffff0000cd8a1460 (sb_writers#3){.+.+}-{0:0}, at: do_coredump+0x910/0x10a0 fs/coredump.c:755
#1: ffff0000ca4f8d90 (&sb->s_type->i_mutex_key#8){++++}-{3:3}, at: inode_lock include/linux/fs.h:756 [inline]
#1: ffff0000ca4f8d90 (&sb->s_type->i_mutex_key#8){++++}-{3:3}, at: ext4_buffered_write_iter+0x50/0x294 fs/ext4/file.c:264
#2: ffff0000ca4f8c18 (&ei->i_data_sem/2){++++}-{3:3}, at: ext4_map_blocks+0x444/0xaec fs/ext4/inode.c:638
#3: ffff80000d47ee98 (dquot_srcu){....}-{0:0}, at: rcu_lock_acquire+0x10/0x4c include/linux/rcupdate.h:279

stack backtrace:
CPU: 0 PID: 3082 Comm: syz-executor252 Not tainted 6.0.0-rc7-syzkaller-18095-gbbed346d5a96 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/30/2022
Call trace:
dump_backtrace+0x1c4/0x1f0 arch/arm64/kernel/stacktrace.c:156
show_stack+0x2c/0x54 arch/arm64/kernel/stacktrace.c:163
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x104/0x16c lib/dump_stack.c:106
dump_stack+0x1c/0x58 lib/dump_stack.c:113
print_circular_bug+0x2c4/0x2c8 kernel/locking/lockdep.c:2053
check_noncircular+0x14c/0x154 kernel/locking/lockdep.c:2175
check_prev_add kernel/locking/lockdep.c:3095 [inline]
check_prevs_add kernel/locking/lockdep.c:3214 [inline]
validate_chain kernel/locking/lockdep.c:3829 [inline]
__lock_acquire+0x1530/0x30a4 kernel/locking/lockdep.c:5053
lock_acquire+0x100/0x1f8 kernel/locking/lockdep.c:5666
__mutex_lock_common+0xd4/0xca8 kernel/locking/mutex.c:603
__mutex_lock kernel/locking/mutex.c:747 [inline]
mutex_lock_nested+0x38/0x44 kernel/locking/mutex.c:799
dquot_commit+0x34/0x1e4 fs/quota/dquot.c:479
ext4_write_dquot fs/ext4/super.c:6596 [inline]
ext4_mark_dquot_dirty+0xdc/0x148 fs/ext4/super.c:6644
mark_dquot_dirty fs/quota/dquot.c:346 [inline]
mark_all_dquot_dirty fs/quota/dquot.c:384 [inline]
__dquot_alloc_space+0x2a8/0x644 fs/quota/dquot.c:1722
dquot_alloc_space_nodirty include/linux/quotaops.h:300 [inline]
dquot_alloc_space include/linux/quotaops.h:313 [inline]
dquot_alloc_block include/linux/quotaops.h:337 [inline]
ext4_mb_new_blocks+0x5fc/0x9e4 fs/ext4/mballoc.c:5574
ext4_ext_map_blocks+0x7d8/0x10a0 fs/ext4/extents.c:4285
ext4_map_blocks+0x4a8/0xaec fs/ext4/inode.c:645
_ext4_get_block+0xb4/0x248 fs/ext4/inode.c:802
ext4_get_block+0x4c/0x60 fs/ext4/inode.c:819
ext4_block_write_begin+0x2d8/0x112c fs/ext4/inode.c:1092
ext4_write_begin+0x21c/0xc38
ext4_da_write_begin+0x1ac/0x4d0 fs/ext4/inode.c:2972
generic_perform_write+0xf0/0x2cc mm/filemap.c:3738
ext4_buffered_write_iter+0x15c/0x294 fs/ext4/file.c:270
ext4_file_write_iter+0x544/0xc6c
__kernel_write+0x128/0x2cc fs/read_write.c:523
__dump_emit fs/coredump.c:805 [inline]
dump_emit+0x210/0x4d4 fs/coredump.c:842
elf_core_dump+0x111c/0x16dc fs/binfmt_elf.c:2263
do_coredump+0x91c/0x10a0 fs/coredump.c:756
get_signal+0x7c4/0xb40 kernel/signal.c:2843
do_signal+0xd4/0x438 arch/arm64/kernel/signal.c:1071
do_notify_resume+0xc0/0x1f0 arch/arm64/kernel/signal.c:1124
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/0x16c arch/arm64/kernel/entry-common.c:515
el0t_64_sync_handler+0xcc/0xf0 arch/arm64/kernel/entry-common.c:657
el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581
EXT4-fs (loop0): unmounting filesystem.

Theodore Ts'o

unread,
May 6, 2023, 12:55:55 PM5/6/23
to syzbot, syzkall...@googlegroups.com
#syz test git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git tt/next

diff --git a/fs/ext4/orphan.c b/fs/ext4/orphan.c
index e5b47dda3317..5d5ac37ddca6 100644
--- a/fs/ext4/orphan.c
+++ b/fs/ext4/orphan.c
@@ -328,7 +328,7 @@ static void ext4_process_orphan(struct inode *inode,

dquot_initialize(inode);
if (inode->i_nlink) {
- if (test_opt(sb, DEBUG))
+ if (1)
ext4_msg(sb, KERN_DEBUG,
"%s: truncating inode %lu to %lld bytes",
__func__, inode->i_ino, inode->i_size);
@@ -349,7 +349,7 @@ static void ext4_process_orphan(struct inode *inode,
inode_unlock(inode);
(*nr_truncates)++;
} else {
- if (test_opt(sb, DEBUG))
+ if (1)
ext4_msg(sb, KERN_DEBUG,
"%s: deleting unreferenced inode %lu",
__func__, inode->i_ino);

syzbot

unread,
May 6, 2023, 1:18:21 PM5/6/23
to syzkall...@googlegroups.com, ty...@mit.edu
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+70ff52...@syzkaller.appspotmail.com

Tested on:

commit: e9895f68 ext4: improve error handling from ext4_dirhas..
git tree: git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git tt/next
console output: https://syzkaller.appspot.com/x/log.txt?x=13214f6a280000
kernel config: https://syzkaller.appspot.com/x/.config?x=26f73f8967829661
dashboard link: https://syzkaller.appspot.com/bug?extid=70ff52e51b7e7714db8a
compiler: Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2
patch: https://syzkaller.appspot.com/x/patch.diff?x=175fde6c280000

Note: testing is done by a robot and is best-effort only.

Theodore Ts'o

unread,
May 14, 2023, 4:35:51 PM5/14/23
to syzbot, syzkall...@googlegroups.com

syzbot

unread,
May 14, 2023, 5:01:33 PM5/14/23
to syzkall...@googlegroups.com, ty...@mit.edu
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
possible deadlock in dquot_commit

loop0: detected capacity change from 0 to 512
EXT4-fs (loop0): orphan cleanup on readonly fs
======================================================
WARNING: possible circular locking dependency detected
6.3.0-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.0/5687 is trying to acquire lock:
ffff88806f138ce8 (&dquot->dq_lock){+.+.}-{3:3}, at: dquot_commit+0x5b/0x520 fs/quota/dquot.c:479

but task is already holding lock:
ffff8880739bdcd0 (&ei->i_data_sem/2){++++}-{3:3}, at: ext4_truncate+0x981/0x1150 fs/ext4/inode.c:4337

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&ei->i_data_sem/2){++++}-{3:3}:
lock_acquire+0x1e1/0x520 kernel/locking/lockdep.c:5669
down_read+0x3d/0x50 kernel/locking/rwsem.c:1520
ext4_map_blocks+0x38e/0x1cf0 fs/ext4/inode.c:574
ext4_getblk+0x1ef/0x7c0 fs/ext4/inode.c:863
ext4_bread+0x2e/0x180 fs/ext4/inode.c:919
ext4_quota_write+0x222/0x580 fs/ext4/super.c:7135
write_blk fs/quota/quota_tree.c:64 [inline]
get_free_dqblk+0x336/0x690 fs/quota/quota_tree.c:130
do_insert_tree+0x265/0x1a60 fs/quota/quota_tree.c:340
do_insert_tree+0x70f/0x1a60 fs/quota/quota_tree.c:375
do_insert_tree+0x70f/0x1a60 fs/quota/quota_tree.c:375
do_insert_tree+0x70f/0x1a60 fs/quota/quota_tree.c:375
dq_insert_tree fs/quota/quota_tree.c:401 [inline]
qtree_write_dquot+0x3bd/0x530 fs/quota/quota_tree.c:420
v2_write_dquot+0x120/0x190 fs/quota/quota_v2.c:358
dquot_acquire+0x351/0x680 fs/quota/dquot.c:444
ext4_acquire_dquot+0x2e6/0x400 fs/ext4/super.c:6770
dqget+0x98f/0xdb0 fs/quota/dquot.c:914
__dquot_initialize+0x462/0xe20 fs/quota/dquot.c:1492
ext4_process_orphan+0x57/0x2d0 fs/ext4/orphan.c:329
ext4_orphan_cleanup+0xb21/0x13c0 fs/ext4/orphan.c:474
__ext4_fill_super fs/ext4/super.c:5509 [inline]
ext4_fill_super+0x8239/0x8990 fs/ext4/super.c:5637
get_tree_bdev+0x402/0x620 fs/super.c:1303
vfs_get_tree+0x8c/0x270 fs/super.c:1510
do_new_mount+0x28f/0xae0 fs/namespace.c:3042
do_mount fs/namespace.c:3385 [inline]
__do_sys_mount fs/namespace.c:3594 [inline]
__se_sys_mount+0x2d9/0x3c0 fs/namespace.c:3571
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

-> #1 (&s->s_dquot.dqio_sem){++++}-{3:3}:
lock_acquire+0x1e1/0x520 kernel/locking/lockdep.c:5669
down_read+0x3d/0x50 kernel/locking/rwsem.c:1520
v2_read_dquot+0x4e/0x110 fs/quota/quota_v2.c:332
dquot_acquire+0x18c/0x680 fs/quota/dquot.c:435
ext4_acquire_dquot+0x2e6/0x400 fs/ext4/super.c:6770
dqget+0x98f/0xdb0 fs/quota/dquot.c:914
__dquot_initialize+0x2dd/0xe20 fs/quota/dquot.c:1492
ext4_process_orphan+0x57/0x2d0 fs/ext4/orphan.c:329
ext4_orphan_cleanup+0xb21/0x13c0 fs/ext4/orphan.c:474
__ext4_fill_super fs/ext4/super.c:5509 [inline]
ext4_fill_super+0x8239/0x8990 fs/ext4/super.c:5637
get_tree_bdev+0x402/0x620 fs/super.c:1303
vfs_get_tree+0x8c/0x270 fs/super.c:1510
do_new_mount+0x28f/0xae0 fs/namespace.c:3042
do_mount fs/namespace.c:3385 [inline]
__do_sys_mount fs/namespace.c:3594 [inline]
__se_sys_mount+0x2d9/0x3c0 fs/namespace.c:3571
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

-> #0 (&dquot->dq_lock){+.+.}-{3:3}:
check_prev_add kernel/locking/lockdep.c:3098 [inline]
check_prevs_add kernel/locking/lockdep.c:3217 [inline]
validate_chain+0x166b/0x58e0 kernel/locking/lockdep.c:3832
__lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5056
lock_acquire+0x1e1/0x520 kernel/locking/lockdep.c:5669
__mutex_lock_common+0x1d8/0x2530 kernel/locking/mutex.c:603
__mutex_lock kernel/locking/mutex.c:747 [inline]
mutex_lock_nested+0x1b/0x20 kernel/locking/mutex.c:799
dquot_commit+0x5b/0x520 fs/quota/dquot.c:479
ext4_write_dquot+0x1f2/0x2c0 fs/ext4/super.c:6754
mark_dquot_dirty fs/quota/dquot.c:346 [inline]
mark_all_dquot_dirty fs/quota/dquot.c:384 [inline]
__dquot_free_space+0x9a4/0xfc0 fs/quota/dquot.c:1907
dquot_free_space_nodirty include/linux/quotaops.h:379 [inline]
dquot_free_space include/linux/quotaops.h:384 [inline]
dquot_free_block include/linux/quotaops.h:395 [inline]
ext4_mb_clear_bb fs/ext4/mballoc.c:6044 [inline]
ext4_free_blocks+0x1ea3/0x2dd0 fs/ext4/mballoc.c:6173
ext4_remove_blocks fs/ext4/extents.c:2545 [inline]
ext4_ext_rm_leaf fs/ext4/extents.c:2710 [inline]
ext4_ext_remove_space+0x216e/0x4d90 fs/ext4/extents.c:2958
ext4_ext_truncate+0x176/0x210 fs/ext4/extents.c:4416
ext4_truncate+0xa0a/0x1150 fs/ext4/inode.c:4342
ext4_process_orphan+0x1aa/0x2d0 fs/ext4/orphan.c:339
ext4_orphan_cleanup+0xb21/0x13c0 fs/ext4/orphan.c:474
__ext4_fill_super fs/ext4/super.c:5509 [inline]
ext4_fill_super+0x8239/0x8990 fs/ext4/super.c:5637
get_tree_bdev+0x402/0x620 fs/super.c:1303
vfs_get_tree+0x8c/0x270 fs/super.c:1510
do_new_mount+0x28f/0xae0 fs/namespace.c:3042
do_mount fs/namespace.c:3385 [inline]
__do_sys_mount fs/namespace.c:3594 [inline]
__se_sys_mount+0x2d9/0x3c0 fs/namespace.c:3571
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

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 ***

4 locks held by syz-executor.0/5687:
#0: ffff8880233340e0 (&type->s_umount_key#26/1){+.+.}-{3:3}, at: alloc_super+0x217/0x930 fs/super.c:228
#1: ffff8880739bde48 (&sb->s_type->i_mutex_key#7){++++}-{3:3}, at: inode_lock include/linux/fs.h:758 [inline]
#1: ffff8880739bde48 (&sb->s_type->i_mutex_key#7){++++}-{3:3}, at: ext4_process_orphan+0x164/0x2d0 fs/ext4/orphan.c:337
#2: ffff8880739bdcd0 (&ei->i_data_sem/2){++++}-{3:3}, at: ext4_truncate+0x981/0x1150 fs/ext4/inode.c:4337
#3: ffffffff8d0698c8 (dquot_srcu){....}-{0:0}, at: rcu_lock_acquire+0x5/0x40 include/linux/rcupdate.h:326

stack backtrace:
CPU: 1 PID: 5687 Comm: syz-executor.0 Not tainted 6.3.0-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/28/2023
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x1e7/0x2d0 lib/dump_stack.c:106
check_noncircular+0x2fe/0x3b0 kernel/locking/lockdep.c:2178
check_prev_add kernel/locking/lockdep.c:3098 [inline]
check_prevs_add kernel/locking/lockdep.c:3217 [inline]
validate_chain+0x166b/0x58e0 kernel/locking/lockdep.c:3832
__lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5056
lock_acquire+0x1e1/0x520 kernel/locking/lockdep.c:5669
__mutex_lock_common+0x1d8/0x2530 kernel/locking/mutex.c:603
__mutex_lock kernel/locking/mutex.c:747 [inline]
mutex_lock_nested+0x1b/0x20 kernel/locking/mutex.c:799
dquot_commit+0x5b/0x520 fs/quota/dquot.c:479
ext4_write_dquot+0x1f2/0x2c0 fs/ext4/super.c:6754
mark_dquot_dirty fs/quota/dquot.c:346 [inline]
mark_all_dquot_dirty fs/quota/dquot.c:384 [inline]
__dquot_free_space+0x9a4/0xfc0 fs/quota/dquot.c:1907
dquot_free_space_nodirty include/linux/quotaops.h:379 [inline]
dquot_free_space include/linux/quotaops.h:384 [inline]
dquot_free_block include/linux/quotaops.h:395 [inline]
ext4_mb_clear_bb fs/ext4/mballoc.c:6044 [inline]
ext4_free_blocks+0x1ea3/0x2dd0 fs/ext4/mballoc.c:6173
ext4_remove_blocks fs/ext4/extents.c:2545 [inline]
ext4_ext_rm_leaf fs/ext4/extents.c:2710 [inline]
ext4_ext_remove_space+0x216e/0x4d90 fs/ext4/extents.c:2958
ext4_ext_truncate+0x176/0x210 fs/ext4/extents.c:4416
ext4_truncate+0xa0a/0x1150 fs/ext4/inode.c:4342
ext4_process_orphan+0x1aa/0x2d0 fs/ext4/orphan.c:339
ext4_orphan_cleanup+0xb21/0x13c0 fs/ext4/orphan.c:474
__ext4_fill_super fs/ext4/super.c:5509 [inline]
ext4_fill_super+0x8239/0x8990 fs/ext4/super.c:5637
get_tree_bdev+0x402/0x620 fs/super.c:1303
vfs_get_tree+0x8c/0x270 fs/super.c:1510
do_new_mount+0x28f/0xae0 fs/namespace.c:3042
do_mount fs/namespace.c:3385 [inline]
__do_sys_mount fs/namespace.c:3594 [inline]
__se_sys_mount+0x2d9/0x3c0 fs/namespace.c:3571
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7ff47268d62a
Code: 48 c7 c2 b8 ff ff ff f7 d8 64 89 02 b8 ff ff ff ff eb d2 e8 b8 04 00 00 0f 1f 84 00 00 00 00 00 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ff473353f88 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00000000000004a5 RCX: 00007ff47268d62a
RDX: 0000000020000140 RSI: 0000000020000500 RDI: 00007ff473353fe0
RBP: 00007ff473354020 R08: 00007ff473354020 R09: 0000000000000047
R10: 0000000000000047 R11: 0000000000000246 R12: 0000000020000140
R13: 0000000020000500 R14: 00007ff473353fe0 R15: 0000000020000100
</TASK>
EXT4-fs (loop0): 1 truncate cleaned up


Tested on:

commit: 457391b0 Linux 6.3
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git v6.3
console output: https://syzkaller.appspot.com/x/log.txt?x=16fdc90a280000
kernel config: https://syzkaller.appspot.com/x/.config?x=42cc4f91f532bc55
dashboard link: https://syzkaller.appspot.com/bug?extid=70ff52e51b7e7714db8a
compiler: Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2

Note: no patches were applied.

Theodore Ts'o

unread,
May 14, 2023, 8:33:04 PM5/14/23
to syzbot, syzkall...@googlegroups.com

syzbot

unread,
May 14, 2023, 9:02:32 PM5/14/23
to syzkall...@googlegroups.com, ty...@mit.edu
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+70ff52...@syzkaller.appspotmail.com

Tested on:

commit: f1fcbaa1 Linux 6.4-rc2
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git v6.4-rc2
console output: https://syzkaller.appspot.com/x/log.txt?x=143420fa280000
kernel config: https://syzkaller.appspot.com/x/.config?x=28559677ea982824
dashboard link: https://syzkaller.appspot.com/bug?extid=70ff52e51b7e7714db8a
compiler: Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2

Note: no patches were applied.

Theodore Ts'o

unread,
May 14, 2023, 9:18:58 PM5/14/23
to syzbot, syzkall...@googlegroups.com

syzbot

unread,
May 14, 2023, 10:08:24 PM5/14/23
to syzkall...@googlegroups.com, ty...@mit.edu
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+70ff52...@syzkaller.appspotmail.com

Tested on:

commit: ac9a7868 Linux 6.4-rc1
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git v6.4-rc1
console output: https://syzkaller.appspot.com/x/log.txt?x=12d41f8a280000
kernel config: https://syzkaller.appspot.com/x/.config?x=7f2e5c3b3ba61823

Theodore Ts'o

unread,
May 14, 2023, 10:37:14 PM5/14/23
to syzbot, syzkall...@googlegroups.com
#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 9a9d01f081ea29a5a8afc4504b1bc48daffa5cc1

syzbot

unread,
May 14, 2023, 10:57:23 PM5/14/23
to syzkall...@googlegroups.com, ty...@mit.edu
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
possible deadlock in dquot_commit

loop0: detected capacity change from 0 to 512
EXT4-fs (loop0): orphan cleanup on readonly fs
======================================================
WARNING: possible circular locking dependency detected
6.3.0-rc3-syzkaller-00065-g9a9d01f081ea #0 Not tainted
------------------------------------------------------
syz-executor.0/5753 is trying to acquire lock:
ffff888075ad25e8 (&dquot->dq_lock){+.+.}-{3:3}, at: dquot_commit+0x5b/0x520 fs/quota/dquot.c:479

but task is already holding lock:
ffff888075a40288 (&ei->i_data_sem/2){++++}-{3:3}, at: ext4_truncate+0x981/0x1150 fs/ext4/inode.c:4192

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&ei->i_data_sem/2){++++}-{3:3}:
lock_acquire+0x1e1/0x520 kernel/locking/lockdep.c:5669
down_read+0x3d/0x50 kernel/locking/rwsem.c:1520
ext4_map_blocks+0x38e/0x1cf0 fs/ext4/inode.c:573
ext4_getblk+0x1ef/0x7c0 fs/ext4/inode.c:862
ext4_bread+0x2e/0x180 fs/ext4/inode.c:918
ext4_quota_write+0x222/0x580 fs/ext4/super.c:7146
write_blk fs/quota/quota_tree.c:64 [inline]
get_free_dqblk+0x336/0x690 fs/quota/quota_tree.c:130
do_insert_tree+0x265/0x1a60 fs/quota/quota_tree.c:340
do_insert_tree+0x70f/0x1a60 fs/quota/quota_tree.c:375
do_insert_tree+0x70f/0x1a60 fs/quota/quota_tree.c:375
do_insert_tree+0x70f/0x1a60 fs/quota/quota_tree.c:375
dq_insert_tree fs/quota/quota_tree.c:401 [inline]
qtree_write_dquot+0x3bd/0x530 fs/quota/quota_tree.c:420
v2_write_dquot+0x120/0x190 fs/quota/quota_v2.c:358
dquot_acquire+0x351/0x680 fs/quota/dquot.c:444
ext4_acquire_dquot+0x2e6/0x400 fs/ext4/super.c:6781
dqget+0x98f/0xdb0 fs/quota/dquot.c:914
__dquot_initialize+0x462/0xe20 fs/quota/dquot.c:1492
ext4_process_orphan+0x57/0x2d0 fs/ext4/orphan.c:329
ext4_orphan_cleanup+0xb21/0x13c0 fs/ext4/orphan.c:474
__ext4_fill_super fs/ext4/super.c:5509 [inline]
ext4_fill_super+0x8239/0x8990 fs/ext4/super.c:5637
get_tree_bdev+0x402/0x620 fs/super.c:1294
vfs_get_tree+0x8c/0x270 fs/super.c:1501
do_new_mount+0x28f/0xae0 fs/namespace.c:3042
do_mount fs/namespace.c:3385 [inline]
__do_sys_mount fs/namespace.c:3594 [inline]
__se_sys_mount+0x2d9/0x3c0 fs/namespace.c:3571
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

-> #1 (&s->s_dquot.dqio_sem){++++}-{3:3}:
lock_acquire+0x1e1/0x520 kernel/locking/lockdep.c:5669
down_read+0x3d/0x50 kernel/locking/rwsem.c:1520
v2_read_dquot+0x4e/0x110 fs/quota/quota_v2.c:332
dquot_acquire+0x18c/0x680 fs/quota/dquot.c:435
ext4_acquire_dquot+0x2e6/0x400 fs/ext4/super.c:6781
dqget+0x98f/0xdb0 fs/quota/dquot.c:914
__dquot_initialize+0x2dd/0xe20 fs/quota/dquot.c:1492
ext4_process_orphan+0x57/0x2d0 fs/ext4/orphan.c:329
ext4_orphan_cleanup+0xb21/0x13c0 fs/ext4/orphan.c:474
__ext4_fill_super fs/ext4/super.c:5509 [inline]
ext4_fill_super+0x8239/0x8990 fs/ext4/super.c:5637
get_tree_bdev+0x402/0x620 fs/super.c:1294
vfs_get_tree+0x8c/0x270 fs/super.c:1501
do_new_mount+0x28f/0xae0 fs/namespace.c:3042
do_mount fs/namespace.c:3385 [inline]
__do_sys_mount fs/namespace.c:3594 [inline]
__se_sys_mount+0x2d9/0x3c0 fs/namespace.c:3571
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

-> #0 (&dquot->dq_lock){+.+.}-{3:3}:
check_prev_add kernel/locking/lockdep.c:3098 [inline]
check_prevs_add kernel/locking/lockdep.c:3217 [inline]
validate_chain+0x166b/0x58e0 kernel/locking/lockdep.c:3832
__lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5056
lock_acquire+0x1e1/0x520 kernel/locking/lockdep.c:5669
__mutex_lock_common+0x1d8/0x2530 kernel/locking/mutex.c:603
__mutex_lock kernel/locking/mutex.c:747 [inline]
mutex_lock_nested+0x1b/0x20 kernel/locking/mutex.c:799
dquot_commit+0x5b/0x520 fs/quota/dquot.c:479
ext4_write_dquot+0x1f2/0x2c0 fs/ext4/super.c:6765
mark_dquot_dirty fs/quota/dquot.c:346 [inline]
mark_all_dquot_dirty fs/quota/dquot.c:384 [inline]
__dquot_free_space+0x9a4/0xfc0 fs/quota/dquot.c:1907
dquot_free_space_nodirty include/linux/quotaops.h:379 [inline]
dquot_free_space include/linux/quotaops.h:384 [inline]
dquot_free_block include/linux/quotaops.h:395 [inline]
ext4_mb_clear_bb fs/ext4/mballoc.c:6223 [inline]
ext4_free_blocks+0x1e98/0x2d60 fs/ext4/mballoc.c:6352
ext4_remove_blocks fs/ext4/extents.c:2545 [inline]
ext4_ext_rm_leaf fs/ext4/extents.c:2710 [inline]
ext4_ext_remove_space+0x216e/0x4d90 fs/ext4/extents.c:2958
ext4_ext_truncate+0x176/0x210 fs/ext4/extents.c:4416
ext4_truncate+0xa0a/0x1150 fs/ext4/inode.c:4197
ext4_process_orphan+0x1aa/0x2d0 fs/ext4/orphan.c:339
ext4_orphan_cleanup+0xb21/0x13c0 fs/ext4/orphan.c:474
__ext4_fill_super fs/ext4/super.c:5509 [inline]
ext4_fill_super+0x8239/0x8990 fs/ext4/super.c:5637
get_tree_bdev+0x402/0x620 fs/super.c:1294
vfs_get_tree+0x8c/0x270 fs/super.c:1501
do_new_mount+0x28f/0xae0 fs/namespace.c:3042
do_mount fs/namespace.c:3385 [inline]
__do_sys_mount fs/namespace.c:3594 [inline]
__se_sys_mount+0x2d9/0x3c0 fs/namespace.c:3571
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

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 ***

4 locks held by syz-executor.0/5753:
#0: ffff88807d1b20e0 (&type->s_umount_key#27/1){+.+.}-{3:3}, at: alloc_super+0x217/0x930 fs/super.c:228
#1: ffff888075a40400 (&sb->s_type->i_mutex_key#7){++++}-{3:3}, at: inode_lock include/linux/fs.h:758 [inline]
#1: ffff888075a40400 (&sb->s_type->i_mutex_key#7){++++}-{3:3}, at: ext4_process_orphan+0x164/0x2d0 fs/ext4/orphan.c:337
#2: ffff888075a40288 (&ei->i_data_sem/2){++++}-{3:3}, at: ext4_truncate+0x981/0x1150 fs/ext4/inode.c:4192
#3: ffffffff8d069788 (dquot_srcu){....}-{0:0}, at: rcu_lock_acquire+0x5/0x40 include/linux/rcupdate.h:326

stack backtrace:
CPU: 0 PID: 5753 Comm: syz-executor.0 Not tainted 6.3.0-rc3-syzkaller-00065-g9a9d01f081ea #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/28/2023
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x1e7/0x2d0 lib/dump_stack.c:106
check_noncircular+0x2fe/0x3b0 kernel/locking/lockdep.c:2178
check_prev_add kernel/locking/lockdep.c:3098 [inline]
check_prevs_add kernel/locking/lockdep.c:3217 [inline]
validate_chain+0x166b/0x58e0 kernel/locking/lockdep.c:3832
__lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5056
lock_acquire+0x1e1/0x520 kernel/locking/lockdep.c:5669
__mutex_lock_common+0x1d8/0x2530 kernel/locking/mutex.c:603
__mutex_lock kernel/locking/mutex.c:747 [inline]
mutex_lock_nested+0x1b/0x20 kernel/locking/mutex.c:799
dquot_commit+0x5b/0x520 fs/quota/dquot.c:479
ext4_write_dquot+0x1f2/0x2c0 fs/ext4/super.c:6765
mark_dquot_dirty fs/quota/dquot.c:346 [inline]
mark_all_dquot_dirty fs/quota/dquot.c:384 [inline]
__dquot_free_space+0x9a4/0xfc0 fs/quota/dquot.c:1907
dquot_free_space_nodirty include/linux/quotaops.h:379 [inline]
dquot_free_space include/linux/quotaops.h:384 [inline]
dquot_free_block include/linux/quotaops.h:395 [inline]
ext4_mb_clear_bb fs/ext4/mballoc.c:6223 [inline]
ext4_free_blocks+0x1e98/0x2d60 fs/ext4/mballoc.c:6352
ext4_remove_blocks fs/ext4/extents.c:2545 [inline]
ext4_ext_rm_leaf fs/ext4/extents.c:2710 [inline]
ext4_ext_remove_space+0x216e/0x4d90 fs/ext4/extents.c:2958
ext4_ext_truncate+0x176/0x210 fs/ext4/extents.c:4416
ext4_truncate+0xa0a/0x1150 fs/ext4/inode.c:4197
ext4_process_orphan+0x1aa/0x2d0 fs/ext4/orphan.c:339
ext4_orphan_cleanup+0xb21/0x13c0 fs/ext4/orphan.c:474
__ext4_fill_super fs/ext4/super.c:5509 [inline]
ext4_fill_super+0x8239/0x8990 fs/ext4/super.c:5637
get_tree_bdev+0x402/0x620 fs/super.c:1294
vfs_get_tree+0x8c/0x270 fs/super.c:1501
do_new_mount+0x28f/0xae0 fs/namespace.c:3042
do_mount fs/namespace.c:3385 [inline]
__do_sys_mount fs/namespace.c:3594 [inline]
__se_sys_mount+0x2d9/0x3c0 fs/namespace.c:3571
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7ffa3368d62a
Code: 48 c7 c2 b8 ff ff ff f7 d8 64 89 02 b8 ff ff ff ff eb d2 e8 b8 04 00 00 0f 1f 84 00 00 00 00 00 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffa342fdf88 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00000000000004a5 RCX: 00007ffa3368d62a
RDX: 0000000020000140 RSI: 0000000020000500 RDI: 00007ffa342fdfe0
RBP: 00007ffa342fe020 R08: 00007ffa342fe020 R09: 0000000000000047
R10: 0000000000000047 R11: 0000000000000246 R12: 0000000020000140
R13: 0000000020000500 R14: 00007ffa342fdfe0 R15: 0000000020000100
</TASK>
EXT4-fs (loop0): 1 truncate cleaned up


Tested on:

commit: 9a9d01f0 ext4: Convert ext4_da_write_inline_data_begin..
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=169ee776280000
kernel config: https://syzkaller.appspot.com/x/.config?x=acdb62bf488a8fe5

syzbot

unread,
Jun 14, 2023, 4:47:27 PM6/14/23
to adilger...@dilger.ca, boqun...@gmail.com, ja...@suse.com, linux...@vger.kernel.org, linux-...@vger.kernel.org, linux-...@vger.kernel.org, pau...@kernel.org, pet...@infradead.org, syzkall...@googlegroups.com, ty...@mit.edu
syzbot suspects this issue was fixed by commit:

commit f0f44752f5f61ee4e3bd88ae033fdb888320aafe
Author: Boqun Feng <boqun...@gmail.com>
Date: Fri Jan 13 06:59:54 2023 +0000

rcu: Annotate SRCU's update-side lockdep dependencies

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=1355576f280000
start commit: ab072681eabe Merge tag 'irq_urgent_for_v6.2_rc6' of git://..
git tree: upstream
kernel config: https://syzkaller.appspot.com/x/.config?x=c8d5c2ee6c2bd4b8
dashboard link: https://syzkaller.appspot.com/bug?extid=70ff52e51b7e7714db8a
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=11436221480000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=15133749480000

If the result looks correct, please mark the issue as fixed by replying with:

#syz fix: rcu: Annotate SRCU's update-side lockdep dependencies

For information about bisection process see: https://goo.gl/tpsmEJ#bisection

syzbot

unread,
Aug 13, 2023, 5:11:01 AM8/13/23
to syzkall...@googlegroups.com
Auto-closing this bug as obsolete.
No recent activity, existing reproducers are no longer triggering the issue.
Reply all
Reply to author
Forward
0 new messages