CVE-2026-98844: netfs: clear post-EOF pagecache when extending a file via write
In the Linux kernel, the following vulnerability has been resolved:
netfs: clear post-EOF pagecache when extending a file via write
Fix netfs to erase the contents of a hole created after the EOF by an ordinary write if dirty data has been previously left there by writes through an mmapped region. Neither the buffered nor the unbuffered/DIO write path clears that stale pagecache.
Zero the tail of the folio straddling the EOF before an extending write. That is the only folio that can hold data written past the EOF through an mmap, as pages wholly beyond the EOF can't be faulted in. The folio is zeroed rather than dropped so a concurrent extending write can't lose data.
Both write paths downgrade the irwsem to shared, so extending writes can run concurrently and the isize read by the caller may be stale by the time the folio is locked. Re-read isize under the folio lock and clamp the zeroed range up to it, so a racing write that already put data into the folio isn't clobbered.
Wait for any writeback on the folio to finish before zeroing it so that the pagecache isn't modified while it may still be read by the transport during transmission. Honour IOCBNOWAIT by returning -EAGAIN rather than blocking on the folio lock, on writeback, or in foliomkclean()'s rmap walk when the folio is mapped.
truncatepagecache() can't be used here: it must be called with the irwsem held exclusively, but these write paths only hold it shared, and it would block unconditionally, breaking IOCBNOWAIT.
Callers that hold irwsem exclusively for the whole resize (truncate, setattr, fallocate, clone) exclude any genuine concurrent buffered writer, so staleness can instead be decided from the folio's dirty state, as pagecacheisizeextended() already does for filesystems that serialise writes against truncate/setattr via a single irwsem. Export netfsclearstalepostisize() helper to handle such case.
The helper is required by the CIFS client to fix generic/363.
Affected Software
Event History
Frequently Asked Questions
What workload is required to trigger the stale-data condition?
The affected sequence requires dirty data to have been left past EOF by writes through an mmaped region, followed by an ordinary buffered or unbuffered/DIO write that extends the file. Pages wholly beyond EOF cannot be faulted in, so the relevant stale data is limited to the folio that straddles EOF.
How does the fix avoid corrupting data during concurrent extending writes?
It re-reads i_size while holding the folio lock and clamps the zeroing range to the current size, preventing data written by a racing extending write from being overwritten. It also waits for writeback on that folio before zeroing it.
Will nonblocking writes have different behavior when cleanup is required?
Yes. The fix honors IOCB_NOWAIT by returning -EAGAIN when it cannot perform the required wait before zeroing the folio.