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: 2d21h, last: 1d13h
✨ 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 0xffffea00041fe048 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
 __preempt_count_dec_and_test arch/x86/include/asm/preempt.h:123 [inline]
 __raw_spin_unlock_irqrestore include/linux/spinlock_api_smp.h:211 [inline]
 _raw_spin_unlock_irqrestore+0x1a/0x30 kernel/locking/spinlock.c:221
 __unix_dgram_recvmsg+0x39c/0x920 net/unix/af_unix.c:2620
 unix_dgram_recvmsg+0x7e/0x90 net/unix/af_unix.c:2694
 sock_recvmsg_nosec+0xc2/0xf0 net/socket.c:1154
 ____sys_recvmsg+0x23f/0x250 net/socket.c:2931
 ___sys_recvmsg+0x156/0x3a0 net/socket.c:2978
 do_recvmmsg+0x1e4/0x550 net/socket.c:3073
 __sys_recvmmsg net/socket.c:3147 [inline]
 __do_sys_recvmmsg net/socket.c:3170 [inline]
 __se_sys_recvmmsg net/socket.c:3163 [inline]
 __x64_sys_recvmmsg+0xe5/0x170 net/socket.c:3163
 x64_sys_call+0x77f/0x2550 arch/x86/include/generated/asm/syscalls_64.h:300
 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 0xffffea00041fe048 of 8 bytes by task 19307 on cpu 0:
 list_del include/linux/list.h:276 [inline]
 shrink_folio_list+0x3cc/0x2d70 mm/vmscan.c:1190
 evict_folios+0x1fa4/0x2990 mm/vmscan.c:5097
 try_to_shrink_lruvec+0x9fb/0xd60 mm/vmscan.c:5271
 shrink_one+0x1b4/0x940 mm/vmscan.c:5318
 shrink_many mm/vmscan.c:5381 [inline]
 lru_gen_shrink_node mm/vmscan.c:5459 [inline]
 shrink_node+0x4034/0x4600 mm/vmscan.c:6465
 __node_reclaim+0xf0/0x3e0 mm/vmscan.c:8012
 user_proactive_reclaim+0x595/0x700 mm/vmscan.c:8202
 reclaim_store+0x4a/0x70 mm/vmscan.c:8268
 dev_attr_store+0x4a/0x70 drivers/base/core.c:2509
 sysfs_kf_write+0xfe/0x120 fs/sysfs/file.c:145
 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: 19307 Comm: syz.3.4152 Not tainted syzkaller #0 PREEMPT(lazy) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026
==================================================================

Crashes (4):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
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.