syzbot


possible deadlock in ext4_xattr_set_handle

Status: fixed on 2023/07/17 13:09
Reported-by: syzbot+dafdb578b33989ec0674@syzkaller.appspotmail.com
Fix commit: b112babc565e ext4: add EA_INODE checking to ext4_iget()
First crash: 350d, last: 262d
Fix bisection: fixed by (bisect log) :
commit b112babc565ea92d54045fe70bd931b546c5dc4e
Author: Theodore Ts'o <tytso@mit.edu>
Date: Wed May 24 03:49:48 2023 +0000

  ext4: add EA_INODE checking to ext4_iget()

  
Bug presence (1)
Date Name Commit Repro Result
2023/07/14 upstream (ToT) 4b810bf037e5 C Didn't crash
Similar bugs (6)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in ext4_xattr_set_handle (3) ext4 C 451 239d 396d 22/26 fixed on 2023/07/01 16:05
upstream possible deadlock in ext4_xattr_set_handle (4) ext4 5 35d 156d 0/26 upstream: reported on 2023/09/22 04:51
upstream possible deadlock in ext4_xattr_set_handle ext4 1 859d 855d 0/26 auto-closed as invalid on 2022/02/15 19:59
upstream possible deadlock in ext4_xattr_set_handle (2) ext4 1 593d 593d 0/26 auto-obsoleted due to no activity on 2022/11/08 16:24
linux-5.15 possible deadlock in ext4_xattr_set_handle C done 42 262d 354d 3/3 fixed on 2023/07/17 13:09
linux-4.19 possible deadlock in ext4_xattr_set_handle ext4 1 386d 386d 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.
ext4 filesystem being mounted at /root/file0 supports timestamps until 2038 (0x7fffffff)
======================================================
WARNING: possible circular locking dependency detected
6.1.31-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor266/3542 is trying to acquire lock:
ffff888074415b10 (&ei->xattr_sem){++++}-{3:3}, at: ext4_write_lock_xattr fs/ext4/xattr.h:155 [inline]
ffff888074415b10 (&ei->xattr_sem){++++}-{3:3}, at: ext4_xattr_set_handle+0x270/0x1560 fs/ext4/xattr.c:2322

but task is already holding lock:
ffff888074415e48 (&ea_inode->i_rwsem#8/1){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:756 [inline]
ffff888074415e48 (&ea_inode->i_rwsem#8/1){+.+.}-{3:3}, at: vfs_setxattr+0x1dd/0x420 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#8/1){+.+.}-{3:3}:
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5669
       down_write+0x36/0x60 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+0x33c5/0x3c00 fs/ext4/xattr.c:1686
       ext4_xattr_block_set+0xb0e/0x3680 fs/ext4/xattr.c:1992
       ext4_xattr_set_handle+0xdac/0x1560 fs/ext4/xattr.c:2407
       ext4_xattr_set+0x231/0x3d0 fs/ext4/xattr.c:2509
       __vfs_setxattr+0x3e7/0x420 fs/xattr.c:182
       __vfs_setxattr_noperm+0x12a/0x5e0 fs/xattr.c:216
       vfs_setxattr+0x21d/0x420 fs/xattr.c:309
       do_setxattr fs/xattr.c:594 [inline]
       setxattr+0x250/0x2b0 fs/xattr.c:617
       path_setxattr+0x1bc/0x2a0 fs/xattr.c:636
       __do_sys_setxattr fs/xattr.c:652 [inline]
       __se_sys_setxattr fs/xattr.c:648 [inline]
       __x64_sys_setxattr+0xb7/0xd0 fs/xattr.c:648
       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 (&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+0x1667/0x58e0 kernel/locking/lockdep.c:3832
       __lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5056
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5669
       down_write+0x36/0x60 kernel/locking/rwsem.c:1573
       ext4_write_lock_xattr fs/ext4/xattr.h:155 [inline]
       ext4_xattr_set_handle+0x270/0x1560 fs/ext4/xattr.c:2322
       ext4_xattr_set+0x231/0x3d0 fs/ext4/xattr.c:2509
       __vfs_setxattr+0x3e7/0x420 fs/xattr.c:182
       __vfs_setxattr_noperm+0x12a/0x5e0 fs/xattr.c:216
       vfs_setxattr+0x21d/0x420 fs/xattr.c:309
       do_setxattr fs/xattr.c:594 [inline]
       setxattr+0x250/0x2b0 fs/xattr.c:617
       path_setxattr+0x1bc/0x2a0 fs/xattr.c:636
       __do_sys_setxattr fs/xattr.c:652 [inline]
       __se_sys_setxattr fs/xattr.c:648 [inline]
       __x64_sys_setxattr+0xb7/0xd0 fs/xattr.c:648
       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:

 Possible unsafe locking scenario:

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

 *** DEADLOCK ***

2 locks held by syz-executor266/3542:
 #0: ffff88807c3e0460 (sb_writers#4){.+.+}-{0:0}, at: mnt_want_write+0x3b/0x80 fs/namespace.c:393
 #1: ffff888074415e48 (&ea_inode->i_rwsem#8/1){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:756 [inline]
 #1: ffff888074415e48 (&ea_inode->i_rwsem#8/1){+.+.}-{3:3}, at: vfs_setxattr+0x1dd/0x420 fs/xattr.c:308

stack backtrace:
CPU: 0 PID: 3542 Comm: syz-executor266 Not tainted 6.1.31-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/25/2023
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 check_noncircular+0x2fa/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+0x1667/0x58e0 kernel/locking/lockdep.c:3832
 __lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5056
 lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5669
 down_write+0x36/0x60 kernel/locking/rwsem.c:1573
 ext4_write_lock_xattr fs/ext4/xattr.h:155 [inline]
 ext4_xattr_set_handle+0x270/0x1560 fs/ext4/xattr.c:2322
 ext4_xattr_set+0x231/0x3d0 fs/ext4/xattr.c:2509
 __vfs_setxattr+0x3e7/0x420 fs/xattr.c:182
 __vfs_setxattr_noperm+0x12a/0x5e0 fs/xattr.c:216
 vfs_setxattr+0x21d/0x420 fs/xattr.c:309
 do_setxattr fs/xattr.c:594 [inline]
 setxattr+0x250/0x2b0 fs/xattr.c:617
 path_setxattr+0x1bc/0x2a0 fs/xattr.c:636
 __do_sys_setxattr fs/xattr.c:652 [inline]
 __se_sys_setxattr fs/xattr.c:648 [inline]
 __x64_sys_setxattr+0xb7/0xd0 fs/xattr.c:648
 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:0x7f5cba5788a9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 51 14 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 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffea881dbc8 EFLAGS: 00000246 ORIG_RAX: 00000000000000bc
RAX: ffffffffffffffda RBX: 0030656c69662f2e RCX: 00007f5cba5788a9
RDX: 0000000000000000 RSI: 0000000020000140 RDI: 0000000020000000
RBP: 00007f5cba538140 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f5cba5381d0
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000

Crashes (15):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/06/04 19:15 linux-6.1.y d2869ace6eeb a4ae4f42 .config console log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-linux-6-1-kasan possible deadlock in ext4_xattr_set_handle
2023/06/02 21:14 linux-6.1.y d2869ace6eeb a4ae4f42 .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/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/06/01 16:17 linux-6.1.y d2869ace6eeb babc4389 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in ext4_xattr_set_handle
2023/06/01 16:17 linux-6.1.y d2869ace6eeb babc4389 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan 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/06/08 00:19 linux-6.1.y 76ba310227d2 058b3a5a .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in ext4_xattr_set_handle
2023/06/07 22:26 linux-6.1.y 76ba310227d2 058b3a5a .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in ext4_xattr_set_handle
2023/06/05 15:36 linux-6.1.y 76ba310227d2 a4ae4f42 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in ext4_xattr_set_handle
2023/06/05 09:18 linux-6.1.y 76ba310227d2 a4ae4f42 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in ext4_xattr_set_handle
2023/06/02 01:37 linux-6.1.y d2869ace6eeb a4ae4f42 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in ext4_xattr_set_handle
2023/06/02 00:43 linux-6.1.y d2869ace6eeb a4ae4f42 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in ext4_xattr_set_handle
2023/06/01 13:04 linux-6.1.y d2869ace6eeb babc4389 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 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.