syzbot


possible deadlock in ext4_xattr_set_handle

Status: upstream: reported C repro on 2023/03/12 03:51
Labels: origin:upstream (incorrect?)
Reported-by: syzbot+dafdb578b33989ec0674@syzkaller.appspotmail.com
First crash: 77d, last: 6d08h
Bug presence (1)
Date Name Commit Repro Result
2023/05/08 upstream (ToT) ac9a78681b92 C [report] possible deadlock in ext4_xattr_set_handle
Similar bugs (5)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in ext4_xattr_set_handle (3) ext4 C 392 1d16h 123d 0/24 upstream: reported C repro on 2023/01/25 00:27
upstream possible deadlock in ext4_xattr_set_handle 1 586d 582d 0/24 auto-closed as invalid on 2022/02/15 19:59
upstream possible deadlock in ext4_xattr_set_handle (2) 1 320d 320d 0/24 auto-obsoleted due to no activity on 2022/11/08 16:24
linux-5.15 possible deadlock in ext4_xattr_set_handle origin:upstream C 32 18d 81d 0/3 upstream: reported C repro on 2023/03/07 17:51
linux-4.19 possible deadlock in ext4_xattr_set_handle ext4 1 113d 113d 0/1 upstream: reported on 2023/02/03 16:43

Sample crash report:
loop0: detected capacity change from 0 to 512
EXT4-fs (loop0): mounted filesystem without journal. Quota mode: writeback.
======================================================
WARNING: possible circular locking dependency detected
6.1.27-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor166/4218 is trying to acquire lock:
ffff0000e24a00c8 (&ei->xattr_sem){++++}-{3:3}, at: ext4_write_lock_xattr fs/ext4/xattr.h:155 [inline]
ffff0000e24a00c8 (&ei->xattr_sem){++++}-{3:3}, at: ext4_xattr_set_handle+0x1e0/0x1294 fs/ext4/xattr.c:2322

but task is already holding lock:
ffff0000e24a0400 (&ea_inode->i_rwsem#9/1){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:756 [inline]
ffff0000e24a0400 (&ea_inode->i_rwsem#9/1){+.+.}-{3:3}, at: vfs_setxattr+0x17c/0x344 fs/xattr.c:308

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&ea_inode->i_rwsem#9/1){+.+.}-{3:3}:
       down_write+0x5c/0x88 kernel/locking/rwsem.c:1573
       inode_lock include/linux/fs.h:756 [inline]
       ext4_xattr_inode_create fs/ext4/xattr.c:1475 [inline]
       ext4_xattr_inode_lookup_create fs/ext4/xattr.c:1558 [inline]
       ext4_xattr_set_entry+0x2394/0x2bfc fs/ext4/xattr.c:1686
       ext4_xattr_block_set+0x8e0/0x2cc4 fs/ext4/xattr.c:1992
       ext4_xattr_set_handle+0xae8/0x1294 fs/ext4/xattr.c:2407
       ext4_xattr_set+0x1dc/0x350 fs/ext4/xattr.c:2509
       ext4_xattr_trusted_set+0x4c/0x64 fs/ext4/xattr_trusted.c:38
       __vfs_setxattr+0x388/0x3a4 fs/xattr.c:182
       __vfs_setxattr_noperm+0x110/0x528 fs/xattr.c:216
       __vfs_setxattr_locked+0x1ec/0x218 fs/xattr.c:277
       vfs_setxattr+0x1a8/0x344 fs/xattr.c:309
       do_setxattr fs/xattr.c:594 [inline]
       setxattr+0x230/0x294 fs/xattr.c:617
       path_setxattr+0x17c/0x258 fs/xattr.c:636
       __do_sys_setxattr fs/xattr.c:652 [inline]
       __se_sys_setxattr fs/xattr.c:648 [inline]
       __arm64_sys_setxattr+0xbc/0xd8 fs/xattr.c:648
       __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
       invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
       el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
       do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206
       el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
       el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
       el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581

-> #0 (&ei->xattr_sem){++++}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3098 [inline]
       check_prevs_add kernel/locking/lockdep.c:3217 [inline]
       validate_chain kernel/locking/lockdep.c:3832 [inline]
       __lock_acquire+0x3338/0x764c kernel/locking/lockdep.c:5056
       lock_acquire+0x26c/0x7cc kernel/locking/lockdep.c:5669
       down_write+0x5c/0x88 kernel/locking/rwsem.c:1573
       ext4_write_lock_xattr fs/ext4/xattr.h:155 [inline]
       ext4_xattr_set_handle+0x1e0/0x1294 fs/ext4/xattr.c:2322
       ext4_xattr_set+0x1dc/0x350 fs/ext4/xattr.c:2509
       ext4_xattr_trusted_set+0x4c/0x64 fs/ext4/xattr_trusted.c:38
       __vfs_setxattr+0x388/0x3a4 fs/xattr.c:182
       __vfs_setxattr_noperm+0x110/0x528 fs/xattr.c:216
       __vfs_setxattr_locked+0x1ec/0x218 fs/xattr.c:277
       vfs_setxattr+0x1a8/0x344 fs/xattr.c:309
       do_setxattr fs/xattr.c:594 [inline]
       setxattr+0x230/0x294 fs/xattr.c:617
       path_setxattr+0x17c/0x258 fs/xattr.c:636
       __do_sys_setxattr fs/xattr.c:652 [inline]
       __se_sys_setxattr fs/xattr.c:648 [inline]
       __arm64_sys_setxattr+0xbc/0xd8 fs/xattr.c:648
       __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
       invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
       el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
       do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206
       el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
       el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
       el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581

other info that might help us debug this:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&ea_inode->i_rwsem#9/1);
                               lock(&ei->xattr_sem);
                               lock(&ea_inode->i_rwsem#9/1);
  lock(&ei->xattr_sem);

 *** DEADLOCK ***

2 locks held by syz-executor166/4218:
 #0: ffff0000d7d42460 (sb_writers#3){.+.+}-{0:0}, at: mnt_want_write+0x44/0x9c fs/namespace.c:393
 #1: ffff0000e24a0400 (&ea_inode->i_rwsem#9/1){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:756 [inline]
 #1: ffff0000e24a0400 (&ea_inode->i_rwsem#9/1){+.+.}-{3:3}, at: vfs_setxattr+0x17c/0x344 fs/xattr.c:308

stack backtrace:
CPU: 0 PID: 4218 Comm: syz-executor166 Not tainted 6.1.27-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/14/2023
Call trace:
 dump_backtrace+0x1c8/0x1f4 arch/arm64/kernel/stacktrace.c:158
 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:165
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x108/0x170 lib/dump_stack.c:106
 dump_stack+0x1c/0x5c lib/dump_stack.c:113
 print_circular_bug+0x150/0x1b8 kernel/locking/lockdep.c:2056
 check_noncircular+0x2cc/0x378 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 kernel/locking/lockdep.c:3832 [inline]
 __lock_acquire+0x3338/0x764c kernel/locking/lockdep.c:5056
 lock_acquire+0x26c/0x7cc kernel/locking/lockdep.c:5669
 down_write+0x5c/0x88 kernel/locking/rwsem.c:1573
 ext4_write_lock_xattr fs/ext4/xattr.h:155 [inline]
 ext4_xattr_set_handle+0x1e0/0x1294 fs/ext4/xattr.c:2322
 ext4_xattr_set+0x1dc/0x350 fs/ext4/xattr.c:2509
 ext4_xattr_trusted_set+0x4c/0x64 fs/ext4/xattr_trusted.c:38
 __vfs_setxattr+0x388/0x3a4 fs/xattr.c:182
 __vfs_setxattr_noperm+0x110/0x528 fs/xattr.c:216
 __vfs_setxattr_locked+0x1ec/0x218 fs/xattr.c:277
 vfs_setxattr+0x1a8/0x344 fs/xattr.c:309
 do_setxattr fs/xattr.c:594 [inline]
 setxattr+0x230/0x294 fs/xattr.c:617
 path_setxattr+0x17c/0x258 fs/xattr.c:636
 __do_sys_setxattr fs/xattr.c:652 [inline]
 __se_sys_setxattr fs/xattr.c:648 [inline]
 __arm64_sys_setxattr+0xbc/0xd8 fs/xattr.c:648
 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
 invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
 do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206
 el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
 el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581

Crashes (4):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets Manager Title
2023/05/07 06:03 linux-6.1.y ca48fc16c493 90c93c40 .config console log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-linux-6-1-kasan-arm64 possible deadlock in ext4_xattr_set_handle
2023/03/18 11:52 linux-6.1.y 7eaef76fbc46 7939252e .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in ext4_xattr_set_handle
2023/05/22 03:34 linux-6.1.y fa74641fb6b9 4bce1a3e .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in ext4_xattr_set_handle
2023/03/12 03:51 linux-6.1.y 1cc3fcf63192 5205ef30 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in ext4_xattr_set_handle
* Struck through repros no longer work on HEAD.