WARNING in iomap_release_folio

Status: moderation: reported on 2026/11/22 20:23
Subsystems: iomap
Labels: prio:low
[Documentation on labels]
Reported-by: syzbot+054bf712a392cd265831@syzkaller.appspotmail.com
First crash: 1h51m, last: 1h51m
✨ AI-generated root cause summary:

ntfs3 registers iomap folio lifecycle callbacks (iomap_dirty_folio and iomap_release_folio) on ntfs_aops and ntfs_aops_cmpr, which attach a per-block struct iomap_folio_state (ifs) to folios whenever i_blocks_per_folio(inode, folio) > 1 (such as when NTFS cluster size is smaller than PAGE_SIZE). However, ntfs_read_folio() in fs/ntfs3/inode.c directly calls folio_mark_uptodate(folio) instead of iomap_folio_mark_uptodate(folio) when ni->i_valid <= vbo (and the same pattern appears in ni_read_folio_cmpr, ntfs_compress_write, and attr_make_nonresident). If an earlier incomplete or aborted iomap write/zero-range operation left ifs attached to an !uptodate folio, folio_mark_uptodate() sets PG_uptodate without updating the ifs->state uptodate bitmap. When kswapd later reclaims the clean folio via iomap_release_folio() -> ifs_free(), ifs_is_fully_uptodate(folio, ifs) != folio_test_uptodate(folio) triggers the WARN_ON_ONCE.

▶ ▼ ✨ Full AI root cause analysis
Based on kernel commit 4843f6873f7c:

Root Cause Analysis

The warning in ifs_free() (fs/iomap/buffered-io.c:294-295):

WARN_ON_ONCE(ifs_is_fully_uptodate(folio, ifs) !=
             folio_test_uptodate(folio));

enforces the invariant that whenever a struct iomap_folio_state (ifs) is attached to folio->private, the per-block uptodate bitmap (ifs->state[0 .. nr_blocks - 1]) is all-1s (ifs_is_fully_uptodate(folio, ifs)) if and only if the folio's PG_uptodate flag (folio_test_uptodate(folio)) is set.

Violating Paths in fs/ntfs3/

ntfs3 uses iomap folio state management on both regular and compressed file mappings (ntfs_aops and ntfs_aops_cmpr in fs/ntfs3/inode.c):

  • .dirty_folio = iomap_dirty_folio
  • .release_folio = iomap_release_folio
  • .invalidate_folio = iomap_invalidate_folio

In ntfs_init_from_boot() (fs/ntfs3/super.c:1244), sb_set_blocksize(sb, min_t(u32, sbi->cluster_size, PAGE_SIZE)) sets sb->s_blocksize_bits (inherited by inode->i_blkbits) to less than PAGE_SHIFT whenever the NTFS cluster size is smaller than PAGE_SIZE (e.g., 512, 1024, or 2048 bytes), and large folios also produce i_blocks_per_folio(inode, folio) > 1. Consequently, ifs_alloc() allocates and attaches an ifs structure to folio->private during iomap operations (__iomap_write_begin(), iomap_dirty_folio(), iomap_read_folio_iter(), etc.).

However, ntfs3 bypasses iomap_folio_mark_uptodate() (fs/iomap/buffered-io.c:110-114) and calls raw folio_mark_uptodate(folio) directly in several places:

  1. ntfs_read_folio() in fs/ntfs3/inode.c:850-855 (primary trigger):

    if (ni->i_valid <= vbo) {
        folio_zero_range(folio, 0, folio_size(folio));
        folio_mark_uptodate(folio);
        folio_unlock(folio);
        return 0;
    }
    

    When reading a folio at or beyond ni->i_valid, ntfs_read_folio() zeroes the folio and calls folio_mark_uptodate(folio) instead of iomap_folio_mark_uptodate(folio).

  2. Additional occurrences in ntfs3 with the same pattern:

    • ni_read_folio_cmpr() in fs/ntfs3/frecord.c:1945: calls folio_mark_uptodate(folio) when vbo >= i_size_read(&ni->vfs_inode) on ntfs_aops_cmpr.
    • ntfs_compress_write() in fs/ntfs3/file.c:1175: calls folio_mark_uptodate(folio) on ntfs_aops_cmpr.
    • attr_make_nonresident() in fs/ntfs3/attrib.c:338: calls folio_mark_uptodate(folio) before folio_mark_dirty(folio) (which invokes iomap_dirty_folio()).

Trigger Sequence

  1. An NTFS filesystem with sbi->cluster_size < PAGE_SIZE (or a large folio) gives i_blocks_per_folio(inode, folio) > 1.
  2. An iomap operation (ntfs_file_write_iter() -> iomap_file_buffered_write() or ntfs_extend_initialized_size() -> iomap_zero_range()) invokes __iomap_write_begin() -> ifs_alloc(inode, folio, 0) on a folio at vbo >= ni->i_valid. Because !folio_test_uptodate(folio), ifs is attached to folio->private with all uptodate bits in ifs->state cleared (0).
  3. If that operation stops short or aborts before completing the whole folio (e.g., an EFAULT/short copy in copy_folio_from_iter_atomic(), or a partial-folio write where __iomap_write_end() does not mark all blocks uptodate), the clean folio remains in the page cache with ifs attached, folio_test_uptodate(folio) == false, and ifs_is_fully_uptodate(folio, ifs) == false.
  4. A subsequent read on that folio enters ntfs_read_folio(). Since ni->i_valid <= vbo, it executes folio_zero_range(folio, 0, folio_size(folio)) followed by folio_mark_uptodate(folio). This sets PG_uptodate on folio without updating ifs->state, leaving folio_test_uptodate(folio) == true while ifs_is_fully_uptodate(folio, ifs) == false.
  5. Later, during memory reclaim, kswapd0 calls shrink_folio_list() -> iomap_release_folio() -> ifs_free() (fs/iomap/buffered-io.c:286-297), where ifs_is_fully_uptodate(folio, ifs) != folio_test_uptodate(folio) triggers the WARN_ON_ONCE at fs/iomap/buffered-io.c:294-295.

(Other filesystems using iomap_release_folio()—erofs, exfat, ext4, fuse, gfs2, xfs, and zonefs—as well as fs/iomap/buffered-io.c itself were audited and do not exhibit this desynchronization; e.g. fuse properly uses iomap_folio_mark_uptodate() and stores server blksize in fi->cached_i_blkbits rather than mutating inode->i_blkbits.)

Suggested Fix Direction

Replace direct folio_mark_uptodate(folio) calls on ntfs3 iomap-managed folios (at minimum ntfs_read_folio() in fs/ntfs3/inode.c:852, as well as fs/ntfs3/frecord.c:1945, fs/ntfs3/file.c:1175, and fs/ntfs3/attrib.c:338) with iomap_folio_mark_uptodate(folio) so ifs->state is updated consistently with PG_uptodate whenever ifs is attached.

▶ ▼ ✨ AI Jobs (2)
ID Workflow Result Correct Bug Created Started Finished Revision
85d9b281 assessment-security DenialOfService: ❌ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ❌ UserNamespace: ❌ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ WARNING in iomap_release_folio 2026/11/22 18:55 2026/11/22 18:55 2026/11/22 20:23 b2c69459
9da9f3c1 bisect-cause 💥 WARNING in iomap_release_folio 2026/11/22 18:55 2026/11/22 18:55 2026/11/22 20:16 b2c69459

Sample crash report:
------------[ cut here ]------------
ifs_is_fully_uptodate(folio, ifs) != folio_test_uptodate(folio)
WARNING: fs/iomap/buffered-io.c:295 at ifs_free+0x22d/0x2c0 fs/iomap/buffered-io.c:294, CPU#0: kswapd0/84
Modules linked in:
CPU: 0 UID: 0 PID: 84 Comm: kswapd0 Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
RIP: 0010:ifs_free+0x22d/0x2c0 fs/iomap/buffered-io.c:294
Code: 41 5f 5d e9 55 0a bb ff e8 30 8e 4d ff 90 0f 0b 90 e9 0a ff ff ff e8 22 8e 4d ff 90 0f 0b 90 e9 3a ff ff ff e8 14 8e 4d ff 90 <0f> 0b 90 eb c7 44 89 f9 80 e1 07 80 c1 03 38 c1 0f 8c 3d fe ff ff
RSP: 0018:ffffc90000ed67e0 EFLAGS: 00010293
RAX: ffffffff827bbe6c RBX: ffff88803922d400 RCX: ffff8880338a8000
RDX: 0000000000000000 RSI: 0000000000000008 RDI: 0000000000000000
RBP: 00000000827c3c01 R08: ffffea0000538607 R09: 1ffffd40000a70c0
R10: dffffc0000000000 R11: fffff940000a70c1 R12: dffffc0000000000
R13: 1ffffd40000a70c5 R14: 0000000000000008 R15: 0000000000000000
FS:  0000000000000000(0000) GS:ffff88808a9ea000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fb6145bafe8 CR3: 000000004527b000 CR4: 0000000000352ef0
Call Trace:
 <TASK>
 iomap_release_folio+0x254/0x450 fs/iomap/buffered-io.c:826
 shrink_folio_list+0x22e2/0x4d90 mm/vmscan.c:1569
 evict_folios+0x3326/0x4390 mm/vmscan.c:5097
 try_to_shrink_lruvec+0xf22/0x1630 mm/vmscan.c:5271
 shrink_one+0x312/0x10f0 mm/vmscan.c:5318
 shrink_many mm/vmscan.c:5381 [inline]
 lru_gen_shrink_node mm/vmscan.c:5459 [inline]
 shrink_node+0x631e/0x6c50 mm/vmscan.c:6465
 kswapd_shrink_node mm/vmscan.c:7258 [inline]
 balance_pgdat mm/vmscan.c:7429 [inline]
 kswapd+0x1ff4/0x3a20 mm/vmscan.c:7705
 kthread+0x38b/0x480 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 (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/11/22 18:55 upstream 4843f6873f7c b2c69459 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root WARNING in iomap_release_folio
* Struck through repros no longer work on HEAD.