syzbot


possible deadlock in ext4_xattr_get

Status: upstream: reported C repro on 2022/04/27 05:09
Reported-by: syzbot+b2cdc53d61809157fbcb@syzkaller.appspotmail.com
First crash: 939d, last: 939d
Fix bisection: failed (error log, bisect log)
  
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.14 possible deadlock in ext4_xattr_get C inconclusive 1 939d 939d 0/1 upstream: reported C repro on 2022/04/27 03:33
upstream possible deadlock in ext4_xattr_get ext4 C inconclusive 3 564d 836d 22/28 fixed on 2023/07/01 16:05

Sample crash report:
EXT4-fs (loop0): mounted filesystem without journal. Opts: ,errors=continue
======================================================
WARNING: possible circular locking dependency detected
4.19.211-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor363/8086 is trying to acquire lock:
00000000bec9b65b (&ei->xattr_sem){++++}, at: ext4_xattr_get+0x141/0x9c0 fs/ext4/xattr.c:648

but task is already holding lock:
00000000bfbe5d25 (&ea_inode->i_rwsem#10/1){+.+.}, at: inode_lock include/linux/fs.h:748 [inline]
00000000bfbe5d25 (&ea_inode->i_rwsem#10/1){+.+.}, at: chown_common+0x2d0/0x550 fs/open.c:648

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&ea_inode->i_rwsem#10/1){+.+.}:
       inode_lock include/linux/fs.h:748 [inline]
       ext4_xattr_inode_create fs/ext4/xattr.c:1459 [inline]
       ext4_xattr_inode_lookup_create fs/ext4/xattr.c:1542 [inline]
       ext4_xattr_set_entry+0x2a10/0x3750 fs/ext4/xattr.c:1670
       ext4_xattr_ibody_set+0x81/0x2a0 fs/ext4/xattr.c:2246
       ext4_xattr_set_handle+0x60b/0x1030 fs/ext4/xattr.c:2403
       ext4_xattr_set+0x135/0x2a0 fs/ext4/xattr.c:2515
       __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

-> #0 (&ei->xattr_sem){++++}:
       down_read+0x36/0x80 kernel/locking/rwsem.c:24
       ext4_xattr_get+0x141/0x9c0 fs/ext4/xattr.c:648
       __vfs_getxattr+0xd9/0x140 fs/xattr.c:347
       cap_inode_need_killpriv+0x3c/0x60 security/commoncap.c:306
       security_inode_need_killpriv+0x40/0x90 security/security.c:797
       notify_change+0xa15/0xfc0 fs/attr.c:271
       chown_common+0x4a9/0x550 fs/open.c:651
       do_fchownat+0x126/0x1e0 fs/open.c:681
       __do_sys_fchownat fs/open.c:696 [inline]
       __se_sys_fchownat fs/open.c:693 [inline]
       __x64_sys_fchownat+0xba/0x150 fs/open.c:693
       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:

 Possible unsafe locking scenario:

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

 *** DEADLOCK ***

2 locks held by syz-executor363/8086:
 #0: 000000005b443f8c (sb_writers#3){.+.+}, at: sb_start_write include/linux/fs.h:1579 [inline]
 #0: 000000005b443f8c (sb_writers#3){.+.+}, at: mnt_want_write+0x3a/0xb0 fs/namespace.c:360
 #1: 00000000bfbe5d25 (&ea_inode->i_rwsem#10/1){+.+.}, at: inode_lock include/linux/fs.h:748 [inline]
 #1: 00000000bfbe5d25 (&ea_inode->i_rwsem#10/1){+.+.}, at: chown_common+0x2d0/0x550 fs/open.c:648

stack backtrace:
CPU: 0 PID: 8086 Comm: syz-executor363 Not tainted 4.19.211-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
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_xattr_get+0x141/0x9c0 fs/ext4/xattr.c:648
 __vfs_getxattr+0xd9/0x140 fs/xattr.c:347
 cap_inode_need_killpriv+0x3c/0x60 security/commoncap.c:306
 security_inode_need_killpriv+0x40/0x90 security/security.c:797
 notify_change+0xa15/0xfc0 fs/attr.c:271
 chown_common+0x4a9/0x550 fs/open.c:651
 do_fchownat+0x126/0x1e0 fs/open.c:681
 __do_sys_fchownat fs/open.c:696 [inline]
 __se_sys_fchownat fs/open.c:693 [inline]
 __x64_sys_fchownat+0xba/0x150 fs/open.c:693
 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x7f2ddf6f4109
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 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fffe9617d98 EFLAGS: 00000246 ORIG_RAX: 0000000000000104
RAX: ffffffffffffffda RBX: 2f30656c69662f2e RCX: 00007f2ddf6f4109
RDX: 0000000000000000 RSI: 00000000200000c0 RDI: 0000000000000005
RBP: 00007f2ddf6b39a0 R08: 0000000000001000 R09: 0000000000000000
R10: 000000000000ee01 R11: 0000000000000246 R12: 00007f2ddf6b3a30
R13: 0000000000000000 R14: 0000000000000000 R15:

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2022/04/27 05:09 linux-4.19.y 3f8a27f9e27b 1fa34c1b .config console log report syz C ci2-linux-4-19 possible deadlock in ext4_xattr_get
* Struck through repros no longer work on HEAD.