WARNING in ext4_do_writepages

Status: upstream: reported C repro on 2026/10/30 16:29
Subsystems: ext4
Labels: prio:low
[Documentation on labels]
Reported-by: syzbot+97fbc97fdd4e4fa2ed3a@syzkaller.appspotmail.com
First crash: 4d01h, last: 12h28m
Cause bisection: failed (error log, bisect log)
  
✨ AI-generated root cause summary:
In ext4 writeback (mpage_map_one_extent), a WARN_ON_ONCE(!err) is hit because ext4_map_blocks() returns 0 (indicating a hole) for an extent that was queued for writeback by mpage_add_bh_to_extent(). This occurs when a buffer head remains marked mapped, dirty, and delayed/unwritten (for example, during file truncation down via ftruncate/ext4_block_zero_eof or direct I/O fallback paths), while the extent status tree or on-disk extent mapping for the logical block is or becomes a hole. When ext4_map_blocks() is called with EXT4_GET_BLOCKS_IO_SUBMIT, it avoids allocating blocks for holes and returns 0, triggering the warning and returning -EINVAL. In production kernels, the warning does not halt execution and error recovery safely invalidates the page without causing memory corruption, information leaks, or denial of service.
▶ ▼ ✨ Full AI root cause analysis
Based on kernel commit 6b4b543fa187:
### Root Cause Analysis #### 1. Functions, Structs, and Files Involved - **`fs/ext4/inode.c`**: - `mpage_map_one_extent()`: Maps delayed/unwritten extents during writeback. Hits `WARN_ON_ONCE(!err)` at line 2512 when `ext4_map_blocks()` returns `0`. - `mpage_add_bh_to_extent()`: Inspects page buffer heads and queues logical blocks into `mpd->map` when `buffer_dirty(bh) && buffer_mapped(bh) && (buffer_delay(bh) || buffer_unwritten(bh))`. - `ext4_map_blocks()`: Maps/allocates blocks. When invoked with `EXT4_GET_BLOCKS_IO_SUBMIT`, it explicitly avoids creating blocks if the extent status tree or disk query encounters a hole (`retval == 0` and `!map->m_flags`), returning `0`. - `ext4_block_zero_eof()` / `ext4_block_do_zero_range()` / `ext4_load_tail_bh()`: Executed during truncation (`ext4_truncate()`) to zero the tail of the block straddling `i_size`. #### 2. Trigger and Invariant Violation During delayed allocation writeback (`ext4_do_writepages()` via `wb_workfn`): 1. `mpage_process_page_bufs()` iterates over page buffers within file limits (`lblk < blocks`) and invokes `mpage_add_bh_to_extent()`. 2. An invariant assumed by the writeback code is that any buffer head added to `mpd->map` (due to possessing `BH_Dirty`, `BH_Mapped`, and either `BH_Delay` or `BH_Unwritten`) corresponds to a valid delayed or unwritten extent in the extent tree or disk inode. Consequently, `ext4_map_blocks()` called with `EXT4_GET_BLOCKS_CREATE | EXT4_GET_BLOCKS_IO_SUBMIT` is expected to return `> 0` (the number of blocks mapped/allocated) or `< 0` (an error like `-ENOSPC`). 3. In the reproducer sequence (`open(O_DIRECT)` -> `sendfile` -> `open` -> `ftruncate(7)`), a state discrepancy occurs between the page cache buffer head state and the extent status tree / on-disk block state. Specifically, the buffer head for block 0 is marked dirty, mapped, and delayed/unwritten (or re-dirtied during EOF zeroing by `ext4_block_zero_eof()` -> `ext4_block_do_zero_range()` -> `mark_buffer_dirty(bh)`), while the extent status tree or on-disk lookup reports that the block is a hole (`!map->m_flags` and `retval == 0`). 4. In `ext4_map_blocks()`: ```c } else if (retval == 0) { /* * Do not allocate blocks for holes in the context of * data submission path. */ if (!map->m_flags && (flags & EXT4_GET_BLOCKS_IO_SUBMIT)) goto out; } ``` Because `flags` includes `EXT4_GET_BLOCKS_IO_SUBMIT`, `ext4_map_blocks()` returns `0`. 5. `mpage_map_one_extent()` treats `0` as an unexpected condition and triggers: ```c if (WARN_ON_ONCE(!err)) return -EINVAL; ``` #### 3. Runtime Consequences in Production - **Memory Corruption (`false`)**: No invalid pointers, use-after-free, double-free, or out-of-bounds writes occur. - **Information Leak (`none`)**: No kernel data or pointers are exposed to userspace or the network. - **Denial of Service (`false`)**: In production kernels without `CONFIG_PANIC_ON_WARN`, `WARN_ON_ONCE(!err)` logs a warning and returns `-EINVAL`. In `mpage_map_and_submit_extent()`, the error is caught, the failure is logged (`Delayed block allocation failed for inode...`), and dirty pages are invalidated via `invalidate_dirty_pages`. Normal error recovery completes without a hang, deadlock, resource leak, or system crash. - **Virtualization / Network Candidates (`false`)**: The defect is purely in the ext4 filesystem writeback / page cache subsystem.
▶ ▼ ✨ AI Jobs (1)
ID Workflow Result Correct Bug Created Started Finished Revision
c9ac438e assessment-security DenialOfService: ❌ Exploitable: ❌ FilesystemTrigger: ✅ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ❌ UserNamespace: ❌ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ WARNING in ext4_do_writepages 2026/10/27 01:36 2026/10/27 01:36 2026/10/27 02:51 168cb7a2
▶ ▼ Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [ext4?] WARNING in ext4_do_writepages 0 (1) 2026/10/30 16:29

Sample crash report:
------------[ cut here ]------------
!err
WARNING: fs/ext4/inode.c:2512 at mpage_map_one_extent fs/ext4/inode.c:2512 [inline], CPU#1: kworker/u8:5/72
WARNING: fs/ext4/inode.c:2512 at mpage_map_and_submit_extent fs/ext4/inode.c:2601 [inline], CPU#1: kworker/u8:5/72
WARNING: fs/ext4/inode.c:2512 at ext4_do_writepages+0x33b6/0x44b0 fs/ext4/inode.c:3077, CPU#1: kworker/u8:5/72
Modules linked in:
CPU: 1 UID: 0 PID: 72 Comm: kworker/u8:5 Not tainted syzkaller #0 PREEMPT_{RT,(full)} 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/16/2026
Workqueue: writeback wb_workfn (flush-7:0)
RIP: 0010:mpage_map_one_extent fs/ext4/inode.c:2512 [inline]
RIP: 0010:mpage_map_and_submit_extent fs/ext4/inode.c:2601 [inline]
RIP: 0010:ext4_do_writepages+0x33b6/0x44b0 fs/ext4/inode.c:3077
Code: 0f 0b 90 e9 b6 d9 ff ff e8 c7 d4 38 ff 90 0f 0b 90 e9 e6 dc ff ff e8 b9 d4 38 ff 90 0f 0b 90 e9 94 df ff ff e8 ab d4 38 ff 90 <0f> 0b 90 bb ea ff ff ff e9 ae f8 ff ff e8 98 d4 38 ff 48 8d 3d 11
RSP: 0018:ffffc9000158ec60 EFLAGS: 00010293
RAX: ffffffff828f01e5 RBX: 0000000000000000 RCX: ffff88801eb7ddc0
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: ffffc9000158f070 R08: 0000000000000000 R09: 0000000000000000
R10: dffffc0000000000 R11: ffffed10054fc8bc R12: ffffc9000158f120
R13: dffffc0000000000 R14: 0000000000000000 R15: 1ffff110054fc8d1
FS:  0000000000000000(0000) GS:ffff888124834000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f6c27e15b20 CR3: 0000000032ea4000 CR4: 00000000003526f0
Call Trace:
 <TASK>
 ext4_writepages+0x1fe/0x4e0 fs/ext4/inode.c:3171
 do_writepages+0x338/0x560 mm/page-writeback.c:2560
 __writeback_single_inode+0x136/0x1230 fs/fs-writeback.c:1800
 writeback_sb_inodes+0x9db/0x1aa0 fs/fs-writeback.c:2111
 __writeback_inodes_wb+0x114/0x240 fs/fs-writeback.c:2187
 wb_writeback+0x42f/0xad0 fs/fs-writeback.c:2298
 wb_check_old_data_flush fs/fs-writeback.c:2402 [inline]
 wb_do_writeback fs/fs-writeback.c:2481 [inline]
 wb_workfn+0xc98/0x10f0 fs/fs-writeback.c:2509
 process_one_work kernel/workqueue.c:3495 [inline]
 process_scheduled_works+0xc3d/0x1630 kernel/workqueue.c:3578
 worker_thread+0xa47/0xfb0 kernel/workqueue.c:3659
 kthread+0x38b/0x470 kernel/kthread.c:436
 ret_from_fork+0x514/0xb70 arch/x86/kernel/process.c:158
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
 </TASK>

Crashes (16):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/10/27 00:12 upstream 6b4b543fa187 168cb7a2 .config strace log report syz / log C [disk image] [vmlinux] [kernel image] [mounted in repro (corrupt fs)] ci2-upstream-fs WARNING in ext4_do_writepages
2026/10/30 05:34 upstream 4dd16e31135e b498adee .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root WARNING in ext4_do_writepages
2026/10/29 12:42 upstream c339f4010dea b1d00f76 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs WARNING in ext4_do_writepages
2026/10/28 21:47 upstream 65ba8f34ec88 858db2ec .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root WARNING in ext4_do_writepages
2026/10/28 18:57 upstream 65ba8f34ec88 858db2ec .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs WARNING in ext4_do_writepages
2026/10/28 16:45 upstream 65ba8f34ec88 858db2ec .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs WARNING in ext4_do_writepages
2026/10/28 13:57 upstream 65ba8f34ec88 858db2ec .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs WARNING in ext4_do_writepages
2026/10/28 11:13 upstream 65ba8f34ec88 858db2ec .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs WARNING in ext4_do_writepages
2026/10/28 03:37 upstream 62c457528529 96923c60 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs WARNING in ext4_do_writepages
2026/10/28 02:11 upstream 62c457528529 96923c60 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs WARNING in ext4_do_writepages
2026/10/28 00:56 upstream 62c457528529 96923c60 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs WARNING in ext4_do_writepages
2026/10/27 08:18 upstream d135ab453a74 168cb7a2 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs WARNING in ext4_do_writepages
2026/10/27 08:17 upstream d135ab453a74 168cb7a2 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs WARNING in ext4_do_writepages
2026/10/26 20:37 upstream 6b4b543fa187 168cb7a2 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs WARNING in ext4_do_writepages
2026/10/26 16:24 upstream 6b4b543fa187 168cb7a2 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs WARNING in ext4_do_writepages
2026/10/30 00:01 linux-next a39c95080621 b1d00f76 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root WARNING in ext4_do_writepages
* Struck through repros no longer work on HEAD.