WARNING in jbd2_journal_dirty_metadata (4)

Status: upstream: reported C repro on 2026/11/16 08:12
Subsystems: ext4
Labels: prio:high
[Documentation on labels]
Reported-by: syzbot+e8180f5590685cbc9037@syzkaller.appspotmail.com
First crash: 4d03h, last: 7h20m
✨ AI-generated root cause summary:

In ext4 inline data writes, ext4_generic_write_inline_data() starts a transaction handle requesting only 1 credit for dirtying the inode buffer. When inline data is created or expanded, ext4_prepare_inline_data() consumes that sole credit by marking the inode table block (iloc.bh) dirty. If the subsequent userspace copy fails or is truncated (e.g. copying from a NULL/unmapped address), ext4_write_inline_data_end() invokes ext4_orphan_add(handle, inode), which attempts to dirty an orphan file or superblock block using the exhausted handle. jbd2_journal_dirty_metadata() encounters jbd2_handle_buffer_credits(handle) <= 0, warns, and returns -ENOSPC, causing __ext4_handle_dirty_metadata() to abort the journal handle and trigger ext4 filesystem error handling.

▶ ▼ ✨ Full AI root cause analysis
Based on kernel commit 79eb6679ef6a:

Root Cause Analysis

1. Context and Problem Statement

When performing a buffered write to an ext4 inode with inline data enabled (EXT4_STATE_MAY_INLINE_DATA), the write path begins in generic_perform_write(), which invokes a_ops->write_begin() (ext4_da_write_begin() or ext4_write_begin()) followed by a_ops->write_end() (ext4_da_write_end() or ext4_write_end()).

For inline data writes:

  • ext4_try_to_write_inline_data() or ext4_da_write_begin() delegates to ext4_generic_write_inline_data() (fs/ext4/inline.c:695).
  • ext4_generic_write_inline_data() starts a journal transaction handle:
    handle = ext4_journal_start(inode, EXT4_HT_INODE, 1);
    
    It requests only 1 transaction credit (nblocks = 1).

2. Credit Consumption During Inline Data Preparation

Immediately after starting the handle, ext4_generic_write_inline_data() calls:

ret = ext4_prepare_inline_data(handle, inode, pos + len);

In ext4_prepare_inline_data() (fs/ext4/inline.c:406), if the inline data entry needs to be created or expanded to accommodate pos + len, it calls ext4_create_inline_data() or ext4_update_inline_data(). Both functions modify the inode and call:

error = ext4_mark_iloc_dirty(handle, inode, &is.iloc);

ext4_mark_iloc_dirty() calls ext4_handle_dirty_metadata(handle, inode, iloc->bh) -> jbd2_journal_dirty_metadata(handle, bh). Because iloc.bh (the inode table block) is being modified for the first time in this handle:

if (jh->b_modified == 0) {
    ...
    jh->b_modified = 1;
    handle->h_total_credits--;
}

This consumes the single credit requested at handle start, leaving jbd2_handle_buffer_credits(handle) == 0.

(Note: Even if ext4_prepare_inline_data() did not expand inline storage, if any data is copied in a short write 0 < copied < len, ext4_write_inline_data_end() invokes mark_inode_dirty(inode) -> ext4_dirty_inode(), which joins the existing handle without adding credits and dirties iloc.bh, likewise exhausting the single credit).

3. Short/Failed Userspace Copy Triggers Orphan Addition

In generic_perform_write(), copy_folio_from_iter_atomic() attempts to copy user data. When the userspace buffer is invalid or causes a page fault (as observed in the syzkaller reproducer register state where RSI = 0x0, a NULL pointer, for a write length RDX = 0x15), the copy fails or is truncated (copied == 0 < len).

Next, generic_perform_write() calls a_ops->write_end(), which calls ext4_write_inline_data_end() (fs/ext4/inline.c:793). Because copied < len, inode->i_size is not extended to pos + len, satisfying:

if (pos + len > inode->i_size && ext4_can_truncate(inode))
    ext4_orphan_add(handle, inode);

Unlike regular block writes in ext4_write_begin() (fs/ext4/inode.c:1423-1428), which specifically account for failure by reserving extra credits:

/*
 * Reserve one block more for addition to orphan list in case
 * we allocate blocks but write fails for some reason
 */
needed_blocks = ext4_chunk_trans_extent(inode, ext4_journal_blocks_per_folio(inode)) + 1;

ext4_generic_write_inline_data() only reserved 1 credit.

4. Buffer Credit Underflow in JBD2

ext4_orphan_add() attempts to add the inode to the orphan tracking mechanism:

  • If the orphan_file feature is enabled (sbi->s_orphan_info.of_blocks != 0), it calls ext4_orphan_file_add(handle, inode) (fs/ext4/orphan.c:14), which records the inode in an orphan file block (oi->of_binfo[i].ob_bh) and marks it dirty via ext4_handle_dirty_metadata().
  • If using the traditional superblock orphan list, it marks the superblock buffer (sbi->s_sbh) dirty via ext4_handle_dirty_metadata().

Both orphan paths require dirtying a completely different metadata block from iloc.bh. When ext4_handle_dirty_metadata() calls jbd2_journal_dirty_metadata(handle, bh) (fs/jbd2/transaction.c:1598):

if (jh->b_modified == 0) {
    if (WARN_ON_ONCE(jbd2_handle_buffer_credits(handle) <= 0)) {
        ret = -ENOSPC;
        goto out_unlock_bh;
    }
    ...
}

Because jbd2_handle_buffer_credits(handle) is 0, the WARN_ON_ONCE triggers, and -ENOSPC is returned. In __ext4_handle_dirty_metadata() (fs/ext4/ext4_jbd2.c:394-396), receiving this error causes the journal handle to be aborted (ext4_journal_abort_handle()) and reports a filesystem error via ext4_error_inode().

▶ ▼ ✨ AI Jobs (1)
ID Workflow Result Correct Bug Created Started Finished Revision
3906b50e assessment-security DenialOfService: ✅ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ✅ UserNamespace: ✅ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ WARNING in jbd2_journal_dirty_metadata (4) 2026/11/12 07:22 2026/11/12 07:22 2026/11/12 08:01 8d68b303
▶ ▼ Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [ext4?] WARNING in jbd2_journal_dirty_metadata (4) 0 (1) 2026/11/16 08:12
▶ ▼ Similar bugs (3)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream WARNING in jbd2_journal_dirty_metadata (2) ext4 -1 58 290d 535d 0/29 auto-obsoleted due to no activity on 2026/04/10 03:13
upstream WARNING in jbd2_journal_dirty_metadata ext4 -1 49 629d 797d 0/29 auto-obsoleted due to no activity on 2025/05/05 22:21
upstream WARNING in jbd2_journal_dirty_metadata (3) prio:high ext4 -1 21 102d 207d 0/29 auto-obsoleted due to no activity on 2026/10/20 03:48

Sample crash report:
EXT4-fs (loop0): mounted filesystem 104feaea-39f8-49fa-9fe9-3052f307e139 r/w with ordered data mode. Quota mode: journalled.
------------[ cut here ]------------
jbd2_handle_buffer_credits(handle) <= 0
WARNING: fs/jbd2/transaction.c:1598 at jbd2_journal_dirty_metadata+0xb84/0xef0 fs/jbd2/transaction.c:1598, CPU#0: syz-executor284/5618
Modules linked in:
CPU: 0 UID: 0 PID: 5618 Comm: syz-executor284 Not tainted syzkaller #0 PREEMPT_{RT,(full)} 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026
RIP: 0010:jbd2_journal_dirty_metadata+0xb84/0xef0 fs/jbd2/transaction.c:1598
Code: 39 03 00 00 45 8b 06 48 c7 c7 a0 bf a7 8b 89 ee 89 da 4c 89 f9 e8 bc 6f 80 fe b8 ea ff ff ff e9 40 fd ff ff e8 dd f5 20 ff 90 <0f> 0b 90 b8 e4 ff ff ff e9 2d fd ff ff 44 89 e1 80 e1 07 38 c1 0f
RSP: 0018:ffffc90004a5f0f8 EFLAGS: 00010293
RAX: ffffffff82a6f833 RBX: 1ffff11008908f20 RCX: ffff88804117be80
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
R10: dffffc0000000000 R11: fffffbfff21ab638 R12: dffffc0000000000
R13: ffff888044847908 R14: ffff888044853900 R15: 0000000000000008
FS:  000055558b2f3400(0000) GS:ffff888124709000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000000000046af40 CR3: 000000002ae66000 CR4: 00000000003526f0
Call Trace:
 <TASK>
 __ext4_handle_dirty_metadata+0x198/0x9f0 fs/ext4/ext4_jbd2.c:392
 ext4_quota_write+0x3ca/0x580 fs/ext4/super.c:7503
 qtree_write_dquot+0x244/0x5e0 fs/quota/quota_tree.c:462
 v2_write_dquot+0x183/0x260 fs/quota/quota_v2.c:372
 dquot_commit+0x36e/0x440 fs/quota/dquot.c:540
 ext4_write_dquot+0x20a/0x380 fs/ext4/super.c:7096
 mark_dquot_dirty fs/quota/dquot.c:398 [inline]
 mark_all_dquot_dirty+0x1fe/0x460 fs/quota/dquot.c:438
 __dquot_free_space+0x817/0xc00 fs/quota/dquot.c:1901
 dquot_free_space_nodirty include/linux/quotaops.h:372 [inline]
 dquot_free_space+0x1b/0x30 include/linux/quotaops.h:377
 swap_inode_boot_loader+0xbe6/0x1070 fs/ext4/ioctl.c:503
 __ext4_ioctl fs/ext4/ioctl.c:1731 [inline]
 ext4_ioctl+0x2379/0x4b70 fs/ext4/ioctl.c:1932
 vfs_ioctl fs/ioctl.c:52 [inline]
 __do_sys_ioctl fs/ioctl.c:598 [inline]
 __se_sys_ioctl+0xff/0x170 fs/ioctl.c:584
 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
 do_syscall_64+0x171/0x540 arch/x86/entry/syscall_64.c:89
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f163c16d949
Code: c0 79 93 eb d5 48 8d 7c 1d 00 eb 99 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 d8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffe5b174698 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0031656c69662f2e RCX: 00007f163c16d949
RDX: 0000000000000000 RSI: 0000000000006611 RDI: 0000000000000004
RBP: 0000000000000001 R08: 000055558b2f4560 R09: 000055558b2f4560
R10: 0000000000000000 R11: 0000000000000246 R12: 00007ffe5b1746c0
R13: 0000000000000002 R14: 431bde82d7b634db R15: 00007f163c1cd04b
 </TASK>

Crashes (10):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/11/16 02:34 upstream fa2933aac170 819ebe34 .config strace log report syz / log C [disk image] [vmlinux] [kernel image] [mounted in repro (clean fs)] ci2-upstream-fs WARNING in jbd2_journal_dirty_metadata
2026/11/15 09:18 upstream 23c62304dde2 819ebe34 .config strace log report syz / log C [disk image] [vmlinux] [kernel image] [mounted in repro (clean fs)] ci2-upstream-fs WARNING in jbd2_journal_dirty_metadata
2026/11/12 09:52 upstream 79eb6679ef6a 8d68b303 .config console log report syz / log C [disk image (non-bootable)] [vmlinux] [kernel image] [mounted in repro #1 (clean fs)] [mounted in repro #2] ci-snapshot-upstream-root WARNING in jbd2_journal_dirty_metadata
2026/11/12 08:35 upstream 79eb6679ef6a 8d68b303 .config console log report syz / log C [disk image (non-bootable)] [vmlinux] [kernel image] [mounted in repro (clean fs)] ci-snapshot-upstream-root WARNING in jbd2_journal_dirty_metadata
2026/11/12 06:31 upstream 79eb6679ef6a 8d68b303 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root WARNING in jbd2_journal_dirty_metadata
2026/11/14 10:00 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci ad3fc05c7e65 819ebe34 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 WARNING in jbd2_journal_dirty_metadata
2026/11/14 10:00 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci ad3fc05c7e65 819ebe34 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 WARNING in jbd2_journal_dirty_metadata
2026/11/13 14:06 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 18f2d01bfce9 be5d1971 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 WARNING in jbd2_journal_dirty_metadata
2026/11/13 14:06 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 18f2d01bfce9 be5d1971 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 WARNING in jbd2_journal_dirty_metadata
2026/11/13 02:51 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 18f2d01bfce9 26b2fee0 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 WARNING in jbd2_journal_dirty_metadata
* Struck through repros no longer work on HEAD.