syzbot


possible deadlock in ext4_xattr_get

Status: fixed on 2023/07/01 16:05
Subsystems: ext4
[Documentation on labels]
Reported-by: syzbot+62120febbd1ee3c3c860@syzkaller.appspotmail.com
Fix commit: b3e6bcb94590 ext4: add EA_INODE checking to ext4_iget()
First crash: 840d, last: 563d
Cause bisection: the issue happens on the oldest tested release (bisect log)
Crash: possible deadlock in ext4_xattr_get (log)
Repro: C syz .config
  
Discussions (3)
Title Replies (including bot) Last reply
[PATCH 0/4] ext4: clean up ea_inode handling 5 (5) 2023/05/24 03:49
Re: [syzbot] possible deadlock in ext4_xattr_get 1 (1) 2022/08/09 01:48
[syzbot] possible deadlock in ext4_xattr_get 0 (1) 2022/08/07 13:08
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
linux-4.19 possible deadlock in ext4_xattr_get C error 1 939d 939d 0/1 upstream: reported C repro on 2022/04/27 05:09
Last patch testing requests (5)
Created Duration User Patch Repo Result
2023/05/22 19:10 16m tytso@mit.edu git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git test OK log
2022/12/22 07:31 12m retest repro upstream report log
2022/08/08 13:32 15m hdanton@sina.com patch https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git cb71b93c2dc3 OK log
2022/08/08 12:10 9m hdanton@sina.com patch https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git cb71b93c2dc3 report log
2022/08/08 11:14 10m hdanton@sina.com patch https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git cb71b93c2dc3 report log
Fix bisection attempts (5)
Created Duration User Patch Repo Result
2023/05/04 12:02 21m (2) bisect fix upstream OK (0) job log log
2023/04/03 11:13 21m bisect fix upstream OK (0) job log log
2023/03/04 09:00 21m bisect fix upstream OK (0) job log log
2023/02/02 07:23 23m bisect fix upstream OK (0) job log log
2022/10/13 06:52 22m (2) bisect fix upstream OK (0) job log log

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.0.0-rc5-syzkaller-00007-g6504d82f4440 #0 Not tainted
------------------------------------------------------
syz-executor384/3606 is trying to acquire lock:
ffff88806d467208 (&ei->xattr_sem){++++}-{3:3}, at: ext4_xattr_get+0x14e/0x740 fs/ext4/xattr.c:665

but task is already holding lock:
ffff88806d467540 (&ea_inode->i_rwsem#7/1){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:756 [inline]
ffff88806d467540 (&ea_inode->i_rwsem#7/1){+.+.}-{3:3}, at: chown_common+0x364/0x710 fs/open.c:727

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&ea_inode->i_rwsem#7/1){+.+.}-{3:3}:
       down_write+0x90/0x150 kernel/locking/rwsem.c:1552
       inode_lock include/linux/fs.h:756 [inline]
       ext4_xattr_inode_create fs/ext4/xattr.c:1454 [inline]
       ext4_xattr_inode_lookup_create fs/ext4/xattr.c:1537 [inline]
       ext4_xattr_set_entry+0x2b38/0x3980 fs/ext4/xattr.c:1665
       ext4_xattr_ibody_set+0x12d/0x3a0 fs/ext4/xattr.c:2225
       ext4_xattr_set_handle+0x964/0x1500 fs/ext4/xattr.c:2382
       ext4_xattr_set+0x13a/0x340 fs/ext4/xattr.c:2495
       __vfs_setxattr+0x115/0x180 fs/xattr.c:182
       __vfs_setxattr_noperm+0x125/0x5f0 fs/xattr.c:216
       __vfs_setxattr_locked+0x1cf/0x260 fs/xattr.c:277
       vfs_setxattr+0x11e/0x3c0 fs/xattr.c:313
       setxattr+0x146/0x160 fs/xattr.c:623
       path_setxattr+0x197/0x1c0 fs/xattr.c:642
       __do_sys_setxattr fs/xattr.c:658 [inline]
       __se_sys_setxattr fs/xattr.c:654 [inline]
       __x64_sys_setxattr+0xc0/0x160 fs/xattr.c:654
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x35/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:3095 [inline]
       check_prevs_add kernel/locking/lockdep.c:3214 [inline]
       validate_chain kernel/locking/lockdep.c:3829 [inline]
       __lock_acquire+0x2a43/0x56d0 kernel/locking/lockdep.c:5053
       lock_acquire kernel/locking/lockdep.c:5666 [inline]
       lock_acquire+0x1ab/0x570 kernel/locking/lockdep.c:5631
       down_read+0x98/0x450 kernel/locking/rwsem.c:1499
       ext4_xattr_get+0x14e/0x740 fs/ext4/xattr.c:665
       __vfs_getxattr+0xd9/0x140 fs/xattr.c:411
       cap_inode_need_killpriv+0x3c/0x60 security/commoncap.c:301
       security_inode_need_killpriv+0x40/0x90 security/security.c:1420
       notify_change+0x6e7/0x1440 fs/attr.c:353
       chown_common+0x61b/0x710 fs/open.c:734
       do_fchownat+0x126/0x1e0 fs/open.c:765
       __do_sys_fchownat fs/open.c:780 [inline]
       __se_sys_fchownat fs/open.c:777 [inline]
       __x64_sys_fchownat+0xba/0x150 fs/open.c:777
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x35/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#7/1);
                               lock(&ei->xattr_sem);
                               lock(&ea_inode->i_rwsem#7/1);
  lock(&ei->xattr_sem);

 *** DEADLOCK ***

2 locks held by syz-executor384/3606:
 #0: ffff888028a20460 (sb_writers#5){.+.+}-{0:0}, at: do_fchownat+0x101/0x1e0 fs/open.c:762
 #1: ffff88806d467540 (&ea_inode->i_rwsem#7/1){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:756 [inline]
 #1: ffff88806d467540 (&ea_inode->i_rwsem#7/1){+.+.}-{3:3}, at: chown_common+0x364/0x710 fs/open.c:727

stack backtrace:
CPU: 1 PID: 3606 Comm: syz-executor384 Not tainted 6.0.0-rc5-syzkaller-00007-g6504d82f4440 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/26/2022
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 check_noncircular+0x25f/0x2e0 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+0x2a43/0x56d0 kernel/locking/lockdep.c:5053
 lock_acquire kernel/locking/lockdep.c:5666 [inline]
 lock_acquire+0x1ab/0x570 kernel/locking/lockdep.c:5631
 down_read+0x98/0x450 kernel/locking/rwsem.c:1499
 ext4_xattr_get+0x14e/0x740 fs/ext4/xattr.c:665
 __vfs_getxattr+0xd9/0x140 fs/xattr.c:411
 cap_inode_need_killpriv+0x3c/0x60 security/commoncap.c:301
 security_inode_need_killpriv+0x40/0x90 security/security.c:1420
 notify_change+0x6e7/0x1440 fs/attr.c:353
 chown_common+0x61b/0x710 fs/open.c:734
 do_fchownat+0x126/0x1e0 fs/open.c:765
 __do_sys_fchownat fs/open.c:780 [inline]
 __se_sys_fchownat fs/open.c:777 [inline]
 __x64_sys_fchownat+0xba/0x150 fs/open.c:777
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f2c842f20e9
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:00007ffd30187fd8 EFLAGS: 00000246 ORIG_RAX: 0000000000000104
RAX: ffffffffffffffda RBX: 2f30656c69662f2e RCX: 00007f2c842f20e9
RDX: 0000000000000000 RSI: 00000000200000c0 RDI: 0000000000000005

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2022/09/13 06:51 upstream 6504d82f4440 f371ed7e .config strace log report syz C ci-upstream-kasan-gce-selinux-root possible deadlock in ext4_xattr_get
2022/08/14 18:48 upstream 7ebfc85e2cd7 8dfcaa3d .config strace log report syz C ci-upstream-kasan-gce-smack-root possible deadlock in ext4_xattr_get
2022/08/03 13:00 linux-next cb71b93c2dc3 1c9013ac .config strace log report syz C ci-upstream-linux-next-kasan-gce-root possible deadlock in ext4_xattr_get
* Struck through repros no longer work on HEAD.