syzbot


possible deadlock in ext4_writepages (2)

Status: upstream: reported syz repro on 2025/09/10 19:34
Reported-by: syzbot+4e957072bdc454795418@syzkaller.appspotmail.com
First crash: 2d12h, last: 2d11h
Similar bugs (5)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-6.1 possible deadlock in ext4_writepages 4 syz 11 2h18m 2d09h 0/3 upstream: reported syz repro on 2025/09/10 22:18
upstream possible deadlock in ext4_writepages ext4 4 1 1127d 1123d 0/29 auto-obsoleted due to no activity on 2022/12/11 07:00
upstream possible deadlock in ext4_writepages (2) ext4 4 C unreliable 50 28m 328d 0/29 upstream: reported C repro on 2024/10/19 20:27
linux-6.6 possible deadlock in ext4_writepages origin:upstream 4 syz 10 1h53m 15h59m 0/2 upstream: reported syz repro on 2025/09/12 16:06
linux-5.15 possible deadlock in ext4_writepages 4 2 863d 864d 0/3 auto-obsoleted due to no activity on 2023/08/23 09:09

Sample crash report:
loop0: detected capacity change from 0 to 512
======================================================
WARNING: possible circular locking dependency detected
syzkaller #0 Not tainted
------------------------------------------------------
syz.0.17/4321 is trying to acquire lock:
ffff888074f64bd8 (&sbi->s_writepages_rwsem){.+.+}-{0:0}, at: ext4_writepages+0x1c0/0x2d20 fs/ext4/inode.c:2689

but task is already holding lock:
ffff8880702dbc98 (&ei->xattr_sem){++++}-{3:3}, at: ext4_write_trylock_xattr fs/ext4/xattr.h:162 [inline]
ffff8880702dbc98 (&ei->xattr_sem){++++}-{3:3}, at: ext4_try_to_expand_extra_isize fs/ext4/inode.c:5927 [inline]
ffff8880702dbc98 (&ei->xattr_sem){++++}-{3:3}, at: __ext4_mark_inode_dirty+0x3e8/0x700 fs/ext4/inode.c:6008

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&ei->xattr_sem){++++}-{3:3}:
       down_read+0x44/0x2e0 kernel/locking/rwsem.c:1498
       ext4_setattr+0x71d/0x19e0 fs/ext4/inode.c:5451
       notify_change+0xbcd/0xee0 fs/attr.c:505
       chown_common+0x483/0x610 fs/open.c:680
       do_fchownat+0x164/0x270 fs/open.c:711
       __do_sys_chown fs/open.c:731 [inline]
       __se_sys_chown fs/open.c:729 [inline]
       __x64_sys_chown+0x7e/0x90 fs/open.c:729
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x66/0xd0

-> #1 (jbd2_handle){++++}-{0:0}:
       start_this_handle+0x1338/0x15a0 fs/jbd2/transaction.c:464
       jbd2__journal_start+0x2b7/0x5a0 fs/jbd2/transaction.c:521
       __ext4_journal_start_sb+0x167/0x360 fs/ext4/ext4_jbd2.c:105
       __ext4_journal_start fs/ext4/ext4_jbd2.h:326 [inline]
       ext4_writepages+0xdc2/0x2d20 fs/ext4/inode.c:2812
       do_writepages+0x48d/0x6d0 mm/page-writeback.c:2386
       filemap_fdatawrite_wbc+0x1eb/0x240 mm/filemap.c:400
       __filemap_fdatawrite_range mm/filemap.c:433 [inline]
       file_write_and_wait_range+0x129/0x1e0 mm/filemap.c:810
       ext4_sync_file+0x1ff/0xae0 fs/ext4/fsync.c:151
       vfs_fsync_range fs/sync.c:188 [inline]
       vfs_fsync fs/sync.c:202 [inline]
       do_fsync fs/sync.c:212 [inline]
       __do_sys_fsync fs/sync.c:220 [inline]
       __se_sys_fsync fs/sync.c:218 [inline]
       __x64_sys_fsync+0x1a5/0x1e0 fs/sync.c:218
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x66/0xd0

-> #0 (&sbi->s_writepages_rwsem){.+.+}-{0:0}:
       check_prev_add kernel/locking/lockdep.c:3053 [inline]
       check_prevs_add kernel/locking/lockdep.c:3172 [inline]
       validate_chain kernel/locking/lockdep.c:3788 [inline]
       __lock_acquire+0x2c33/0x7c60 kernel/locking/lockdep.c:5012
       lock_acquire+0x197/0x3f0 kernel/locking/lockdep.c:5623
       percpu_down_read+0x46/0x1b0 include/linux/percpu-rwsem.h:51
       ext4_writepages+0x1c0/0x2d20 fs/ext4/inode.c:2689
       do_writepages+0x48d/0x6d0 mm/page-writeback.c:2386
       __writeback_single_inode+0x153/0xda0 fs/fs-writeback.c:1647
       writeback_single_inode+0x221/0x8b0 fs/fs-writeback.c:1760
       write_inode_now+0x217/0x280 fs/fs-writeback.c:2801
       iput_final fs/inode.c:1756 [inline]
       iput+0x5ab/0x8a0 fs/inode.c:1795
       ext4_xattr_set_entry+0x10ff/0x3d30 fs/ext4/xattr.c:1836
       ext4_xattr_block_set+0x4f7/0x2d30 fs/ext4/xattr.c:1935
       ext4_xattr_move_to_block fs/ext4/xattr.c:2632 [inline]
       ext4_xattr_make_inode_space fs/ext4/xattr.c:2707 [inline]
       ext4_expand_extra_isize_ea+0xf4b/0x19a0 fs/ext4/xattr.c:2799
       __ext4_expand_extra_isize+0x301/0x3e0 fs/ext4/inode.c:5887
       ext4_try_to_expand_extra_isize fs/ext4/inode.c:5930 [inline]
       __ext4_mark_inode_dirty+0x469/0x700 fs/ext4/inode.c:6008
       ext4_evict_inode+0xa81/0x1080 fs/ext4/inode.c:282
       evict+0x485/0x870 fs/inode.c:647
       ext4_orphan_cleanup+0xaa9/0x12e0 fs/ext4/orphan.c:474
       ext4_fill_super+0x92f0/0x9a60 fs/ext4/super.c:4975
       mount_bdev+0x287/0x3c0 fs/super.c:1400
       legacy_get_tree+0xe6/0x180 fs/fs_context.c:611
       vfs_get_tree+0x88/0x270 fs/super.c:1530
       do_new_mount+0x24a/0xa40 fs/namespace.c:3025
       do_mount fs/namespace.c:3368 [inline]
       __do_sys_mount fs/namespace.c:3576 [inline]
       __se_sys_mount+0x2d6/0x3c0 fs/namespace.c:3553
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x66/0xd0

other info that might help us debug this:

Chain exists of:
  &sbi->s_writepages_rwsem --> jbd2_handle --> &ei->xattr_sem

 Possible unsafe locking scenario:

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

 *** DEADLOCK ***

3 locks held by syz.0.17/4321:
 #0: ffff888074f660e0 (&type->s_umount_key#28/1){+.+.}-{3:3}, at: alloc_super+0x201/0x950 fs/super.c:229
 #1: ffff888074f66650 (sb_internal){.+.+}-{0:0}, at: __sb_start_write include/linux/fs.h:1811 [inline]
 #1: ffff888074f66650 (sb_internal){.+.+}-{0:0}, at: sb_start_intwrite include/linux/fs.h:1928 [inline]
 #1: ffff888074f66650 (sb_internal){.+.+}-{0:0}, at: ext4_evict_inode+0x444/0x1080 fs/ext4/inode.c:243
 #2: ffff8880702dbc98 (&ei->xattr_sem){++++}-{3:3}, at: ext4_write_trylock_xattr fs/ext4/xattr.h:162 [inline]
 #2: ffff8880702dbc98 (&ei->xattr_sem){++++}-{3:3}, at: ext4_try_to_expand_extra_isize fs/ext4/inode.c:5927 [inline]
 #2: ffff8880702dbc98 (&ei->xattr_sem){++++}-{3:3}, at: __ext4_mark_inode_dirty+0x3e8/0x700 fs/ext4/inode.c:6008

stack backtrace:
CPU: 1 PID: 4321 Comm: syz.0.17 Not tainted syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2025
Call Trace:
 <TASK>
 dump_stack_lvl+0x168/0x230 lib/dump_stack.c:106
 check_noncircular+0x274/0x310 kernel/locking/lockdep.c:2133
 check_prev_add kernel/locking/lockdep.c:3053 [inline]
 check_prevs_add kernel/locking/lockdep.c:3172 [inline]
 validate_chain kernel/locking/lockdep.c:3788 [inline]
 __lock_acquire+0x2c33/0x7c60 kernel/locking/lockdep.c:5012
 lock_acquire+0x197/0x3f0 kernel/locking/lockdep.c:5623
 percpu_down_read+0x46/0x1b0 include/linux/percpu-rwsem.h:51
 ext4_writepages+0x1c0/0x2d20 fs/ext4/inode.c:2689
 do_writepages+0x48d/0x6d0 mm/page-writeback.c:2386
 __writeback_single_inode+0x153/0xda0 fs/fs-writeback.c:1647
 writeback_single_inode+0x221/0x8b0 fs/fs-writeback.c:1760
 write_inode_now+0x217/0x280 fs/fs-writeback.c:2801
 iput_final fs/inode.c:1756 [inline]
 iput+0x5ab/0x8a0 fs/inode.c:1795
 ext4_xattr_set_entry+0x10ff/0x3d30 fs/ext4/xattr.c:1836
 ext4_xattr_block_set+0x4f7/0x2d30 fs/ext4/xattr.c:1935
 ext4_xattr_move_to_block fs/ext4/xattr.c:2632 [inline]
 ext4_xattr_make_inode_space fs/ext4/xattr.c:2707 [inline]
 ext4_expand_extra_isize_ea+0xf4b/0x19a0 fs/ext4/xattr.c:2799
 __ext4_expand_extra_isize+0x301/0x3e0 fs/ext4/inode.c:5887
 ext4_try_to_expand_extra_isize fs/ext4/inode.c:5930 [inline]
 __ext4_mark_inode_dirty+0x469/0x700 fs/ext4/inode.c:6008
 ext4_evict_inode+0xa81/0x1080 fs/ext4/inode.c:282
 evict+0x485/0x870 fs/inode.c:647
 ext4_orphan_cleanup+0xaa9/0x12e0 fs/ext4/orphan.c:474
 ext4_fill_super+0x92f0/0x9a60 fs/ext4/super.c:4975
 mount_bdev+0x287/0x3c0 fs/super.c:1400
 legacy_get_tree+0xe6/0x180 fs/fs_context.c:611
 vfs_get_tree+0x88/0x270 fs/super.c:1530
 do_new_mount+0x24a/0xa40 fs/namespace.c:3025
 do_mount fs/namespace.c:3368 [inline]
 __do_sys_mount fs/namespace.c:3576 [inline]
 __se_sys_mount+0x2d6/0x3c0 fs/namespace.c:3553
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0
RIP: 0033:0x7f6d6daef34a
Code: d8 64 89 02 48 c7 c0 ff ff ff ff eb a6 e8 de 1a 00 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffe48a08d58 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007ffe48a08de0 RCX: 00007f6d6daef34a
RDX: 0000200000000180 RSI: 00002000000001c0 RDI: 00007ffe48a08da0
RBP: 0000200000000180 R08: 00007ffe48a08de0 R09: 0000000000800700
R10: 0000000000800700 R11: 0000000000000246 R12: 00002000000001c0
R13: 00007ffe48a08da0 R14: 0000000000000473 R15: 0000200000000680
 </TASK>
------------[ cut here ]------------
EA inode 11 i_nlink=2
WARNING: CPU: 0 PID: 4321 at fs/ext4/xattr.c:1021 ext4_xattr_inode_update_ref+0x517/0x570 fs/ext4/xattr.c:1019
Modules linked in:
CPU: 0 PID: 4321 Comm: syz.0.17 Not tainted syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2025
RIP: 0010:ext4_xattr_inode_update_ref+0x517/0x570 fs/ext4/xattr.c:1019
Code: 7b 40 4c 89 f8 48 c1 e8 03 42 80 3c 20 00 74 08 4c 89 ff e8 7b e6 a2 ff 49 8b 37 48 c7 c7 e0 6f 1d 8a 44 89 f2 e8 69 db 84 07 <0f> 0b 48 8b 5c 24 10 4c 8b 7c 24 18 4c 8d 6c 24 60 e9 00 fe ff ff
RSP: 0018:ffffc9000306f140 EFLAGS: 00010246
RAX: a23112d2b70fe600 RBX: ffff888070248c98 RCX: ffff888025851dc0
RDX: 0000000000000000 RSI: 0000000080000000 RDI: 0000000000000000
RBP: ffffc9000306f230 R08: dffffc0000000000 R09: ffffed1017204f24
R10: ffffed1017204f24 R11: 1ffff11017204f23 R12: dffffc0000000000
R13: ffffc9000306f1a0 R14: 0000000000000002 R15: ffff888070248cd8
FS:  000055557bdff500(0000) GS:ffff8880b9000000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f6d64d9d000 CR3: 0000000079dba000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <TASK>
 ext4_xattr_inode_dec_ref fs/ext4/xattr.c:1044 [inline]
 ext4_xattr_set_entry+0xed0/0x3d30 fs/ext4/xattr.c:1696
 ext4_xattr_ibody_set+0x112/0x330 fs/ext4/xattr.c:2252
 ext4_xattr_move_to_block fs/ext4/xattr.c:2639 [inline]
 ext4_xattr_make_inode_space fs/ext4/xattr.c:2707 [inline]
 ext4_expand_extra_isize_ea+0xf9a/0x19a0 fs/ext4/xattr.c:2799
 __ext4_expand_extra_isize+0x301/0x3e0 fs/ext4/inode.c:5887
 ext4_try_to_expand_extra_isize fs/ext4/inode.c:5930 [inline]
 __ext4_mark_inode_dirty+0x469/0x700 fs/ext4/inode.c:6008
 ext4_evict_inode+0xa81/0x1080 fs/ext4/inode.c:282
 evict+0x485/0x870 fs/inode.c:647
 ext4_orphan_cleanup+0xaa9/0x12e0 fs/ext4/orphan.c:474
 ext4_fill_super+0x92f0/0x9a60 fs/ext4/super.c:4975
 mount_bdev+0x287/0x3c0 fs/super.c:1400
 legacy_get_tree+0xe6/0x180 fs/fs_context.c:611
 vfs_get_tree+0x88/0x270 fs/super.c:1530
 do_new_mount+0x24a/0xa40 fs/namespace.c:3025
 do_mount fs/namespace.c:3368 [inline]
 __do_sys_mount fs/namespace.c:3576 [inline]
 __se_sys_mount+0x2d6/0x3c0 fs/namespace.c:3553
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0
RIP: 0033:0x7f6d6daef34a
Code: d8 64 89 02 48 c7 c0 ff ff ff ff eb a6 e8 de 1a 00 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffe48a08d58 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007ffe48a08de0 RCX: 00007f6d6daef34a
RDX: 0000200000000180 RSI: 00002000000001c0 RDI: 00007ffe48a08da0
RBP: 0000200000000180 R08: 00007ffe48a08de0 R09: 0000000000800700
R10: 0000000000800700 R11: 0000000000000246 R12: 00002000000001c0
R13: 00007ffe48a08da0 R14: 0000000000000473 R15: 0000200000000680
 </TASK>

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/09/10 20:44 linux-5.15.y de9476bb4f1b fdeaa69b .config console log report syz / log [disk image] [vmlinux] [kernel image] [mounted in repro (corrupt fs)] ci2-linux-5-15-kasan possible deadlock in ext4_writepages
2025/09/10 19:34 linux-5.15.y de9476bb4f1b fdeaa69b .config console log report syz / log [disk image] [vmlinux] [kernel image] [mounted in repro (corrupt fs)] ci2-linux-5-15-kasan possible deadlock in ext4_writepages
* Struck through repros no longer work on HEAD.