Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792758956; b=KozhMkLBUaedJbl9LHBPGgGIsSdtLRq25+sBJJZpkDQ1CVtwALPkyffmtQxNOs6SBr7C eC2HFHmEEea+Xk1jD8sckbY9CyB0UXX6SUhkdsMM0EoK7lTPEj5Kb9PC4KtOgLKp29BuX xm0UbQecAtOMXvq+gUVeebWtGWFQ1OYfU0iY5DfKIX4uLeIY7mjto9viCcAHjSuZ3V/g7 Freii/7qmBVs5y5oPSjjQKG+ezEDHfwmCfHaCWZ80WSwBHR+QoaB3HZCqSpbjQb2bYTME 5zD0jt7WA4J8hnIChRVwu0kux+KPu4a18AJYf7JZUqSB9hTzyLgIcVDrAHcnRp3K2EQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792758956; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: Reply-To:MIME-Version:Lines:X-Developer-Signature:X-Developer-Key: Content-Transfer-Encoding; bh=WWuX4ILXrEw9r5pkN1dyPScJoUqWht+29BGdlLQtWJs=; b=3gtK0gcNaSi/i+x3MGVZ2hVqLl2watrCDloTHcj+n9+bSirgIT7IujKqTHPKrlWvtaLW dvSQFRbg7yB1ckdfUVklRKc1rzsU0CF0FiuTF6KDPXRd3MOEIc93EcQUR/Lbedw3IIF/7 fexoAvRkcaG7JS8X2QiNdQgvUw9jGSfxMz5eDKB28KGC+yW96oDiMipGu3zN+6l0o2w0h +vFz96gxeS6/L59H44TXITueE0EIu0Fgj0Mrdo0gmBTwLFR1IPm+Rk91ULo/v4RKXm1ES VujRGTSoVbZFHLKWF07TCacDzfU04JGNHbUa94Kkk8G0ZM3BbDzudWOAHr0YYvH/yQQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=ifXXBLKR; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB5DB606A31A for ; Fri, 23 Oct 2026 12:35:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=ifXXBLKR Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28D2D1F01825; Fri, 23 Oct 2026 12:35:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1792758955; bh=WWuX4ILXrEw9r5pkN1dyPScJoUqWht+29BGdlLQtWJs=; h=From:To:Cc:Subject:Date:Reply-To; b=ifXXBLKRIpEyOxlXxgOw/VJdk+1Tqg9KDUZze9HnljFYxatkHkCMWvEVvm0FEHRQC +d2M9KTLztKvhloASnDytkPL864XIk+cvrhyLJ//RaJDow0LSS1JGDHL59e5p5ptea KSNT5WdECQQRqnG9PaE/GuWPHHov79gV9NQBzvS4= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2026-98974: xfs: fix exchange-range-to-eof file size exchange Date: Fri, 23 Oct 2026 14:19:36 +0200 Message-ID: <2026102312-CVE-2026-98974-a938@gregkh> X-Mailer: git-send-email 2.56.0 Reply-To: , X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=6795; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=SynxtI0Za9VgV6jpLBdxocvKbNmbXneAMoG5tgFj0ss=; b=owGbwMvMwCRo6H6F97bub03G02pJDFm3Aw6IlAWwxxx8XXdKX6hR5visWYqR/14LGnIl780V2 O+U7iXYEcvCIMjEICumyPJlG8/R/RWHFL0MbU/DzGFlAhnCwMUpABN5ncAwh4MpYfW+b6tTpJ6r L9mzzfROwu6F2gwLujpUVYo4/7tNmZ99YVpryr55XGVfAA== 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: xfs: fix exchange-range-to-eof file size exchange Norbert Szetei posted a patch containing an incomplete description of a bug in XFS_IOC_EXCHANGE_RANGE's TO_EOF flag. The bug tricks exchange-range into modifying a file so that it has shared blocks starting beyond EOF, which is never allowed because files never have written data beyond EOF, and you can only share written data blocks. This is key to all the incorrect behavior that follows. Eventually I got from Norbert a description of what's going wrong: > Fair. Here it is with physical block numbers, 4k blocks. peer is the file > that gets rewritten and file1 is the one that ends up with the flag > cleared. > > Start, nothing shared: > > peer size 4096 -> [100] > file1 size 12288 -> [200] [201] [202] > donor1 size 4096 -> [300] > donor2 size 4096 -> [400] > > 1. FICLONERANGE peer's block into file1's middle slot: > > peer size 4096 -> [100] > file1 size 12288 -> [200] [100] [202] reflink flag set > ^^^^^ both files own block 100 > > 2. XFS_IOC_EXCHANGE_RANGE file1 against donor1, file1_offset 0, > file2_offset 8192, length 0, TO_EOF. One block is exchanged, and the sizes > are exchanged with it: > > file1 size 4096 -> [200] [100] [300] reflink flag set > ^^^^^^^^^^^ still owned, now past the size > donor1 size 12288 -> [202] > > file1 says it is one block long while it still owns three. Nothing was > unmapped. file2_offset is block 2, so this exchange cannot clear a flag. > > 3. XFS_IOC_EXCHANGE_RANGE file1 against donor2, both offsets 0, length 4096. > By i_disk_size this is two one-block files exchanging everything, so > xmi_can_exchange_reflink_flags() agrees and the flag is cleared: > > file1 size 4096 -> [400] [100] [300] reflink flag CLEARED > donor2 size 4096 -> [200] > > Block 100 is still shared with peer. > > 4. pwrite(file1, 4096, 4096), which is file1's second slot, block 100. > xfs_is_cow_inode(file1) is false, so no CoW: > > peer size 4096 -> [100] same block, new contents > > Block 100 is the only one that matters here. PoC below, it reads a file > called peer in the current directory. The filesystem needs reflink and > exchange-range, which mkfs.xfs 7.x turns on by default. So yes, TO_EOF is screwing up the file size even if it's actually exchanging the data block correctly. The following is the intended behavior of XFS_EXCHANGE_RANGE_TO_EOF, as described by its manpage: "Ignore the length parameter. All bytes in file1_fd from file1_offset to EOF are moved to file2_fd, and file2's size is set to (file2_offset+(file1_length-file1_offset)). Meanwhile, all bytes in file2 from file2_offset to EOF are moved to file1 and file1's size is set to (file1_offset+(file2_length-file2_offset))." In other words, if we only exchange a portion of the file data, then we should only exchange the portion of the file size that relates to the exchanged data. Unfortunately, the code swaps the ondisk file size and the incore file sizes, which is incorrect if the caller passes in a nonzero offset. Having confused the file sizes, the PoC uses a second exchange-range call on what looks like a non-reflinked single-block file. Because the file size is set incorrectly, exchange-range thinks it's exchanging the full contents of two files and clears the reflink flag on the broken file. That enables an extending write of the broken file to rewrite the shared block that's just past EOF. This has become known colloquially as refluxfs. Once the file sizes are set correctly, the second exchange-range no longer thinks that it's doing a full-contents swap, so it won't clear the reflink flag on either of its file arguments. Norbert followed up to an earlier version of this patch with a second complaint about us not handling the i_disk_size state correctly: > The offsets are bounded against the incore i_size but subtracted from > the ondisk i_disk_size, so a file that has not been written back gives > xmi_isize1 = 0 + (0 - 12288). > > For instance, you can do: > > $ xfs_io -f -c "pwrite -q 0 4096" -c fsync file1 > $ xfs_io -f -c "pwrite -q 0 12288" \ > -c "exchangerange -s 0 -d 12288 file1" dirty > $ stat -c %s file1 > 0 > $ stat -c %i file1 > 131 > $ sudo xfs_io -r -c "bulkstat_single 131" . | grep bs_size > bs_size = 18446744073709539328 That's wrong, and the new file size update logic depends on the ondisk i_disk_size matching the incore i_size, so flush the pagecache as needed to push it upwards. The Linux kernel CVE team has assigned CVE-2026-98974 to this issue. Affected and fixed versions =========================== Issue introduced in 6.10 with commit 966ceafc7a437105ecfe1cadb3747b2965a260ca and fixed in 6.12.114 with commit b361d32b884f8ddcb9bad5d99b69eece648f8e43 Issue introduced in 6.10 with commit 966ceafc7a437105ecfe1cadb3747b2965a260ca and fixed in 6.18.57 with commit cf32eb20dfacfd2e92ce86ba1fece9ae5f98a7d8 Issue introduced in 6.10 with commit 966ceafc7a437105ecfe1cadb3747b2965a260ca and fixed in 7.2.11 with commit 952b5c99a840c2bff1f6645fd5e06e1db6ec2623 Issue introduced in 6.10 with commit 966ceafc7a437105ecfe1cadb3747b2965a260ca and fixed in 7.3 with commit 7dfb218c829c1acb626e0fe92c5fddb9a26a03e9 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-98974 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/xfs/libxfs/xfs_exchmaps.c fs/xfs/xfs_exchrange.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/b361d32b884f8ddcb9bad5d99b69eece648f8e43 https://git.kernel.org/stable/c/cf32eb20dfacfd2e92ce86ba1fece9ae5f98a7d8 https://git.kernel.org/stable/c/952b5c99a840c2bff1f6645fd5e06e1db6ec2623 https://git.kernel.org/stable/c/7dfb218c829c1acb626e0fe92c5fddb9a26a03e9