CVE-2026-99846: iomap: don't mark unwritten parts of a folio uptodate
In the Linux kernel, the following vulnerability has been resolved:
iomap: don't mark unwritten parts of a folio uptodate
For a buffered write into a hole, an unwritten or new extent, or past EOF iomapwritebegin() zeroes the parts of the blocks outside of the write and then marks the blocks uptodate. That includes the range of the write itself which still holds whatever was in the folio before. It only becomes valid once the copy from userspace has filled it in.
But the copy can come up short and iomapwriteend() only rejects a short copy if the folio isn't uptodate. If the zeroed blocks were all that was missing the folio is uptodate by then, the short copy is accepted, and the rest of the range is exposed to readers and can end up on disk. A source buffer that ends in an unmapped page is enough:
ftruncate(fd, 4096); pwrite(fd, p, 3000, 100); / 16 bytes at p, then PROTNONE / pread(fd, buf, 4096, 0);
The write returns 16 and the read returns 2984 bytes of whatever was in that page before. If other blocks of the folio aren't uptodate the short copy is rejected but the zeroed blocks keep their uptodate bits and the retry with the copied length leaves the same bytes behind.
Only mark blocks uptodate in iomapwritebegin() after reading them. iomapwriteend() marks the zeroed blocks uptodate once the copy has succeeded and rejects a short copy.
Willy reported this back in 2024 (cf. [1]) and Zhang Yi posted the same fix (cf. [2]) but it never got merged.
[1]: https://lore.kernel.org/all/ZqsN5ouQTEc1KAzV@casper.infradead.org [2]: https://lore.kernel.org/all/20240812121159.3775074-6-yi.zhang@huaweicloud.com
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 5.10.275 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 5.15.226 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.1.193 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.6.163 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.12.118 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.18.64 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 7.3.4 - Upgrade
Upgrade
debian/linuxto a version that resolves this vulnerability.Fixed in 6.12.118-1 - Upgrade
Upgrade
debian/linuxto a version that resolves this vulnerability.Fixed in 7.3.4-1 - Upgrade
Upgrade
debian/linuxto a version that resolves this vulnerability.Fixed in 6.12.118-1Fixed in 7.3.4-1
Event History
Frequently Asked Questions
What conditions are required to trigger the issue?
It involves a buffered write into a hole, an unwritten or new extent, or a range past EOF, followed by a short copy from the userspace source buffer. A source buffer that reaches an unmapped or PROT_NONE page can cause such a short copy.
What is the practical impact of a successful trigger?
Bytes that were previously present in the folio can be exposed to readers instead of being rejected or zeroed. Those stale bytes can also be written to disk.
Does retrying a write after a short copy avoid the exposure?
Not necessarily. If other blocks in the folio are not uptodate, the initial short copy is rejected, but the zeroed blocks retain their uptodate state; retrying with the copied length can still leave the same stale bytes behind.