KCSAN: data-race in mpage_end_io / shrink_folio_list

Status: moderation: reported on 2026/11/20 00:06
Subsystems: ext4
Labels: race:benign prio:low
[Documentation on labels]
Reported-by: syzbot+067a2cea20a0c61c3d05@syzkaller.appspotmail.com
First crash: 12d, last: 1h19m
✨ AI-generated root cause summary:

shrink_folio_list() in mm/vmscan.c removes a folio from its isolated local list via list_del(&folio->lru) before attempting folio_trylock(folio), writing LIST_POISON1 to folio->lru.next with a plain store even when the folio is still locked for ongoing read I/O. Concurrently, mpage_end_io() -> __read_end_io() iterates the bio's folios via bio_for_each_folio_all() and calls bvec_folio() -> page_folio() -> _compound_head(), which reads page->compound_info via READ_ONCE(). Because page->compound_info and folio->lru.next share the same 8-byte union slot at offset 8 of struct page / struct folio, KCSAN reports a data race, though it is benign because bit 0 (PageTail()) remains 0 across all list_head and LIST_POISON1 values.

▶ ▼ ✨ Full AI root cause analysis
Based on kernel commit 20eef29b7c84:

Root Cause Analysis

This KCSAN report is triggered by a concurrent access to the aliased 8-byte word at offset 8 of struct page / struct folio (0xffffea00041fe048, corresponding to struct page at 0xffffea00041fe040):

How the race occurs

  1. Folio enters the LRU while read I/O is pending: When a pagecache folio is added for read or readahead (e.g., filemap_add_folio() in mm/filemap.c:969-986), the folio is locked (__folio_set_locked(folio)) and immediately placed on the LRU via folio_add_lru(folio). ext4_mpage_readpages() (fs/ext4/readpage.c:293) then attaches the locked folio to a bio via bio_add_folio() and submits the read request.

  2. Reclaim isolates and manipulates folio->lru without the folio lock (CPU 0): During MGLRU reclaim (evict_folios() -> isolate_folios() -> scan_folios() -> isolate_folio() in mm/vmscan.c:4869), isolate_folio() only checks folio_try_get() and folio_test_clear_lru(); it does not check or acquire PG_locked, so a folio undergoing read I/O can be isolated onto the local list. evict_folios() then calls shrink_folio_list(&list, ...) (mm/vmscan.c:1189-1193), which pops the folio and removes it from the local list before calling folio_trylock(folio):

    folio = lru_to_folio(folio_list);
    list_del(&folio->lru);
    
    if (!folio_trylock(folio))
            goto keep;
    

    list_del(&folio->lru) (include/linux/list.h:276) performs an unmarked 8-byte write entry->next = LIST_POISON1 (0xdead000000000100) to folio->lru.next (0xffffea00041fe048), and after folio_trylock() fails, keep: (mm/vmscan.c:1647) calls list_add(&folio->lru, &ret_folios), writing to folio->lru.next again.

  3. BIO completion reads page->compound_info locklessly (CPU 1): In mpage_end_io() -> __read_end_io() (fs/ext4/readpage.c:65), bio_for_each_folio_all(fi, bio) advances from one bio_vec to the next via bio_next_folio() -> bio_first_folio() (include/linux/bio.h:291,309) -> bvec_folio() (include/linux/bvec.h:89) -> page_folio() -> _compound_head() (include/linux/page-flags.h:221):

    unsigned long info = READ_ONCE(page->compound_info);
    

    Because folio_end_read() has not yet been called on the folio in the next bio_vec, that folio is still locked (PG_locked set), and _compound_head() performs a marked 8-byte READ_ONCE() on page->compound_info (0xffffea00041fe048) concurrently with shrink_folio_list()'s unmarked write in list_del(&folio->lru).

Invariant analysis

As documented in include/linux/mm_types.h:85-87 and include/linux/page-flags.h:289, page_folio() / _compound_head() is explicitly permitted without holding a reference or lock, provided that any other user of the union word never sets bit 0 (PageTail()). Here:

  • folio->lru belongs only to the head page of the folio (&folio->page).
  • Every value stored in folio->lru.nextβ€”aligned struct list_head * pointers and LIST_POISON1 ((void *)0x100 + POISON_POINTER_DELTA)β€”has bit 0 equal to 0.
  • When bit 0 of info is 0, _compound_head() returns (unsigned long)page regardless of the remaining bits (both when compound_info_has_mask() is true, as under CONFIG_VMEMMAP_OPTIMIZATION=y, where mask = (0) - 1 = -1UL, and when it is false).
  • Meanwhile, shrink_folio_list() fails folio_trylock(folio) because the folio is still locked for read I/O, so the folio cannot be freed, split, or otherwise modified by reclaim.

To silence the KCSAN warning, the list_del(&folio->lru) / list_add(&folio->lru, ...) updates in mm/vmscan.c (or the READ_ONCE(page->compound_info) in _compound_head() in include/linux/page-flags.h with data_race() or WRITE_ONCE on the lru side) would need appropriate KCSAN annotations, or shrink_folio_list() would need to avoid modifying folio->lru until after folio_trylock(folio) succeeds (which would require a list_for_each_entry_safe-style traversal or data_race()).

▶ ▼ ✨ AI Jobs (2)
ID Workflow Result Correct Bug Created Started Finished Revision
940f0240 assessment-security DenialOfService: ❌ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: βœ… UserNamespace: βœ… VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ KCSAN: data-race in mpage_end_io / shrink_folio_list 2026/11/19 20:09 2026/11/19 20:09 2026/11/19 20:13 229865fb
eb0cdc01 assessment-kcsan Benign: βœ… ❓ KCSAN: data-race in mpage_end_io / shrink_folio_list 2026/11/19 20:08 2026/11/19 20:08 2026/11/19 20:10 229865fb

Sample crash report:
==================================================================
BUG: KCSAN: data-race in mpage_end_io / shrink_folio_list

read (marked) to 0xffffea000470d188 of 8 bytes by interrupt on cpu 1:
 _compound_head include/linux/page-flags.h:221 [inline]
 bvec_folio include/linux/bvec.h:89 [inline]
 bio_first_folio include/linux/bio.h:291 [inline]
 bio_next_folio include/linux/bio.h:309 [inline]
 __read_end_io fs/ext4/readpage.c:65 [inline]
 mpage_end_io+0x262/0x4a0 fs/ext4/readpage.c:113
 bio_endio+0x3ef/0x5e0 block/bio.c:1908
 blk_update_request+0x365/0x780 block/blk-mq.c:1036
 scsi_end_request+0x48/0x3a0 drivers/scsi/scsi_lib.c:671
 scsi_io_completion+0x7f/0x1d0 drivers/scsi/scsi_lib.c:1125
 scsi_finish_command+0x233/0x250 drivers/scsi/scsi.c:198
 scsi_complete+0x165/0x660 drivers/scsi/scsi_lib.c:1604
 blk_complete_reqs block/blk-mq.c:1242 [inline]
 blk_done_softirq+0x8d/0xc0 block/blk-mq.c:1247
 handle_softirqs+0x109/0x310 kernel/softirq.c:669
 __do_softirq kernel/softirq.c:703 [inline]
 invoke_softirq kernel/softirq.c:542 [inline]
 __irq_exit_rcu+0x40/0xf0 kernel/softirq.c:786
 common_interrupt+0x83/0x90 arch/x86/kernel/irq.c:273
 asm_common_interrupt+0x26/0x40 arch/x86/include/asm/idtentry.h:665
 check_access kernel/kcsan/core.c:796 [inline]
 __tsan_unaligned_write8+0x15d/0x190 kernel/kcsan/core.c:1034
 __tlb_adjust_range include/asm-generic/tlb.h:347 [inline]
 tlb_flush_pte_range include/asm-generic/tlb.h:564 [inline]
 tlb_remove_tlb_entries include/asm-generic/tlb.h:618 [inline]
 zap_present_folio_ptes mm/memory.c:1775 [inline]
 zap_present_ptes mm/memory.c:1839 [inline]
 do_zap_pte_range mm/memory.c:1941 [inline]
 zap_pte_range mm/memory.c:2043 [inline]
 zap_pmd_range mm/memory.c:2134 [inline]
 zap_pud_range mm/memory.c:2162 [inline]
 zap_p4d_range mm/memory.c:2183 [inline]
 __zap_vma_range+0x153a/0x2ea0 mm/memory.c:2223
 unmap_vmas+0x216/0x310 mm/memory.c:2292
 unmap_region+0x11a/0x1b0 mm/vma.c:513
 vms_clear_ptes mm/vma.c:1410 [inline]
 vms_clean_up_area mm/vma.c:1422 [inline]
 __mmap_setup mm/vma.c:2655 [inline]
 __mmap_region mm/vma.c:3099 [inline]
 mmap_region+0xd4f/0x27c0 mm/vma.c:3201
 do_mmap+0xab3/0xd10 mm/mmap.c:573
 vm_mmap_pgoff+0x183/0x320 mm/util.c:581
 ksys_mmap_pgoff+0xc1/0x310 mm/mmap.c:619
 x64_sys_call+0x23b3/0x2550 arch/x86/include/generated/asm/syscalls_64.h:10
 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
 do_syscall_64+0x11e/0x3a0 arch/x86/entry/syscall_64.c:89
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

write to 0xffffea000470d188 of 8 bytes by task 11996 on cpu 0:
 list_del include/linux/list.h:276 [inline]
 shrink_folio_list+0x3cc/0x2e10 mm/vmscan.c:1191
 evict_folios+0x1fa4/0x2990 mm/vmscan.c:5104
 try_to_shrink_lruvec+0x9fb/0xd60 mm/vmscan.c:5278
 lru_gen_shrink_lruvec mm/vmscan.c:5429 [inline]
 shrink_lruvec mm/vmscan.c:6206 [inline]
 shrink_node_memcgs mm/vmscan.c:6445 [inline]
 shrink_node+0x97e/0x4600 mm/vmscan.c:6489
 shrink_zones mm/vmscan.c:6708 [inline]
 do_try_to_free_pages+0x310/0xb80 mm/vmscan.c:6770
 try_to_free_mem_cgroup_pages+0x201/0x450 mm/vmscan.c:7051
 mem_cgroup_force_empty mm/memcontrol-v1.c:1502 [inline]
 mem_cgroup_force_empty_write+0x6b/0x160 mm/memcontrol-v1.c:1518
 cgroup_file_write+0x197/0x350 kernel/cgroup/cgroup.c:4426
 kernfs_fop_write_iter+0x1d2/0x2e0 fs/kernfs/file.c:345
 new_sync_write fs/read_write.c:575 [inline]
 vfs_write+0x57a/0x9b0 fs/read_write.c:667
 ksys_write+0xdc/0x1a0 fs/read_write.c:719
 __do_sys_write fs/read_write.c:730 [inline]
 __se_sys_write fs/read_write.c:727 [inline]
 __x64_sys_write+0x40/0x50 fs/read_write.c:727
 x64_sys_call+0x154e/0x2550 arch/x86/include/generated/asm/syscalls_64.h:2
 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
 do_syscall_64+0x11e/0x3a0 arch/x86/entry/syscall_64.c:89
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Reported by Kernel Concurrency Sanitizer on:
CPU: 0 UID: 0 PID: 11996 Comm: syz.1.2402 Not tainted syzkaller #0 PREEMPT(lazy) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026
==================================================================

Crashes (8):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/11/29 06:38 upstream 946d9ed1aa02 e1f06033 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in mpage_end_io / shrink_folio_list
2026/11/23 15:17 upstream b6a9fa34ce41 e9bfbe3a .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in mpage_end_io / shrink_folio_list
2026/11/20 23:55 upstream d0f871bfb831 b2c69459 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in mpage_end_io / shrink_folio_list
2026/11/20 19:40 upstream 65e4fd942f72 625aa117 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in mpage_end_io / shrink_folio_list
2026/11/18 10:54 upstream 20eef29b7c84 eb4895d7 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in mpage_end_io / shrink_folio_list
2026/11/17 17:39 upstream 666539eecdf4 122f94d5 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in mpage_end_io / shrink_folio_list
2026/11/17 10:30 upstream 666539eecdf4 43af6cac .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in mpage_end_io / shrink_folio_list
2026/11/17 03:30 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in mpage_end_io / shrink_folio_list
* Struck through repros no longer work on HEAD.