syzbot


possible deadlock in ext4_map_blocks

Status: upstream: reported on 2022/10/12 20:37
Subsystems: ext4
[Documentation on labels]
Reported-by: syzbot+b77dd191b732e956529e@syzkaller.appspotmail.com
First crash: 621d, last: 484d
Similar bugs (3)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-6.1 possible deadlock in ext4_map_blocks origin:lts-only C inconclusive 123 6h16m 475d 0/3 upstream: reported C repro on 2023/03/08 04:51
upstream possible deadlock in ext4_map_blocks ext4 480 408d 629d 0/27 auto-obsoleted due to no activity on 2023/08/11 20:48
linux-5.15 possible deadlock in ext4_map_blocks origin:lts-only C done 95 6d10h 471d 0/3 upstream: reported C repro on 2023/03/11 16:28

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
4.19.211-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.2/14244 is trying to acquire lock:
00000000890b0ce3 (&ei->i_data_sem/2){++++}, at: ext4_map_blocks+0x33e/0x1a50 fs/ext4/inode.c:578

but task is already holding lock:
000000001db7ce9d (&s->s_dquot.dqio_sem){++++}, at: v2_write_dquot+0x8b/0x250 fs/quota/quota_v2.c:355

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&s->s_dquot.dqio_sem){++++}:
       v2_read_dquot+0x49/0x120 fs/quota/quota_v2.c:333
       dquot_acquire+0x121/0x490 fs/quota/dquot.c:428
       ext4_acquire_dquot+0x1e7/0x2d0 fs/ext4/super.c:5666
       dqget+0x785/0xfc0 fs/quota/dquot.c:896
       __dquot_initialize+0x3bd/0xb70 fs/quota/dquot.c:1470
       ext4_create+0x84/0x5f0 fs/ext4/namei.c:2510
       lookup_open+0x893/0x1a20 fs/namei.c:3235
       do_last fs/namei.c:3327 [inline]
       path_openat+0x1094/0x2df0 fs/namei.c:3537
       do_filp_open+0x18c/0x3f0 fs/namei.c:3567
       do_sys_open+0x3b3/0x520 fs/open.c:1085
       do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
       entry_SYSCALL_64_after_hwframe+0x49/0xbe

-> #1 (&dquot->dq_lock){+.+.}:
       dquot_commit+0x4d/0x400 fs/quota/dquot.c:469
       ext4_write_dquot+0x1e7/0x280 fs/ext4/super.c:5650
       ext4_mark_dquot_dirty+0x111/0x1a0 fs/ext4/super.c:5701
       mark_dquot_dirty fs/quota/dquot.c:341 [inline]
       mark_all_dquot_dirty fs/quota/dquot.c:379 [inline]
       __dquot_alloc_space+0x37e/0x860 fs/quota/dquot.c:1702
       dquot_alloc_space_nodirty include/linux/quotaops.h:298 [inline]
       dquot_alloc_space include/linux/quotaops.h:311 [inline]
       dquot_alloc_block include/linux/quotaops.h:335 [inline]
       ext4_mb_new_blocks+0x58c/0x4370 fs/ext4/mballoc.c:4534
       ext4_ext_map_blocks+0x2aa2/0x7390 fs/ext4/extents.c:4493
       ext4_map_blocks+0x7a2/0x1a50 fs/ext4/inode.c:657
       ext4_getblk+0xad/0x4f0 fs/ext4/inode.c:993
       ext4_bread+0x7c/0x210 fs/ext4/inode.c:1043
       ext4_append+0x155/0x370 fs/ext4/namei.c:66
       ext4_init_new_dir fs/ext4/namei.c:2659 [inline]
       ext4_mkdir+0x5bd/0xe10 fs/ext4/namei.c:2706
       vfs_mkdir+0x508/0x7a0 fs/namei.c:3819
       do_mkdirat+0x262/0x2d0 fs/namei.c:3842
       do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
       entry_SYSCALL_64_after_hwframe+0x49/0xbe

-> #0 (&ei->i_data_sem/2){++++}:
       down_read+0x36/0x80 kernel/locking/rwsem.c:24
       ext4_map_blocks+0x33e/0x1a50 fs/ext4/inode.c:578
       ext4_getblk+0xad/0x4f0 fs/ext4/inode.c:993
       ext4_bread+0x7c/0x210 fs/ext4/inode.c:1043
       ext4_quota_write+0x205/0x530 fs/ext4/super.c:6008
       write_blk+0x10a/0x200 fs/quota/quota_tree.c:72
       get_free_dqblk+0xff/0x2d0 fs/quota/quota_tree.c:101
       do_insert_tree+0x79c/0x1150 fs/quota/quota_tree.c:308
       do_insert_tree+0xf5c/0x1150 fs/quota/quota_tree.c:339
       dq_insert_tree fs/quota/quota_tree.c:365 [inline]
       qtree_write_dquot+0x1cb/0x570 fs/quota/quota_tree.c:384
       v2_write_dquot+0x11c/0x250 fs/quota/quota_v2.c:359
       dquot_acquire+0x25c/0x490 fs/quota/dquot.c:436
       ext4_acquire_dquot+0x1e7/0x2d0 fs/ext4/super.c:5666
       dqget+0x785/0xfc0 fs/quota/dquot.c:896
       __dquot_initialize+0x3bd/0xb70 fs/quota/dquot.c:1470
       ext4_xattr_set+0xbd/0x2a0 fs/ext4/xattr.c:2499
       __vfs_setxattr+0x10e/0x170 fs/xattr.c:149
       __vfs_setxattr_noperm+0x11a/0x420 fs/xattr.c:180
       __vfs_setxattr_locked+0x176/0x250 fs/xattr.c:238
       vfs_setxattr+0xe5/0x270 fs/xattr.c:255
       setxattr+0x23d/0x330 fs/xattr.c:520
       path_setxattr+0x170/0x190 fs/xattr.c:539
       __do_sys_setxattr fs/xattr.c:554 [inline]
       __se_sys_setxattr fs/xattr.c:550 [inline]
       __x64_sys_setxattr+0xc0/0x160 fs/xattr.c:550
       do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
       entry_SYSCALL_64_after_hwframe+0x49/0xbe

other info that might help us debug this:

Chain exists of:
  &ei->i_data_sem/2 --> &dquot->dq_lock --> &s->s_dquot.dqio_sem

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&s->s_dquot.dqio_sem);
                               lock(&dquot->dq_lock);
                               lock(&s->s_dquot.dqio_sem);
  lock(&ei->i_data_sem/2);

 *** DEADLOCK ***

4 locks held by syz-executor.2/14244:
 #0: 000000005114ca4a (sb_writers#3){.+.+}, at: sb_start_write include/linux/fs.h:1579 [inline]
 #0: 000000005114ca4a (sb_writers#3){.+.+}, at: mnt_want_write+0x3a/0xb0 fs/namespace.c:360
 #1: 000000002e87535c (&type->i_mutex_dir_key#3){++++}, at: inode_lock include/linux/fs.h:748 [inline]
 #1: 000000002e87535c (&type->i_mutex_dir_key#3){++++}, at: vfs_setxattr+0xc7/0x270 fs/xattr.c:254
 #2: 000000004a0178dc (&dquot->dq_lock){+.+.}, at: dquot_acquire+0x54/0x490 fs/quota/dquot.c:426
 #3: 000000001db7ce9d (&s->s_dquot.dqio_sem){++++}, at: v2_write_dquot+0x8b/0x250 fs/quota/quota_v2.c:355

stack backtrace:
CPU: 0 PID: 14244 Comm: syz-executor.2 Not tainted 4.19.211-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/16/2023
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x1fc/0x2ef lib/dump_stack.c:118
 print_circular_bug.constprop.0.cold+0x2d7/0x41e kernel/locking/lockdep.c:1222
 check_prev_add kernel/locking/lockdep.c:1866 [inline]
 check_prevs_add kernel/locking/lockdep.c:1979 [inline]
 validate_chain kernel/locking/lockdep.c:2420 [inline]
 __lock_acquire+0x30c9/0x3ff0 kernel/locking/lockdep.c:3416
 lock_acquire+0x170/0x3c0 kernel/locking/lockdep.c:3908
 down_read+0x36/0x80 kernel/locking/rwsem.c:24
 ext4_map_blocks+0x33e/0x1a50 fs/ext4/inode.c:578
 ext4_getblk+0xad/0x4f0 fs/ext4/inode.c:993
 ext4_bread+0x7c/0x210 fs/ext4/inode.c:1043
 ext4_quota_write+0x205/0x530 fs/ext4/super.c:6008
 write_blk+0x10a/0x200 fs/quota/quota_tree.c:72
 get_free_dqblk+0xff/0x2d0 fs/quota/quota_tree.c:101
 do_insert_tree+0x79c/0x1150 fs/quota/quota_tree.c:308
 do_insert_tree+0xf5c/0x1150 fs/quota/quota_tree.c:339
 dq_insert_tree fs/quota/quota_tree.c:365 [inline]
 qtree_write_dquot+0x1cb/0x570 fs/quota/quota_tree.c:384
 v2_write_dquot+0x11c/0x250 fs/quota/quota_v2.c:359
 dquot_acquire+0x25c/0x490 fs/quota/dquot.c:436
 ext4_acquire_dquot+0x1e7/0x2d0 fs/ext4/super.c:5666
 dqget+0x785/0xfc0 fs/quota/dquot.c:896
 __dquot_initialize+0x3bd/0xb70 fs/quota/dquot.c:1470
 ext4_xattr_set+0xbd/0x2a0 fs/ext4/xattr.c:2499
 __vfs_setxattr+0x10e/0x170 fs/xattr.c:149
 __vfs_setxattr_noperm+0x11a/0x420 fs/xattr.c:180
 __vfs_setxattr_locked+0x176/0x250 fs/xattr.c:238
 vfs_setxattr+0xe5/0x270 fs/xattr.c:255
 setxattr+0x23d/0x330 fs/xattr.c:520
 path_setxattr+0x170/0x190 fs/xattr.c:539
 __do_sys_setxattr fs/xattr.c:554 [inline]
 __se_sys_setxattr fs/xattr.c:550 [inline]
 __x64_sys_setxattr+0xc0/0x160 fs/xattr.c:550
 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x7fd49c0e90f9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 00 00 90 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:00007fd49a65b168 EFLAGS: 00000246 ORIG_RAX: 00000000000000bc
RAX: ffffffffffffffda RBX: 00007fd49c208f80 RCX: 00007fd49c0e90f9
RDX: 0000000020000180 RSI: 0000000020000140 RDI: 0000000020000100
RBP: 00007fd49c144ae9 R08: 0000000000000002 R09: 0000000000000000
R10: 0000000000000015 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffc31d054ff R14: 00007fd49a65b300 R15: 0000000000022000
XFS (loop3): DAX enabled. Warning: EXPERIMENTAL, use at your own risk
XFS (loop3): DAX unsupported by block device. Turning off DAX.
XFS (loop3): Mounting V4 Filesystem
overlayfs: unrecognized mount option "upperdkr=./bus" or missing value
XFS (loop3): Ending clean mount
device team_slave_0 entered promiscuous mode
device team_slave_1 entered promiscuous mode
XFS (loop3): Quotacheck needed: Please wait.
EXT4-fs (loop2): mounted filesystem without journal. Opts: ,errors=continue
XFS (loop3): Quotacheck: Done.
device team_slave_0 left promiscuous mode
device team_slave_1 left promiscuous mode
overlayfs: unrecognized mount option "upperdkr=./bus" or missing value
EXT4-fs (loop2): mounted filesystem without journal. Opts: ,errors=continue
XFS (loop3): Unmounting Filesystem
overlayfs: filesystem on './bus' not supported as upperdir
device team_slave_0 entered promiscuous mode
device team_slave_1 entered promiscuous mode
EXT4-fs (loop2): mounted filesystem without journal. Opts: ,errors=continue
device team_slave_0 left promiscuous mode
device team_slave_1 left promiscuous mode
EXT4-fs (loop2): mounted filesystem without journal. Opts: ,errors=continue
EXT4-fs (loop2): Unrecognized mount option "./bus" or missing value
device team_slave_0 entered promiscuous mode
device team_slave_1 entered promiscuous mode
device team_slave_0 left promiscuous mode
device team_slave_1 left promiscuous mode
dccp_close: ABORT with 67 bytes unread
EXT4-fs (loop2): couldn't mount as ext3 due to feature incompatibilities
overlayfs: failed to resolve './file0': -2
XFS (loop3): DAX enabled. Warning: EXPERIMENTAL, use at your own risk
XFS (loop3): DAX unsupported by block device. Turning off DAX.
XFS (loop3): Mounting V4 Filesystem
XFS (loop3): Ending clean mount
XFS (loop3): Quotacheck needed: Please wait.
XFS (loop3): Quotacheck: Done.
XFS (loop3): Unmounting Filesystem
device team_slave_0 entered promiscuous mode
device team_slave_1 entered promiscuous mode
overlayfs: failed to resolve './file0': -2
kauditd_printk_skb: 66 callbacks suppressed
audit: type=1804 audit(1677447405.674:15080): pid=14588 uid=0 auid=4294967295 ses=4294967295 subj==unconfined op=invalid_pcr cause=open_writers comm="syz-executor.1" name="/root/syzkaller-testdir1624465883/syzkaller.QZvZ0Y/1323/bus/bus" dev="overlay" ino=14278 res=1
device team_slave_0 left promiscuous mode
EXT4-fs (loop2): Unrecognized mount option "./file1" or missing value
device team_slave_1 left promiscuous mode
audit: type=1804 audit(1677447405.734:15081): pid=14587 uid=0 auid=4294967295 ses=4294967295 subj==unconfined op=invalid_pcr cause=open_writers comm="syz-executor.1" name="/root/syzkaller-testdir1624465883/syzkaller.QZvZ0Y/1323/bus/bus" dev="overlay" ino=14278 res=1
EXT4-fs (loop2): couldn't mount as ext3 due to feature incompatibilities
overlayfs: failed to resolve './file0': -2
device team_slave_0 entered promiscuous mode
device team_slave_1 entered promiscuous mode
EXT4-fs (loop2): mounted filesystem without journal. Opts: ,errors=continue
audit: type=1804 audit(1677447406.574:15082): pid=14680 uid=0 auid=4294967295 ses=4294967295 subj==unconfined op=invalid_pcr cause=open_writers comm="syz-executor.1" name="/root/syzkaller-testdir1624465883/syzkaller.QZvZ0Y/1324/bus/bus" dev="overlay" ino=128852 res=1
device team_slave_0 left promiscuous mode
device team_slave_1 left promiscuous mode
EXT4-fs (loop2): mounted filesystem without journal. Opts: ,errors=continue
overlayfs: filesystem on './bus' not supported as upperdir
audit: type=1804 audit(1677447407.455:15083): pid=14749 uid=0 auid=4294967295 ses=4294967295 subj==unconfined op=invalid_pcr cause=open_writers comm="syz-executor.1" name="/root/syzkaller-testdir1624465883/syzkaller.QZvZ0Y/1325/bus/bus" dev="sda1" ino=13937 res=1
overlayfs: './bus' not a directory
device team_slave_0 entered promiscuous mode
device team_slave_1 entered promiscuous mode
EXT4-fs (loop2): mounted filesystem without journal. Opts: ,errors=continue
device team_slave_0 left promiscuous mode
device team_slave_1 left promiscuous mode
EXT4-fs (loop2): mounted filesystem without journal. Opts: ,errors=continue
audit: type=1804 audit(1677447408.275:15084): pid=14843 uid=0 auid=4294967295 ses=4294967295 subj==unconfined op=invalid_pcr cause=open_writers comm="syz-executor.1" name="/root/syzkaller-testdir1624465883/syzkaller.QZvZ0Y/1326/bus/bus" dev="overlay" ino=128992 res=1
overlayfs: failed to resolve './file0': -2
device team_slave_0 entered promiscuous mode
device team_slave_1 entered promiscuous mode
EXT4-fs (loop2): mounted filesystem without journal. Opts: ,errors=continue
device team_slave_0 left promiscuous mode
device team_slave_1 left promiscuous mode
EXT4-fs (loop2): mounted filesystem without journal. Opts: ,errors=continue
overlayfs: filesystem on './bus' not supported as upperdir
EXT4-fs (loop2): mounted filesystem without journal. Opts: ,errors=continue
overlayfs: unrecognized mount option "00000000000000000000000" or missing value
audit: type=1804 audit(1677447409.205:15085): pid=14907 uid=0 auid=4294967295 ses=4294967295 subj==unconfined op=invalid_pcr cause=open_writers comm="syz-executor.1" name="/root/syzkaller-testdir1624465883/syzkaller.QZvZ0Y/1327/bus/bus" dev="overlay" ino=131103 res=1
device team_slave_0 entered promiscuous mode
device team_slave_1 entered promiscuous mode
device team_slave_0 left promiscuous mode
device team_slave_1 left promiscuous mode
EXT4-fs (loop2): mounted filesystem without journal. Opts: ,errors=continue
overlayfs: unrecognized mount option "00000000000000000000000" or missing value
overlayfs: failed to resolve './file1': -2
device team_slave_0 entered promiscuous mode
device team_slave_1 entered promiscuous mode
EXT4-fs (loop2): mounted filesystem without journal. Opts: ,errors=continue
overlayfs: failed to resolve './file1': -2
device team_slave_0 left promiscuous mode
device team_slave_1 left promiscuous mode
audit: type=1804 audit(1677447410.135:15086): pid=15004 uid=0 auid=4294967295 ses=4294967295 subj==unconfined op=invalid_pcr cause=open_writers comm="syz-executor.1" name="/root/syzkaller-testdir1624465883/syzkaller.QZvZ0Y/1329/bus/bus" dev="sda1" ino=14004 res=1
overlayfs: unrecognized mount option "00000000000000000000000" or missing value
EXT4-fs (loop2): mounted filesystem without journal. Opts: ,errors=continue
device team_slave_0 entered promiscuous mode
device team_slave_1 entered promiscuous mode
device team_slave_0 left promiscuous mode
device team_slave_1 left promiscuous mode
device team_slave_0 entered promiscuous mode
device team_slave_1 entered promiscuous mode
EXT4-fs (loop2): mounted filesystem without journal. Opts: ,errors=continue
audit: type=1804 audit(1677447411.035:15087): pid=15110 uid=0 auid=4294967295 ses=4294967295 subj==unconfined op=invalid_pcr cause=open_writers comm="syz-executor.1" name="/root/syzkaller-testdir1624465883/syzkaller.QZvZ0Y/1330/bus/bus" dev="overlay" ino=130337 res=1
device team_slave_0 left promiscuous mode
device team_slave_1 left promiscuous mode
EXT4-fs (loop2): Unrecognized mount option "./bus" or missing value
device team_slave_0 entered promiscuous mode
device team_slave_1 entered promiscuous mode
device team_slave_0 left promiscuous mode
device team_slave_1 left promiscuous mode
EXT4-fs (loop2): mounted filesystem without journal. Opts: ,errors=continue
audit: type=1804 audit(1677447411.955:15088): pid=15209 uid=0 auid=4294967295 ses=4294967295 subj==unconfined op=invalid_pcr cause=open_writers comm="syz-executor.1" name="/root/syzkaller-testdir1624465883/syzkaller.QZvZ0Y/1332/bus/bus" dev="overlay" ino=130458 res=1
EXT4-fs (loop2): mounted filesystem without journal. Opts: ,errors=continue
device team_slave_0 entered promiscuous mode
device team_slave_1 entered promiscuous mode
device team_slave_0 left promiscuous mode
device team_slave_1 left promiscuous mode

Crashes (11):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/02/26 21:36 linux-4.19.y 3f8a27f9e27b ee50e71c .config console log report info [disk image] [vmlinux] ci2-linux-4-19 possible deadlock in ext4_map_blocks
2023/02/25 14:05 linux-4.19.y 3f8a27f9e27b ee50e71c .config console log report info [disk image] [vmlinux] ci2-linux-4-19 possible deadlock in ext4_map_blocks
2023/02/21 21:01 linux-4.19.y 3f8a27f9e27b 42a4d508 .config console log report info [disk image] [vmlinux] ci2-linux-4-19 possible deadlock in ext4_map_blocks
2023/02/16 08:49 linux-4.19.y 3f8a27f9e27b 6be0f1f5 .config console log report info [disk image] [vmlinux] ci2-linux-4-19 possible deadlock in ext4_map_blocks
2023/01/24 09:26 linux-4.19.y 3f8a27f9e27b 9dfcf09c .config console log report info [disk image] [vmlinux] ci2-linux-4-19 possible deadlock in ext4_map_blocks
2023/01/13 13:37 linux-4.19.y 3f8a27f9e27b 96166539 .config console log report info [disk image] [vmlinux] ci2-linux-4-19 possible deadlock in ext4_map_blocks
2022/12/30 07:35 linux-4.19.y 3f8a27f9e27b 44712fbc .config console log report info [disk image] [vmlinux] ci2-linux-4-19 possible deadlock in ext4_map_blocks
2022/12/16 15:31 linux-4.19.y 3f8a27f9e27b 05494336 .config console log report info [disk image] [vmlinux] ci2-linux-4-19 possible deadlock in ext4_map_blocks
2022/12/10 06:33 linux-4.19.y 3f8a27f9e27b 67be1ae7 .config console log report info [disk image] [vmlinux] ci2-linux-4-19 possible deadlock in ext4_map_blocks
2022/11/29 01:03 linux-4.19.y 3f8a27f9e27b ca9683b8 .config console log report info [disk image] [vmlinux] ci2-linux-4-19 possible deadlock in ext4_map_blocks
2022/10/12 20:36 linux-4.19.y 3f8a27f9e27b 16a9c9e0 .config console log report info [disk image] [vmlinux] ci2-linux-4-19 possible deadlock in ext4_map_blocks
* Struck through repros no longer work on HEAD.