syzbot


possible deadlock in ext4_da_get_block_prep

Status: upstream: reported on 2023/07/09 11:14
Subsystems: ext4
[Documentation on labels]
Reported-by: syzbot+a86b193140e10df1aff2@syzkaller.appspotmail.com
First crash: 153d, last: 26d
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [ext4?] possible deadlock in ext4_da_get_block_prep 0 (1) 2023/07/09 11:14

Sample crash report:
R10: 0000000000000000 R11: 0000000000000293 R12: 0000000000000000
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
 </TASK>
======================================================
WARNING: possible circular locking dependency detected
6.6.0-syzkaller-15477-g34f763262743 #0 Not tainted
------------------------------------------------------
syz-executor.2/18847 is trying to acquire lock:
ffffffff8d11d1a0 (fs_reclaim){+.+.}-{0:0}, at: might_alloc include/linux/sched/mm.h:303 [inline]
ffffffff8d11d1a0 (fs_reclaim){+.+.}-{0:0}, at: slab_pre_alloc_hook mm/slab.h:710 [inline]
ffffffff8d11d1a0 (fs_reclaim){+.+.}-{0:0}, at: slab_alloc_node mm/slub.c:3460 [inline]
ffffffff8d11d1a0 (fs_reclaim){+.+.}-{0:0}, at: slab_alloc mm/slub.c:3486 [inline]
ffffffff8d11d1a0 (fs_reclaim){+.+.}-{0:0}, at: __kmem_cache_alloc_lru mm/slub.c:3493 [inline]
ffffffff8d11d1a0 (fs_reclaim){+.+.}-{0:0}, at: kmem_cache_alloc+0x4f/0x380 mm/slub.c:3502

but task is already holding lock:
ffff888026ed0288 (&ei->i_data_sem){++++}-{3:3}, at: ext4_da_map_blocks fs/ext4/inode.c:1745 [inline]
ffff888026ed0288 (&ei->i_data_sem){++++}-{3:3}, at: ext4_da_get_block_prep+0x6c9/0x1340 fs/ext4/inode.c:1823

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&ei->i_data_sem){++++}-{3:3}:
       down_write+0x93/0x200 kernel/locking/rwsem.c:1579
       ext4_truncate+0xd13/0x1300 fs/ext4/inode.c:4164
       ext4_evict_inode+0x7a1/0x1a30 fs/ext4/inode.c:258
       evict+0x2ed/0x6b0 fs/inode.c:664
       iput_final fs/inode.c:1775 [inline]
       iput.part.0+0x55e/0x7a0 fs/inode.c:1801
       iput+0x5c/0x80 fs/inode.c:1791
       ext4_orphan_cleanup+0x70f/0x11d0 fs/ext4/orphan.c:474
       __ext4_fill_super fs/ext4/super.c:5591 [inline]
       ext4_fill_super+0x93af/0xaf20 fs/ext4/super.c:5712
       get_tree_bdev+0x3b5/0x650 fs/super.c:1598
       vfs_get_tree+0x8c/0x370 fs/super.c:1771
       do_new_mount fs/namespace.c:3337 [inline]
       path_mount+0x1492/0x1ed0 fs/namespace.c:3664
       do_mount fs/namespace.c:3677 [inline]
       __do_sys_mount fs/namespace.c:3886 [inline]
       __se_sys_mount fs/namespace.c:3863 [inline]
       __ia32_sys_mount+0x291/0x310 fs/namespace.c:3863
       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 (sb_internal){.+.+}-{0:0}:
       percpu_down_read include/linux/percpu-rwsem.h:51 [inline]
       __sb_start_write include/linux/fs.h:1635 [inline]
       sb_start_intwrite include/linux/fs.h:1757 [inline]
       ext4_evict_inode+0xe55/0x1a30 fs/ext4/inode.c:212
       evict+0x2ed/0x6b0 fs/inode.c:664
       iput_final fs/inode.c:1775 [inline]
       iput.part.0+0x55e/0x7a0 fs/inode.c:1801
       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+0x327/0x540 fs/super.c:228
       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+0x4f7/0x700 mm/vmscan.c:4724
       shrink_many mm/vmscan.c:4776 [inline]
       lru_gen_shrink_node mm/vmscan.c:4893 [inline]
       shrink_node+0x20cd/0x3790 mm/vmscan.c:5833
       kswapd_shrink_node mm/vmscan.c:6638 [inline]
       balance_pgdat+0xa32/0x1b80 mm/vmscan.c:6828
       kswapd+0x5be/0xbf0 mm/vmscan.c:7088
       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:3693 [inline]
       fs_reclaim_acquire+0x100/0x150 mm/page_alloc.c:3707
       might_alloc include/linux/sched/mm.h:303 [inline]
       slab_pre_alloc_hook mm/slab.h:710 [inline]
       slab_alloc_node mm/slub.c:3460 [inline]
       slab_alloc mm/slub.c:3486 [inline]
       __kmem_cache_alloc_lru mm/slub.c:3493 [inline]
       kmem_cache_alloc+0x4f/0x380 mm/slub.c:3502
       kmem_cache_zalloc include/linux/slab.h:711 [inline]
       __es_alloc_extent fs/ext4/extents_status.c:483 [inline]
       ext4_es_insert_delayed_block+0x542/0x750 fs/ext4/extents_status.c:2090
       ext4_insert_delayed_block fs/ext4/inode.c:1674 [inline]
       ext4_da_map_blocks fs/ext4/inode.c:1762 [inline]
       ext4_da_get_block_prep+0x850/0x1340 fs/ext4/inode.c:1823
       ext4_block_write_begin+0x3da/0xee0 fs/ext4/inode.c:1053
       ext4_da_write_begin+0x40a/0x8c0 fs/ext4/inode.c:2900
       generic_perform_write+0x278/0x600 mm/filemap.c:3918
       ext4_buffered_write_iter+0x11f/0x3c0 fs/ext4/file.c:299
       ext4_file_write_iter+0x819/0x1950 fs/ext4/file.c:696
       call_write_iter include/linux/fs.h:2020 [inline]
       new_sync_write fs/read_write.c:491 [inline]
       vfs_write+0x64f/0xdf0 fs/read_write.c:584
       ksys_write+0x12f/0x250 fs/read_write.c:637
       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 --> sb_internal --> &ei->i_data_sem

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  rlock(&ei->i_data_sem);
                               lock(sb_internal);
                               lock(&ei->i_data_sem);
  lock(fs_reclaim);

 *** DEADLOCK ***

4 locks held by syz-executor.2/18847:
 #0: ffff888025257048 (&f->f_pos_lock){+.+.}-{3:3}, at: __fdget_pos+0xe7/0x170 fs/file.c:1177
 #1: ffff88801e25c418 (sb_writers#4){.+.+}-{0:0}, at: ksys_write+0x12f/0x250 fs/read_write.c:637
 #2: ffff888026ed0400 (&sb->s_type->i_mutex_key#8){++++}-{3:3}, at: inode_lock include/linux/fs.h:802 [inline]
 #2: ffff888026ed0400 (&sb->s_type->i_mutex_key#8){++++}-{3:3}, at: ext4_buffered_write_iter+0xb0/0x3c0 fs/ext4/file.c:294
 #3: ffff888026ed0288 (&ei->i_data_sem){++++}-{3:3}, at: ext4_da_map_blocks fs/ext4/inode.c:1745 [inline]
 #3: ffff888026ed0288 (&ei->i_data_sem){++++}-{3:3}, at: ext4_da_get_block_prep+0x6c9/0x1340 fs/ext4/inode.c:1823

stack backtrace:
CPU: 2 PID: 18847 Comm: syz-executor.2 Not tainted 6.6.0-syzkaller-15477-g34f763262743 #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:3693 [inline]
 fs_reclaim_acquire+0x100/0x150 mm/page_alloc.c:3707
 might_alloc include/linux/sched/mm.h:303 [inline]
 slab_pre_alloc_hook mm/slab.h:710 [inline]
 slab_alloc_node mm/slub.c:3460 [inline]
 slab_alloc mm/slub.c:3486 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3493 [inline]
 kmem_cache_alloc+0x4f/0x380 mm/slub.c:3502
 kmem_cache_zalloc include/linux/slab.h:711 [inline]
 __es_alloc_extent fs/ext4/extents_status.c:483 [inline]
 ext4_es_insert_delayed_block+0x542/0x750 fs/ext4/extents_status.c:2090
 ext4_insert_delayed_block fs/ext4/inode.c:1674 [inline]
 ext4_da_map_blocks fs/ext4/inode.c:1762 [inline]
 ext4_da_get_block_prep+0x850/0x1340 fs/ext4/inode.c:1823
 ext4_block_write_begin+0x3da/0xee0 fs/ext4/inode.c:1053
 ext4_da_write_begin+0x40a/0x8c0 fs/ext4/inode.c:2900
 generic_perform_write+0x278/0x600 mm/filemap.c:3918
 ext4_buffered_write_iter+0x11f/0x3c0 fs/ext4/file.c:299
 ext4_file_write_iter+0x819/0x1950 fs/ext4/file.c:696
 call_write_iter include/linux/fs.h:2020 [inline]
 new_sync_write fs/read_write.c:491 [inline]
 vfs_write+0x64f/0xdf0 fs/read_write.c:584
 ksys_write+0x12f/0x250 fs/read_write.c:637
 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:0xf7f49579
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:00000000f7f235ac EFLAGS: 00000292 ORIG_RAX: 0000000000000004
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000020000540
RDX: 00000000fffffdd8 RSI: 0000000000000000 RDI: 0000000000000000
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000293 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 (8):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/11/09 05:56 upstream 34f763262743 4862372a .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 possible deadlock in ext4_da_get_block_prep
2023/10/28 04:20 upstream 56567a20b22b 3c418d72 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 possible deadlock in ext4_da_get_block_prep
2023/10/04 03:40 upstream 5e62ed3b1c8a 65faba36 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 possible deadlock in ext4_da_get_block_prep
2023/08/30 18:40 upstream 6c1b980a7e79 84803932 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 possible deadlock in ext4_da_get_block_prep
2023/07/05 11:07 upstream d528014517f2 80298b6f .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root possible deadlock in ext4_da_get_block_prep
2023/07/27 15:44 upstream 0a8db05b571a 92476829 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 possible deadlock in ext4_da_get_block_prep
2023/07/07 11:10 upstream a452483508d7 22ae5830 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 possible deadlock in ext4_da_get_block_prep
2023/10/18 02:04 net 95535e37e895 342b9c55 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-this-kasan-gce possible deadlock in ext4_da_get_block_prep
* Struck through repros no longer work on HEAD.