From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B1EEC592204 for ; Fri, 11 Sep 2026 20:06:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789157218; cv=none; b=tb2xjb6iOuioIMGJDwJpTCMdfUVNV0c5CiLVPr7R4Eq77vJdivquzX+Zn1iiYJV59djorBog4Cpdpa8YaQBisDMdfGXMhLqYc/ku+da0nQwuO7nZyzr4sG9rxzjmec9OL1IKgys3HL4z9BsoUYf7YTs9i77EmvmfcTyoYtlZ5PM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789157218; c=relaxed/simple; bh=2CCpLGik3kbHPBi06I6gJOBOc3zXnqmJVUaoqeRgBjI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ehT5Zml5iDRxHbcPY56RbfLVQVAzZ4Pv0E5o+Wx35FwG6CZbIuwkdwfaCTCfTtrshXCr2boMoGThM4xyMh5E+lnhK3Bob7bk5xN+Gyrzc0bSVsq3xYbbMazjOrGC68n6dVVJ2NBwrV4vDhtso3kzjneG7yOlH7+6hyt1hLBwhLw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=rxsL6SIa; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="rxsL6SIa" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6CCE51F00893; Fri, 11 Sep 2026 20:06:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789157211; bh=BjHE3jFq3TYMdINkjdIvPqP2UdZwNILKrf9kH50kHug=; h=From:To:Cc:Subject:Date:Reply-To; b=rxsL6SIa657DRl2V9P40TEoE0LECR9NPXn3ihzR/0yfP3lqhGE4C6Wn0ZS9U5vqXe dTesA2MEbPKLX9f86p2aIqI2XVGqxQYN1SvevB9UPv+LsT4z7G4rnf+TkcrAzae6cQ 1IVFaHu0eQanMvqr4Juw/M9iwont4GFSs179NMJY= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2026-89772: btrfs: write-protect folios during data writeback Date: Fri, 11 Sep 2026 21:47:41 +0200 Message-ID: <2026091112-CVE-2026-89772-9b5d@gregkh> X-Mailer: git-send-email 2.55.0 Reply-To: , Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=6477; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=Rspf6QSRqtGib8JCqpWmUK9VpMP86izTzxpa0XTj8YM=; b=owGbwMvMwCRo6H6F97bub03G02pJDFlLIqeIbwzc3mXK8ia+81vPwc0XnN9+PFOvsa5MoPHoL gvLa7/dOmJZGASZGGTFFFm+bOM5ur/ikKKXoe1pmDmsTCBDGLg4BWAiuiwM830f6AXc3vjk5/Hb r08t1b/G+exO0TKG+RVKKU8v5HLurDjIMOXw6ZCFpa63dAA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit From: Greg Kroah-Hartman Description =========== 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 folio_clear_dirty_for_io() call in extent_write_cache_pages() with a plain folio_test_dirty() check. Besides clearing the dirty flag, folio_clear_dirty_for_io() also calls folio_mkclean(), which write-protects the shared mmap PTEs mapping the folio. Note that we still do call folio_clear_dirty_for_io() later in submit_one_sector() 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 extent_write_cache_pages(). 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 folio_clear_dirty_for_io() 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 extent_writepage() loop, we also risk csum violations for those submissions. Zoned writes are clamped to max_zone_append_size and are not aligned with folios, so a submission can span two folios. The first folio being processed in extent_write_cache_pages() will call extent_write_locked_range() 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 folio_clear_dirty_for_io() and we have the same issue. Since extent_write_cache_pages() 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 lock_delalloc_folios(). 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 run_delalloc_compressed() we queue up work to do compress_file_range() in BTRFS_COMPRESSION_CHUNK_SIZE (512K) chunks which will call btrfs_folio_clamp_clear_dirty() 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 compress_file_range() workers have gotten far enough to finish clearing all the dirty bitmaps of the folio and getting to folio_clear_dirty_for_io(). 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 extent_range_clear_dirty_for_io() to handle sector size < page size cases") We cannot simply restore the call to folio_clear_dirty_for_io() because that also drops the dirty flag off the folio which violates invariants introduced for large folios by commit 334509ce9d07 ("btrfs: use dirty flag to check if an ordered extent needs to be truncated") and results in failing to invalidate clean folios past i_size, resulting in deadlocks. Therefore, to fix it, leave the existing semantics w.r.t. the folio's dirty flag (to preserve the correct invalidate behavior) but ensure that the other aspect of folio_clear_dirty_for_io(), folio_mkclean(), is run on the folio when we lock it for writeback. Finally, to help prevent similar regressions in the future, add a debug warning that triggers at the known corruption sites if we have failed to write protect the folio. The Linux kernel CVE team has assigned CVE-2026-89772 to this issue. Affected and fixed versions =========================== Issue introduced in 6.13 with commit a4ef54dbb576032ba31a646a5ffc8a26a83cb92c and fixed in 7.2.4 with commit 074c715e0b498891c09fe7f11e1cd9d7a04699bd Issue introduced in 6.13 with commit a4ef54dbb576032ba31a646a5ffc8a26a83cb92c and fixed in 7.3-rc1 with commit 5376c9db45368eb210b4d71104ac00a59dc8b6e0 Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community. Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at https://cve.org/CVERecord/?id=CVE-2026-89772 will be updated if fixes are backported, please check that for the most up to date information about this issue. Affected files ============== The file(s) affected by this issue are: fs/btrfs/extent_io.c fs/btrfs/extent_io.h fs/btrfs/inode.c Mitigation ========== The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits: https://git.kernel.org/stable/c/074c715e0b498891c09fe7f11e1cd9d7a04699bd https://git.kernel.org/stable/c/5376c9db45368eb210b4d71104ac00a59dc8b6e0