syzbot


WARNING: locking bug in ext4_xattr_inode_iget

Status: upstream: reported C repro on 2023/05/06 10:34
Bug presence: origin:upstream
Labels: missing-backport
[Documentation on labels]
Reported-by: syzbot+4b8823967328f40d1f25@syzkaller.appspotmail.com
First crash: 565d, last: 330d
Fix bisection: the issue occurs on the latest tested release (bisect log)
Crash: INFO: rcu detected stall in corrupted (log)
Repro: syz .config
  
Bug presence (3)
Date Name Commit Repro Result
2024/01/10 linux-6.1.y (ToT) 7c58bfa711cb C [report] WARNING: locking bug in ext4_xattr_inode_update_ref
2023/07/12 upstream (ToT) 3f01e9fed845 C [report] WARNING: locking bug in ext4_xattr_inode_update_ref
2024/01/10 upstream (ToT) 0cb552aa9784 C Didn't crash
Similar bugs (3)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream WARNING: locking bug in ext4_xattr_inode_iget (2) ext4 C 1 239d 235d 0/28 auto-obsoleted due to no activity on 2024/07/05 14:01
upstream WARNING: locking bug in ext4_xattr_inode_iget ext4 C error 23 531d 562d 22/28 fixed on 2023/07/01 16:05
linux-5.15 WARNING: locking bug in ext4_xattr_inode_iget C error 4 534d 563d 0/3 auto-obsoleted due to no activity on 2023/09/14 16:49
Fix bisection attempts (6)
Created Duration User Patch Repo Result
2024/01/23 09:09 2h20m fix candidate upstream OK (0) job log
2023/12/27 09:43 2h34m bisect fix linux-6.1.y OK (0) job log log
2023/11/26 18:56 2h29m bisect fix linux-6.1.y OK (0) job log log
2023/10/26 18:41 2h18m bisect fix linux-6.1.y OK (0) job log log
2023/09/22 15:36 2h12m bisect fix linux-6.1.y OK (0) job log log
2023/07/13 07:42 4h55m bisect fix linux-6.1.y OK (0) job log log

Sample crash report:
------------[ cut here ]------------
Looking for class "&ea_inode->i_rwsem" with key ext4_fs_type, but found a different class "&sb->s_type->i_mutex_key" with the same key
WARNING: CPU: 0 PID: 22745 at kernel/locking/lockdep.c:941 look_up_lock_class+0xec/0x158 kernel/locking/lockdep.c:938
Modules linked in:
CPU: 0 PID: 22745 Comm: syz-executor.2 Not tainted 6.1.27-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/14/2023
pstate: 604000c5 (nZCv daIF +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : look_up_lock_class+0xec/0x158 kernel/locking/lockdep.c:938
lr : look_up_lock_class+0xec/0x158 kernel/locking/lockdep.c:938
sp : ffff8000200a6b80
x29: ffff8000200a6b80 x28: dfff800000000000 x27: ffff800008f47694
x26: ffff8000195af780 x25: ffff8000195af000 x24: 0000000000000000
x23: 0000000000000000 x22: 0000000000000000 x21: ffff800015900b18
x20: ffff0000e71c9810 x19: ffff8000181ea9c0 x18: 1ffff00004014da8
x17: 0000000000000000 x16: ffff8000120e6354 x15: 0000000000000000
x14: 0000000000000000 x13: 0000000000000001 x12: 0000000000000001
x11: ff808000081ae818 x10: 0000000000000000 x9 : 3e75c3455bea5400
x8 : 3e75c3455bea5400 x7 : 0000000000000001 x6 : 0000000000000001
x5 : ffff8000200a6478 x4 : ffff800015672960 x3 : ffff800008585158
x2 : 0000000000000001 x1 : 0000000100000000 x0 : 0000000000000000
Call trace:
 look_up_lock_class+0xec/0x158 kernel/locking/lockdep.c:938
 register_lock_class+0x90/0x6a8 kernel/locking/lockdep.c:1290
 __lock_acquire+0x184/0x764c kernel/locking/lockdep.c:4935
 lock_acquire+0x26c/0x7cc kernel/locking/lockdep.c:5669
 down_write+0x5c/0x88 kernel/locking/rwsem.c:1573
 inode_lock include/linux/fs.h:756 [inline]
 ext4_xattr_inode_iget+0x3a8/0x4b8 fs/ext4/xattr.c:438
 ext4_xattr_inode_inc_ref_all+0x120/0x484 fs/ext4/xattr.c:1077
 ext4_xattr_block_set+0x1c64/0x2cc4 fs/ext4/xattr.c:2110
 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
irq event stamp: 217
hardirqs last  enabled at (217): [<ffff8000120e4420>] __exit_to_kernel_mode arch/arm64/kernel/entry-common.c:84 [inline]
hardirqs last  enabled at (217): [<ffff8000120e4420>] exit_to_kernel_mode+0xe8/0x118 arch/arm64/kernel/entry-common.c:94
hardirqs last disabled at (216): [<ffff8000120e20fc>] __el1_irq arch/arm64/kernel/entry-common.c:468 [inline]
hardirqs last disabled at (216): [<ffff8000120e20fc>] el1_interrupt+0x24/0x68 arch/arm64/kernel/entry-common.c:486
softirqs last  enabled at (8): [<ffff800008032b74>] local_bh_enable+0x10/0x34 include/linux/bottom_half.h:32
softirqs last disabled at (6): [<ffff800008032b40>] local_bh_disable+0x10/0x34 include/linux/bottom_half.h:19
---[ end trace 0000000000000000 ]---

============================================
WARNING: possible recursive locking detected
6.1.27-syzkaller #0 Tainted: G        W         
--------------------------------------------
syz-executor.2/22745 is trying to acquire lock:
ffff0000e71c9810 (&sb->s_type->i_mutex_key#9){++++}-{3:3}, at: inode_lock include/linux/fs.h:756 [inline]
ffff0000e71c9810 (&sb->s_type->i_mutex_key#9){++++}-{3:3}, at: ext4_xattr_inode_iget+0x3a8/0x4b8 fs/ext4/xattr.c:438

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

other info that might help us debug this:
 Possible unsafe locking scenario:

       CPU0
       ----
  lock(&sb->s_type->i_mutex_key#9);
  lock(&sb->s_type->i_mutex_key#9);

 *** DEADLOCK ***

 May be due to missing lock nesting notation

3 locks held by syz-executor.2/22745:
 #0: ffff0000c9c50460 (sb_writers#3){.+.+}-{0:0}, at: mnt_want_write+0x44/0x9c fs/namespace.c:393
 #1: ffff0000e7274030 (&sb->s_type->i_mutex_key#9){++++}-{3:3}, at: inode_lock include/linux/fs.h:756 [inline]
 #1: ffff0000e7274030 (&sb->s_type->i_mutex_key#9){++++}-{3:3}, at: vfs_setxattr+0x17c/0x344 fs/xattr.c:308
 #2: ffff0000e7273cf8 (&ei->xattr_sem){++++}-{3:3}, at: ext4_write_lock_xattr fs/ext4/xattr.h:155 [inline]
 #2: ffff0000e7273cf8 (&ei->xattr_sem){++++}-{3:3}, at: ext4_xattr_set_handle+0x1e0/0x1294 fs/ext4/xattr.c:2322

stack backtrace:
CPU: 0 PID: 22745 Comm: syz-executor.2 Tainted: G        W          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
 __lock_acquire+0x6310/0x764c kernel/locking/lockdep.c:5056
 lock_acquire+0x26c/0x7cc kernel/locking/lockdep.c:5669
 down_write+0x5c/0x88 kernel/locking/rwsem.c:1573
 inode_lock include/linux/fs.h:756 [inline]
 ext4_xattr_inode_iget+0x3a8/0x4b8 fs/ext4/xattr.c:438
 ext4_xattr_inode_inc_ref_all+0x120/0x484 fs/ext4/xattr.c:1077
 ext4_xattr_block_set+0x1c64/0x2cc4 fs/ext4/xattr.c:2110
 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

Crashes (7):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/05/07 11:26 linux-6.1.y ca48fc16c493 90c93c40 .config console log report syz [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-linux-6-1-kasan-arm64 WARNING: locking bug in ext4_xattr_inode_iget
2023/06/04 06:35 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 WARNING: locking bug in ext4_xattr_inode_iget
2023/06/06 20:18 linux-6.1.y 76ba310227d2 a4ae4f42 .config console log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-linux-6-1-kasan-arm64 WARNING: locking bug in ext4_xattr_inode_iget
2023/05/06 10:32 linux-6.1.y ca48fc16c493 de870ca5 .config console log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-linux-6-1-kasan-arm64 WARNING: locking bug in ext4_xattr_inode_iget
2023/06/06 07:05 linux-6.1.y 76ba310227d2 a4ae4f42 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan WARNING: locking bug in ext4_xattr_inode_iget
2023/06/07 19:42 linux-6.1.y 76ba310227d2 058b3a5a .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 WARNING: locking bug in ext4_xattr_inode_iget
2023/06/06 07:01 linux-6.1.y 76ba310227d2 a4ae4f42 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 WARNING: locking bug in ext4_xattr_inode_iget
* Struck through repros no longer work on HEAD.