syzbot


possible deadlock in __ext4_mark_inode_dirty (2)

Status: auto-obsoleted due to no activity on 2024/02/09 09:55
Subsystems: ext4
[Documentation on labels]
Reported-by: syzbot+1422c4a798761a48ea4f@syzkaller.appspotmail.com
First crash: 207d, last: 124d
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [ext4?] possible deadlock in __ext4_mark_inode_dirty (2) 0 (1) 2023/08/14 12:42
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in __ext4_mark_inode_dirty ext4 14 345d 368d 0/26 auto-obsoleted due to no activity on 2023/07/23 20:58

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.6.0-syzkaller-05843-g89ed67ef126c #0 Not tainted
------------------------------------------------------
syz-executor.0/17583 is trying to acquire lock:
ffffffff8d11be80 (fs_reclaim){+.+.}-{0:0}, at: might_alloc include/linux/sched/mm.h:303 [inline]
ffffffff8d11be80 (fs_reclaim){+.+.}-{0:0}, at: slab_pre_alloc_hook mm/slab.h:709 [inline]
ffffffff8d11be80 (fs_reclaim){+.+.}-{0:0}, at: slab_alloc_node mm/slub.c:3460 [inline]
ffffffff8d11be80 (fs_reclaim){+.+.}-{0:0}, at: __kmem_cache_alloc_node+0x51/0x330 mm/slub.c:3517

but task is already holding lock:
ffff8880244a6ec8 (&ei->xattr_sem){++++}-{3:3}, at: ext4_write_trylock_xattr fs/ext4/xattr.h:162 [inline]
ffff8880244a6ec8 (&ei->xattr_sem){++++}-{3:3}, at: ext4_try_to_expand_extra_isize fs/ext4/inode.c:5844 [inline]
ffff8880244a6ec8 (&ei->xattr_sem){++++}-{3:3}, at: __ext4_mark_inode_dirty+0x4a1/0x800 fs/ext4/inode.c:5925

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&ei->xattr_sem){++++}-{3:3}:
       down_write+0x93/0x200 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
       path_setxattr+0x175/0x1d0 fs/xattr.c:672
       __do_sys_lsetxattr fs/xattr.c:695 [inline]
       __se_sys_lsetxattr fs/xattr.c:691 [inline]
       __ia32_sys_lsetxattr+0xbd/0x150 fs/xattr.c:691
       do_syscall_32_irqs_on arch/x86/entry/common.c:164 [inline]
       __do_fast_syscall_32+0x61/0xe0 arch/x86/entry/common.c:230
       do_fast_syscall_32+0x33/0x70 arch/x86/entry/common.c:255
       entry_SYSENTER_compat_after_hwframe+0x70/0x7a

-> #1 (jbd2_handle){++++}-{0:0}:
       start_this_handle+0x10fc/0x15e0 fs/jbd2/transaction.c:463
       jbd2__journal_start+0x391/0x690 fs/jbd2/transaction.c:520
       __ext4_journal_start_sb+0x40f/0x5c0 fs/ext4/ext4_jbd2.c:112
       __ext4_journal_start fs/ext4/ext4_jbd2.h:326 [inline]
       ext4_dirty_inode+0xa1/0x130 fs/ext4/inode.c:5954
       __mark_inode_dirty+0x1e0/0xd50 fs/fs-writeback.c:2452
       mark_inode_dirty_sync include/linux/fs.h:2311 [inline]
       iput.part.0+0x5b/0x7a0 fs/inode.c:1798
       iput+0x5c/0x80 fs/inode.c:1791
       dentry_unlink_inode+0x292/0x430 fs/dcache.c:401
       __dentry_kill+0x3b8/0x640 fs/dcache.c:607
       shrink_dentry_list+0x22b/0x7d0 fs/dcache.c:1201
       prune_dcache_sb+0xeb/0x150 fs/dcache.c:1282
       super_cache_scan+0x31f/0x540 fs/super.c:228
       do_shrink_slab+0x422/0xaa0 mm/vmscan.c:900
       shrink_slab_memcg mm/vmscan.c:969 [inline]
       shrink_slab+0x48b/0x6e0 mm/vmscan.c:1048
       shrink_one+0x4f7/0x700 mm/vmscan.c:5417
       shrink_many mm/vmscan.c:5469 [inline]
       lru_gen_shrink_node mm/vmscan.c:5586 [inline]
       shrink_node+0x20cd/0x3790 mm/vmscan.c:6526
       kswapd_shrink_node mm/vmscan.c:7331 [inline]
       balance_pgdat+0xa32/0x1b80 mm/vmscan.c:7521
       kswapd+0x5be/0xbf0 mm/vmscan.c:7781
       kthread+0x33c/0x440 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:3868 [inline]
       __lock_acquire+0x2e3d/0x5de0 kernel/locking/lockdep.c:5136
       lock_acquire kernel/locking/lockdep.c:5753 [inline]
       lock_acquire+0x1ae/0x510 kernel/locking/lockdep.c:5718
       __fs_reclaim_acquire mm/page_alloc.c:3551 [inline]
       fs_reclaim_acquire+0x100/0x150 mm/page_alloc.c:3565
       might_alloc include/linux/sched/mm.h:303 [inline]
       slab_pre_alloc_hook mm/slab.h:709 [inline]
       slab_alloc_node mm/slub.c:3460 [inline]
       __kmem_cache_alloc_node+0x51/0x330 mm/slub.c:3517
       __do_kmalloc_node mm/slab_common.c:1006 [inline]
       __kmalloc_node+0x52/0x110 mm/slab_common.c:1014
       kmalloc_node include/linux/slab.h:620 [inline]
       kvmalloc_node+0x99/0x1a0 mm/util.c:607
       kvmalloc include/linux/slab.h:738 [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+0x1c3d/0x3ce0 fs/ext4/xattr.c:1719
       ext4_xattr_block_set+0xcbf/0x30e0 fs/ext4/xattr.c:2039
       ext4_xattr_move_to_block fs/ext4/xattr.c:2667 [inline]
       ext4_xattr_make_inode_space fs/ext4/xattr.c:2742 [inline]
       ext4_expand_extra_isize_ea+0x1306/0x1b20 fs/ext4/xattr.c:2834
       __ext4_expand_extra_isize+0x342/0x470 fs/ext4/inode.c:5804
       ext4_try_to_expand_extra_isize fs/ext4/inode.c:5847 [inline]
       __ext4_mark_inode_dirty+0x52b/0x800 fs/ext4/inode.c:5925
       ext4_dirty_inode+0xd9/0x130 fs/ext4/inode.c:5957
       __mark_inode_dirty+0x1e0/0xd50 fs/fs-writeback.c:2452
       mark_inode_dirty include/linux/fs.h:2306 [inline]
       ext4_setattr+0x37c/0x29d0 fs/ext4/inode.c:5481
       notify_change+0x742/0x11c0 fs/attr.c:499
       vfs_utimes+0x41d/0x840 fs/utimes.c:66
       do_utimes_path+0x114/0x1c0 fs/utimes.c:99
       do_utimes+0x34/0x100 fs/utimes.c:145
       __do_sys_utimensat_time32 fs/utimes.c:264 [inline]
       __se_sys_utimensat_time32 fs/utimes.c:252 [inline]
       __ia32_sys_utimensat_time32+0x1c7/0x2b0 fs/utimes.c:252
       do_syscall_32_irqs_on arch/x86/entry/common.c:164 [inline]
       __do_fast_syscall_32+0x61/0xe0 arch/x86/entry/common.c:230
       do_fast_syscall_32+0x33/0x70 arch/x86/entry/common.c:255
       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.0/17583:
 #0: ffff888027922418 (sb_writers#4){.+.+}-{0:0}, at: vfs_utimes+0x6aa/0x840 fs/utimes.c:36
 #1: ffff8880244a7200 (&type->i_mutex_dir_key#3){++++}-{3:3}, at: inode_lock include/linux/fs.h:802 [inline]
 #1: ffff8880244a7200 (&type->i_mutex_dir_key#3){++++}-{3:3}, at: vfs_utimes+0x3d2/0x840 fs/utimes.c:65
 #2: ffff8880244a6ec8 (&ei->xattr_sem){++++}-{3:3}, at: ext4_write_trylock_xattr fs/ext4/xattr.h:162 [inline]
 #2: ffff8880244a6ec8 (&ei->xattr_sem){++++}-{3:3}, at: ext4_try_to_expand_extra_isize fs/ext4/inode.c:5844 [inline]
 #2: ffff8880244a6ec8 (&ei->xattr_sem){++++}-{3:3}, at: __ext4_mark_inode_dirty+0x4a1/0x800 fs/ext4/inode.c:5925

stack backtrace:
CPU: 0 PID: 17583 Comm: syz-executor.0 Not tainted 6.6.0-syzkaller-05843-g89ed67ef126c #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+0x311/0x3f0 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:3868 [inline]
 __lock_acquire+0x2e3d/0x5de0 kernel/locking/lockdep.c:5136
 lock_acquire kernel/locking/lockdep.c:5753 [inline]
 lock_acquire+0x1ae/0x510 kernel/locking/lockdep.c:5718
 __fs_reclaim_acquire mm/page_alloc.c:3551 [inline]
 fs_reclaim_acquire+0x100/0x150 mm/page_alloc.c:3565
 might_alloc include/linux/sched/mm.h:303 [inline]
 slab_pre_alloc_hook mm/slab.h:709 [inline]
 slab_alloc_node mm/slub.c:3460 [inline]
 __kmem_cache_alloc_node+0x51/0x330 mm/slub.c:3517
 __do_kmalloc_node mm/slab_common.c:1006 [inline]
 __kmalloc_node+0x52/0x110 mm/slab_common.c:1014
 kmalloc_node include/linux/slab.h:620 [inline]
 kvmalloc_node+0x99/0x1a0 mm/util.c:607
 kvmalloc include/linux/slab.h:738 [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+0x1c3d/0x3ce0 fs/ext4/xattr.c:1719
 ext4_xattr_block_set+0xcbf/0x30e0 fs/ext4/xattr.c:2039
 ext4_xattr_move_to_block fs/ext4/xattr.c:2667 [inline]
 ext4_xattr_make_inode_space fs/ext4/xattr.c:2742 [inline]
 ext4_expand_extra_isize_ea+0x1306/0x1b20 fs/ext4/xattr.c:2834
 __ext4_expand_extra_isize+0x342/0x470 fs/ext4/inode.c:5804
 ext4_try_to_expand_extra_isize fs/ext4/inode.c:5847 [inline]
 __ext4_mark_inode_dirty+0x52b/0x800 fs/ext4/inode.c:5925
 ext4_dirty_inode+0xd9/0x130 fs/ext4/inode.c:5957
 __mark_inode_dirty+0x1e0/0xd50 fs/fs-writeback.c:2452
 mark_inode_dirty include/linux/fs.h:2306 [inline]
 ext4_setattr+0x37c/0x29d0 fs/ext4/inode.c:5481
 notify_change+0x742/0x11c0 fs/attr.c:499
 vfs_utimes+0x41d/0x840 fs/utimes.c:66
 do_utimes_path+0x114/0x1c0 fs/utimes.c:99
 do_utimes+0x34/0x100 fs/utimes.c:145
 __do_sys_utimensat_time32 fs/utimes.c:264 [inline]
 __se_sys_utimensat_time32 fs/utimes.c:252 [inline]
 __ia32_sys_utimensat_time32+0x1c7/0x2b0 fs/utimes.c:252
 do_syscall_32_irqs_on arch/x86/entry/common.c:164 [inline]
 __do_fast_syscall_32+0x61/0xe0 arch/x86/entry/common.c:230
 do_fast_syscall_32+0x33/0x70 arch/x86/entry/common.c:255
 entry_SYSENTER_compat_after_hwframe+0x70/0x7a
RIP: 0023:0xf7f9c579
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:00000000f7f975ac EFLAGS: 00000292 ORIG_RAX: 0000000000000140
RAX: ffffffffffffffda RBX: 0000000000000004 RCX: 0000000020000100
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 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 (4):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/11/01 09:54 upstream 89ed67ef126c 69904c9f .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 possible deadlock in __ext4_mark_inode_dirty
2023/08/30 21:51 upstream 6c1b980a7e79 84803932 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 possible deadlock in __ext4_mark_inode_dirty
2023/08/16 13:45 upstream 4853c74bd7ab 7773e940 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 possible deadlock in __ext4_mark_inode_dirty
2023/08/10 12:30 upstream 374a7f47bf40 da3c3ef8 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 possible deadlock in __ext4_mark_inode_dirty
* Struck through repros no longer work on HEAD.