[v5.15] possible deadlock in ext4_writepages (2)

0 views
Skip to first unread message

syzbot

unread,
Sep 10, 2025, 3:34:32 PM (3 days ago) Sep 10
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: de9476bb4f1b Linux 5.15.192
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=12f96642580000
kernel config: https://syzkaller.appspot.com/x/.config?x=4aee9f779ad20a6a
dashboard link: https://syzkaller.appspot.com/bug?extid=4e957072bdc454795418
compiler: Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=17507d62580000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/f98a0d0b1f65/disk-de9476bb.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/690c073325bd/vmlinux-de9476bb.xz
kernel image: https://storage.googleapis.com/syzbot-assets/771a90764b1a/bzImage-de9476bb.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/bf416151ebd7/mount_0.gz
fsck result: failed (log: https://syzkaller.appspot.com/x/fsck.log?x=173c2b12580000)

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+4e9570...@syzkaller.appspotmail.com

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

but task is already holding lock:
ffff88805c0a94b8 (&ei->xattr_sem){++++}-{3:3}, at: ext4_write_trylock_xattr fs/ext4/xattr.h:162 [inline]
ffff88805c0a94b8 (&ei->xattr_sem){++++}-{3:3}, at: ext4_try_to_expand_extra_isize fs/ext4/inode.c:5927 [inline]
ffff88805c0a94b8 (&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/4339:
#0: ffff88801e6180e0 (&type->s_umount_key#28/1){+.+.}-{3:3}, at: alloc_super+0x201/0x950 fs/super.c:229
#1: ffff88801e618650 (sb_internal){.+.+}-{0:0}, at: __sb_start_write include/linux/fs.h:1811 [inline]
#1: ffff88801e618650 (sb_internal){.+.+}-{0:0}, at: sb_start_intwrite include/linux/fs.h:1928 [inline]
#1: ffff88801e618650 (sb_internal){.+.+}-{0:0}, at: ext4_evict_inode+0x444/0x1080 fs/ext4/inode.c:243
#2: ffff88805c0a94b8 (&ei->xattr_sem){++++}-{3:3}, at: ext4_write_trylock_xattr fs/ext4/xattr.h:162 [inline]
#2: ffff88805c0a94b8 (&ei->xattr_sem){++++}-{3:3}, at: ext4_try_to_expand_extra_isize fs/ext4/inode.c:5927 [inline]
#2: ffff88805c0a94b8 (&ei->xattr_sem){++++}-{3:3}, at: __ext4_mark_inode_dirty+0x3e8/0x700 fs/ext4/inode.c:6008

stack backtrace:
CPU: 1 PID: 4339 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:0x7fd2d522634a
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:00007ffdd66b3a48 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007ffdd66b3ad0 RCX: 00007fd2d522634a
RDX: 0000200000000180 RSI: 00002000000001c0 RDI: 00007ffdd66b3a90
RBP: 0000200000000180 R08: 00007ffdd66b3ad0 R09: 0000000000800700
R10: 0000000000800700 R11: 0000000000000246 R12: 00002000000001c0
R13: 00007ffdd66b3a90 R14: 0000000000000473 R15: 0000200000000680
</TASK>
------------[ cut here ]------------
EA inode 11 i_nlink=2
WARNING: CPU: 0 PID: 4339 at fs/ext4/xattr.c:1021 ext4_xattr_inode_update_ref+0x517/0x570 fs/ext4/xattr.c:1019
Modules linked in:
CPU: 0 PID: 4339 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:ffffc900042bf140 EFLAGS: 00010246
RAX: a0497ad828b91e00 RBX: ffff888068a2c868 RCX: ffff8880288f0000
RDX: 0000000000000000 RSI: 0000000080000000 RDI: 0000000000000000
RBP: ffffc900042bf230 R08: dffffc0000000000 R09: ffffed1017204f24
R10: ffffed1017204f24 R11: 1ffff11017204f23 R12: dffffc0000000000
R13: ffffc900042bf1a0 R14: 0000000000000002 R15: ffff888068a2c8a8
FS: 0000555590bb9500(0000) GS:ffff8880b9000000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f12f1e05000 CR3: 000000001f66a000 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:0x7fd2d522634a
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:00007ffdd66b3a48 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007ffdd66b3ad0 RCX: 00007fd2d522634a
RDX: 0000200000000180 RSI: 00002000000001c0 RDI: 00007ffdd66b3a90
RBP: 0000200000000180 R08: 00007ffdd66b3ad0 R09: 0000000000800700
R10: 0000000000800700 R11: 0000000000000246 R12: 00002000000001c0
R13: 00007ffdd66b3a90 R14: 0000000000000473 R15: 0000200000000680
</TASK>


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup
Reply all
Reply to author
Forward
0 new messages