syzbot


possible deadlock in ext4_xattr_set_handle (4)

Status: auto-obsoleted due to no activity on 2024/04/29 16:11
Subsystems: ext4
[Documentation on labels]
Reported-by: syzbot+ea0ba556b26f54698271@syzkaller.appspotmail.com
First crash: 303d, last: 178d
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [ext4?] possible deadlock in ext4_xattr_set_handle (4) 0 (1) 2023/09/22 04:51
Similar bugs (7)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in ext4_xattr_set_handle (5) ext4 72 21d 65d 0/27 upstream: reported on 2024/05/13 11:53
upstream possible deadlock in ext4_xattr_set_handle (3) ext4 C 451 382d 539d 22/27 fixed on 2023/07/01 16:05
upstream possible deadlock in ext4_xattr_set_handle ext4 1 1002d 998d 0/27 auto-closed as invalid on 2022/02/15 19:59
upstream possible deadlock in ext4_xattr_set_handle (2) ext4 1 736d 736d 0/27 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 405d 497d 3/3 fixed on 2023/07/17 13:09
linux-4.19 possible deadlock in ext4_xattr_set_handle ext4 1 529d 529d 0/1 upstream: reported on 2023/02/03 16:43
linux-6.1 possible deadlock in ext4_xattr_set_handle C done 15 405d 493d 3/3 fixed on 2023/07/17 13:09

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.7.0-syzkaller-12824-g9d64bf433c53 #0 Not tainted
------------------------------------------------------
syz-executor.3/24120 is trying to acquire lock:
ffffffff8d320a00 (fs_reclaim){+.+.}-{0:0}, at: might_alloc include/linux/sched/mm.h:303 [inline]
ffffffff8d320a00 (fs_reclaim){+.+.}-{0:0}, at: slab_pre_alloc_hook mm/slub.c:3761 [inline]
ffffffff8d320a00 (fs_reclaim){+.+.}-{0:0}, at: slab_alloc_node mm/slub.c:3842 [inline]
ffffffff8d320a00 (fs_reclaim){+.+.}-{0:0}, at: __do_kmalloc_node mm/slub.c:3980 [inline]
ffffffff8d320a00 (fs_reclaim){+.+.}-{0:0}, at: __kmalloc_node+0xb8/0x460 mm/slub.c:3988

but task is already holding lock:
ffff8880484150c8 (&ei->xattr_sem){++++}-{3:3}, at: ext4_write_lock_xattr fs/ext4/xattr.h:155 [inline]
ffff8880484150c8 (&ei->xattr_sem){++++}-{3:3}, at: ext4_xattr_set_handle+0x159/0x1420 fs/ext4/xattr.c:2371

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 (&ei->xattr_sem){++++}-{3:3}:
       down_write+0x3a/0x50 kernel/locking/rwsem.c:1579
       ext4_write_lock_xattr fs/ext4/xattr.h:155 [inline]
       ext4_xattr_set_handle+0x159/0x1420 fs/ext4/xattr.c:2371
       ext4_xattr_set+0x149/0x370 fs/ext4/xattr.c:2558
       __vfs_setxattr+0x173/0x1d0 fs/xattr.c:201
       __vfs_setxattr_noperm+0x127/0x5e0 fs/xattr.c:235
       __vfs_setxattr_locked+0x17e/0x250 fs/xattr.c:296
       vfs_setxattr+0x146/0x350 fs/xattr.c:322
       do_setxattr+0x142/0x170 fs/xattr.c:630
       setxattr+0x159/0x170 fs/xattr.c:653
       __do_sys_fsetxattr fs/xattr.c:709 [inline]
       __se_sys_fsetxattr fs/xattr.c:698 [inline]
       __ia32_sys_fsetxattr+0x25e/0x310 fs/xattr.c:698
       do_syscall_32_irqs_on arch/x86/entry/common.c:165 [inline]
       __do_fast_syscall_32+0x79/0x110 arch/x86/entry/common.c:321
       do_fast_syscall_32+0x33/0x70 arch/x86/entry/common.c:346
       entry_SYSENTER_compat_after_hwframe+0x70/0x7a

-> #2 (jbd2_handle){++++}-{0:0}:
       start_this_handle+0x10ff/0x15e0 fs/jbd2/transaction.c:463
       jbd2__journal_start+0x391/0x840 fs/jbd2/transaction.c:520
       __ext4_journal_start_sb+0x343/0x5d0 fs/ext4/ext4_jbd2.c:112
       ext4_sample_last_mounted fs/ext4/file.c:837 [inline]
       ext4_file_open+0x632/0xc80 fs/ext4/file.c:866
       do_dentry_open+0x8d6/0x18c0 fs/open.c:953
       do_open fs/namei.c:3641 [inline]
       path_openat+0x1df6/0x2990 fs/namei.c:3798
       do_filp_open+0x1de/0x430 fs/namei.c:3825
       do_sys_openat2+0x176/0x1e0 fs/open.c:1404
       do_sys_open fs/open.c:1419 [inline]
       __do_sys_openat fs/open.c:1435 [inline]
       __se_sys_openat fs/open.c:1430 [inline]
       __x64_sys_openat+0x175/0x210 fs/open.c:1430
       do_syscall_x64 arch/x86/entry/common.c:52 [inline]
       do_syscall_64+0xd3/0x250 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x63/0x6b

-> #1 (sb_internal){.+.+}-{0:0}:
       percpu_down_read include/linux/percpu-rwsem.h:51 [inline]
       __sb_start_write include/linux/fs.h:1639 [inline]
       sb_start_intwrite include/linux/fs.h:1822 [inline]
       ext4_evict_inode+0xe5b/0x1a40 fs/ext4/inode.c:212
       evict+0x2ed/0x6b0 fs/inode.c:665
       iput_final fs/inode.c:1739 [inline]
       iput.part.0+0x560/0x7b0 fs/inode.c:1765
       iput+0x5c/0x80 fs/inode.c:1755
       dentry_unlink_inode+0x292/0x430 fs/dcache.c:400
       __dentry_kill+0x1ca/0x5f0 fs/dcache.c:603
       shrink_kill fs/dcache.c:1048 [inline]
       shrink_dentry_list+0x140/0x5d0 fs/dcache.c:1075
       prune_dcache_sb+0xeb/0x150 fs/dcache.c:1156
       super_cache_scan+0x327/0x540 fs/super.c:221
       do_shrink_slab+0x428/0x1120 mm/shrinker.c:435
       shrink_slab_memcg mm/shrinker.c:548 [inline]
       shrink_slab+0xa83/0x1310 mm/shrinker.c:626
       shrink_one+0x48f/0x7b0 mm/vmscan.c:4767
       shrink_many mm/vmscan.c:4828 [inline]
       lru_gen_shrink_node mm/vmscan.c:4929 [inline]
       shrink_node+0x2149/0x3740 mm/vmscan.c:5888
       kswapd_shrink_node mm/vmscan.c:6693 [inline]
       balance_pgdat+0x9d2/0x1a90 mm/vmscan.c:6883
       kswapd+0x5be/0xbf0 mm/vmscan.c:7143
       kthread+0x2c6/0x3a0 kernel/kthread.c:388
       ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147
       ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:242

-> #0 (fs_reclaim){+.+.}-{0:0}:
       check_prev_add kernel/locking/lockdep.c:3134 [inline]
       check_prevs_add kernel/locking/lockdep.c:3253 [inline]
       validate_chain kernel/locking/lockdep.c:3869 [inline]
       __lock_acquire+0x2445/0x3b30 kernel/locking/lockdep.c:5137
       lock_acquire kernel/locking/lockdep.c:5754 [inline]
       lock_acquire+0x1ae/0x520 kernel/locking/lockdep.c:5719
       __fs_reclaim_acquire mm/page_alloc.c:3692 [inline]
       fs_reclaim_acquire+0x100/0x150 mm/page_alloc.c:3706
       might_alloc include/linux/sched/mm.h:303 [inline]
       slab_pre_alloc_hook mm/slub.c:3761 [inline]
       slab_alloc_node mm/slub.c:3842 [inline]
       __do_kmalloc_node mm/slub.c:3980 [inline]
       __kmalloc_node+0xb8/0x460 mm/slub.c:3988
       kmalloc_node include/linux/slab.h:610 [inline]
       kvmalloc_node+0x6f/0x1a0 mm/util.c:617
       kvmalloc include/linux/slab.h:728 [inline]
       ext4_xattr_inode_cache_find fs/ext4/xattr.c:1535 [inline]
       ext4_xattr_inode_lookup_create fs/ext4/xattr.c:1577 [inline]
       ext4_xattr_set_entry+0x1c3f/0x3ce0 fs/ext4/xattr.c:1719
       ext4_xattr_block_set+0xcbf/0x3180 fs/ext4/xattr.c:2039
       ext4_xattr_set_handle+0xd70/0x1420 fs/ext4/xattr.c:2456
       ext4_xattr_set+0x149/0x370 fs/ext4/xattr.c:2558
       __vfs_setxattr+0x173/0x1d0 fs/xattr.c:201
       __vfs_setxattr_noperm+0x127/0x5e0 fs/xattr.c:235
       __vfs_setxattr_locked+0x17e/0x250 fs/xattr.c:296
       vfs_setxattr+0x146/0x350 fs/xattr.c:322
       do_setxattr+0x142/0x170 fs/xattr.c:630
       setxattr+0x159/0x170 fs/xattr.c:653
       __do_sys_fsetxattr fs/xattr.c:709 [inline]
       __se_sys_fsetxattr fs/xattr.c:698 [inline]
       __ia32_sys_fsetxattr+0x25e/0x310 fs/xattr.c:698
       do_syscall_32_irqs_on arch/x86/entry/common.c:165 [inline]
       __do_fast_syscall_32+0x79/0x110 arch/x86/entry/common.c:321
       do_fast_syscall_32+0x33/0x70 arch/x86/entry/common.c:346
       entry_SYSENTER_compat_after_hwframe+0x70/0x7a

other info that might help us debug this:

Chain exists of:
  fs_reclaim --> jbd2_handle --> &ei->xattr_sem

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&ei->xattr_sem);
                               lock(jbd2_handle);
                               lock(&ei->xattr_sem);
  lock(fs_reclaim);

 *** DEADLOCK ***

3 locks held by syz-executor.3/24120:
 #0: ffff88804e694420 (sb_writers#4){.+.+}-{0:0}, at: __do_sys_fsetxattr fs/xattr.c:707 [inline]
 #0: ffff88804e694420 (sb_writers#4){.+.+}-{0:0}, at: __se_sys_fsetxattr fs/xattr.c:698 [inline]
 #0: ffff88804e694420 (sb_writers#4){.+.+}-{0:0}, at: __ia32_sys_fsetxattr+0x17a/0x310 fs/xattr.c:698
 #1: ffff888048415400 (&sb->s_type->i_mutex_key#8){++++}-{3:3}, at: inode_lock include/linux/fs.h:802 [inline]
 #1: ffff888048415400 (&sb->s_type->i_mutex_key#8){++++}-{3:3}, at: vfs_setxattr+0x123/0x350 fs/xattr.c:321
 #2: ffff8880484150c8 (&ei->xattr_sem){++++}-{3:3}, at: ext4_write_lock_xattr fs/ext4/xattr.h:155 [inline]
 #2: ffff8880484150c8 (&ei->xattr_sem){++++}-{3:3}, at: ext4_xattr_set_handle+0x159/0x1420 fs/ext4/xattr.c:2371

stack backtrace:
CPU: 1 PID: 24120 Comm: syz-executor.3 Not tainted 6.7.0-syzkaller-12824-g9d64bf433c53 #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.2-debian-1.16.2-1 04/01/2014
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xd9/0x1b0 lib/dump_stack.c:106
 check_noncircular+0x317/0x400 kernel/locking/lockdep.c:2187
 check_prev_add kernel/locking/lockdep.c:3134 [inline]
 check_prevs_add kernel/locking/lockdep.c:3253 [inline]
 validate_chain kernel/locking/lockdep.c:3869 [inline]
 __lock_acquire+0x2445/0x3b30 kernel/locking/lockdep.c:5137
 lock_acquire kernel/locking/lockdep.c:5754 [inline]
 lock_acquire+0x1ae/0x520 kernel/locking/lockdep.c:5719
 __fs_reclaim_acquire mm/page_alloc.c:3692 [inline]
 fs_reclaim_acquire+0x100/0x150 mm/page_alloc.c:3706
 might_alloc include/linux/sched/mm.h:303 [inline]
 slab_pre_alloc_hook mm/slub.c:3761 [inline]
 slab_alloc_node mm/slub.c:3842 [inline]
 __do_kmalloc_node mm/slub.c:3980 [inline]
 __kmalloc_node+0xb8/0x460 mm/slub.c:3988
 kmalloc_node include/linux/slab.h:610 [inline]
 kvmalloc_node+0x6f/0x1a0 mm/util.c:617
 kvmalloc include/linux/slab.h:728 [inline]
 ext4_xattr_inode_cache_find fs/ext4/xattr.c:1535 [inline]
 ext4_xattr_inode_lookup_create fs/ext4/xattr.c:1577 [inline]
 ext4_xattr_set_entry+0x1c3f/0x3ce0 fs/ext4/xattr.c:1719
 ext4_xattr_block_set+0xcbf/0x3180 fs/ext4/xattr.c:2039
 ext4_xattr_set_handle+0xd70/0x1420 fs/ext4/xattr.c:2456
 ext4_xattr_set+0x149/0x370 fs/ext4/xattr.c:2558
 __vfs_setxattr+0x173/0x1d0 fs/xattr.c:201
 __vfs_setxattr_noperm+0x127/0x5e0 fs/xattr.c:235
 __vfs_setxattr_locked+0x17e/0x250 fs/xattr.c:296
 vfs_setxattr+0x146/0x350 fs/xattr.c:322
 do_setxattr+0x142/0x170 fs/xattr.c:630
 setxattr+0x159/0x170 fs/xattr.c:653
 __do_sys_fsetxattr fs/xattr.c:709 [inline]
 __se_sys_fsetxattr fs/xattr.c:698 [inline]
 __ia32_sys_fsetxattr+0x25e/0x310 fs/xattr.c:698
 do_syscall_32_irqs_on arch/x86/entry/common.c:165 [inline]
 __do_fast_syscall_32+0x79/0x110 arch/x86/entry/common.c:321
 do_fast_syscall_32+0x33/0x70 arch/x86/entry/common.c:346
 entry_SYSENTER_compat_after_hwframe+0x70/0x7a
RIP: 0023:0xf7f4e579
Code: b8 01 10 06 03 74 b4 01 10 07 03 74 b0 01 10 08 03 74 d8 01 00 00 00 00 00 00 00 00 00 00 00 00 00 51 52 55 89 e5 0f 34 cd 80 <5d> 5a 59 c3 90 90 90 90 8d b4 26 00 00 00 00 8d b4 26 00 00 00 00
RSP: 002b:00000000f7f495ac EFLAGS: 00000292 ORIG_RAX: 00000000000000e4
RAX: ffffffffffffffda RBX: 0000000000000005 RCX: 0000000020000100
RDX: 00000000200001c0 RSI: 0000000000001001 RDI: 0000000000000000
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000292 R12: 0000000000000000
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
 </TASK>
----------------
Code disassembly (best guess), 2 bytes skipped:
   0:	10 06                	adc    %al,(%rsi)
   2:	03 74 b4 01          	add    0x1(%rsp,%rsi,4),%esi
   6:	10 07                	adc    %al,(%rdi)
   8:	03 74 b0 01          	add    0x1(%rax,%rsi,4),%esi
   c:	10 08                	adc    %cl,(%rax)
   e:	03 74 d8 01          	add    0x1(%rax,%rbx,8),%esi
  1e:	00 51 52             	add    %dl,0x52(%rcx)
  21:	55                   	push   %rbp
  22:	89 e5                	mov    %esp,%ebp
  24:	0f 34                	sysenter
  26:	cd 80                	int    $0x80
* 28:	5d                   	pop    %rbp <-- trapping instruction
  29:	5a                   	pop    %rdx
  2a:	59                   	pop    %rcx
  2b:	c3                   	ret
  2c:	90                   	nop
  2d:	90                   	nop
  2e:	90                   	nop
  2f:	90                   	nop
  30:	8d b4 26 00 00 00 00 	lea    0x0(%rsi,%riz,1),%esi
  37:	8d b4 26 00 00 00 00 	lea    0x0(%rsi,%riz,1),%esi

Crashes (5):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/01/20 16:10 upstream 9d64bf433c53 9bd8dcda .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 possible deadlock in ext4_xattr_set_handle
2023/12/31 14:30 upstream 453f5db0619e fb427a07 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 possible deadlock in ext4_xattr_set_handle
2023/12/17 13:41 upstream 3b8a9b2e6809 3222d10c .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 possible deadlock in ext4_xattr_set_handle
2023/11/12 21:57 upstream b57b17e88bf5 6d6dbf8a .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 possible deadlock in ext4_xattr_set_handle
2023/09/18 04:42 upstream e789286468a9 0b6a67ac .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 possible deadlock in ext4_xattr_set_handle
* Struck through repros no longer work on HEAD.