CVE-2026-89772: btrfs: write-protect folios during data writeback

Published Sep 11, 2026
·
Updated

In the Linux kernel, the following vulnerability has been resolved:

btrfs: write-protect folios during data writeback

commit 095be159f3eb ("btrfs: unify folio dirty flag clearing") replaced the foliocleardirtyforio() call in extentwritecachepages() with a plain foliotestdirty() check. Besides clearing the dirty flag, foliocleardirtyforio() also calls foliomkclean(), which write-protects the shared mmap PTEs mapping the folio. Note that we still do call foliocleardirtyforio() later in submitonesector() when we clear dirty on the last sector of the folio (the only sector for non-subpage cases). But we lost this early call in extentwritecachepages().

Without the extra write-protection, a process with the file mmap-ed can modify a sector while it is being used by writeback in a way that expects a stable folio (checksumming, compressing, copying, etc...) without faulting, which manifests as a handful of concrete bugs.

1. For large folios or subpage sectorsize, it is possible to submit a bio which does not cover the whole folio. When this happens, we will have a bio in flight for a folio that we have not called foliocleardirtyforio() on. If a task with an existing mmap-ed PTE writes (without faulting..) in this window, it can result in corruptions. If the write arrives while the checksumming or writing itself is underway, this can result in an invalid checksum and later corruption reports on read. If the write arrives after checksumming/writing is done but before the last sector dirty is cleared, then the write is present in page cache but doesn't affect the dirty tracking and will be lost when the folio is fully finished being submitted and the dirty bit is cleared. This results in losing the write even if fsync() is called.

2. For zoned submissions which are done in batch separate from the main extentwritepage() loop, we also risk csum violations for those submissions. Zoned writes are clamped to maxzoneappendsize and are not aligned with folios, so a submission can span two folios. The first folio being processed in extentwritecachepages() will call extentwritelockedrange() which will submit the partial range of the next folio, while the rest of that folio could still be dirty. So clearing dirty on the submitted sectors doesn't call foliocleardirtyforio() and we have the same issue. Since extentwritecachepages() skips these batch submitted folios (they are already marked for writeback from submission by the preceding folio), we must add the extra write protection in lockdelallocfolios().

3. For inline extents this will subtly risk losing writes that happen after/while we copy the inline extent but before we clear dirty on the folio.

4. For folios spanning EOF, mmap could tamper with the zeroed bytes past EOF and cause them to be persisted where future faults would improperly see them instead of zeros.

5. Finally, for compressed extents, we risk modifying the folios while we work on compressing them which will result in corrupted compressed data. Specifically, in rundelalloccompressed() we queue up work to do compressfilerange() in BTRFSCOMPRESSIONCHUNKSIZE (512K) chunks which will call btrfsfolioclampcleardirty() on the range. For non-subpage, this will always clear the whole folio, safely. For subpage, we risk a partial clear here as well. In particular, imagine a 2M folio broken up into 512K chunks of work which might start compression work on one chunk before all the chunks compressfilerange() workers have gotten far enough to finish clearing all the dirty bitmaps of the folio and getting to foliocleardirtyforio(). Large folios on the edges of submission ranges are similarly at risk to be only partly cleared. This particular gap was introduced by a second patch in the same series: commit a4ef54dbb576 ("btrfs: make extentrangecleardirtyforio() to handle sector size < page size cases")

We cannot simply restore the call to folioclear ---truncated---

Event History

Sep 11, 2026
CVE Published
via MITRE·07:47 PM
Data Sourced
via MITRE·07:47 PM
Description

Frequently Asked Questions

1

Who is exposed to this issue?

Systems using Btrfs are exposed when a process has a file memory-mapped and can modify it while the file is undergoing writeback. The risk is particularly relevant for large folios or subpage sector sizes, where a submitted bio may not cover the entire folio.

2

What conditions are needed to trigger the race?

A process must modify a sector through a shared mmap mapping while writeback is using the same folio for operations that require stable contents, such as checksumming, compression, or copying. The missing write protection allows that modification to occur without a page fault.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203