{"id":"CVE-2026-98974","title":"xfs: fix exchange-range-to-eof file size exchange","summary":"In the Linux kernel, the following vulnerability has been resolved:\n\nxfs: fix exchange-range-to-eof file size exchange\n\nNorbert Szetei posted a patch containing an incomplete description of a\nbug in XFS_IOC_EXCHANGE_RANGE's TO_EOF flag. …","severity":"none","vendor":"Linux","product":"Linux","affected":["Linux >= 966ceafc7a437105ecfe1cadb3747b2965a260ca < b361d32b884f8ddcb9bad5d99b69eece648f8e43","Linux >= 966ceafc7a437105ecfe1cadb3747b2965a260ca < cf32eb20dfacfd2e92ce86ba1fece9ae5f98a7d8","Linux >= 966ceafc7a437105ecfe1cadb3747b2965a260ca < 952b5c99a840c2bff1f6645fd5e06e1db6ec2623","Linux >= 966ceafc7a437105ecfe1cadb3747b2965a260ca < 7dfb218c829c1acb626e0fe92c5fddb9a26a03e9","Linux 6.10"],"published":"2026-10-23","updated":"2026-10-23","sourceUpdated":"2026-10-23T12:19:47.424Z","source":"CVEORG","sourceUrl":"https://www.cve.org/CVERecord?id=CVE-2026-98974","references":[{"url":"https://git.kernel.org/stable/c/b361d32b884f8ddcb9bad5d99b69eece648f8e43"},{"url":"https://git.kernel.org/stable/c/cf32eb20dfacfd2e92ce86ba1fece9ae5f98a7d8"},{"url":"https://git.kernel.org/stable/c/952b5c99a840c2bff1f6645fd5e06e1db6ec2623"},{"url":"https://git.kernel.org/stable/c/7dfb218c829c1acb626e0fe92c5fddb9a26a03e9"}],"tags":["cve.org"],"ingestedAt":"2026-10-23T13:24:55.551Z","slug":"CVE-2026-98974","body":"## Overview\n\nIn the Linux kernel, the following vulnerability has been resolved:\n\nxfs: fix exchange-range-to-eof file size exchange\n\nNorbert Szetei posted a patch containing an incomplete description of a\nbug in XFS_IOC_EXCHANGE_RANGE's TO_EOF flag.  The bug tricks\nexchange-range into modifying a file so that it has shared blocks\nstarting beyond EOF, which is never allowed because files never have\nwritten data beyond EOF, and you can only share written data blocks.\nThis is key to all the incorrect behavior that follows.\n\nEventually I got from Norbert a description of what's going wrong:\n\n> Fair. Here it is with physical block numbers, 4k blocks. peer is the file\n> that gets rewritten and file1 is the one that ends up with the flag\n> cleared.\n>\n> Start, nothing shared:\n>\n>\tpeer size 4096   -> [100]\n>\tfile1 size 12288 -> [200] [201] [202]\n>\tdonor1 size 4096 -> [300]\n>\tdonor2 size 4096 -> [400]\n>\n> 1. FICLONERANGE peer's block into file1's middle slot:\n>\n>\tpeer size 4096   -> [100]\n>\tfile1 size 12288 -> [200] [100] [202] reflink flag set\n>                             ^^^^^ both files own block 100\n>\n> 2. XFS_IOC_EXCHANGE_RANGE file1 against donor1, file1_offset 0,\n> file2_offset 8192, length 0, TO_EOF. One block is exchanged, and the sizes\n> are exchanged with it:\n>\n>\tfile1 size 4096   -> [200] [100] [300] reflink flag set\n>                              ^^^^^^^^^^^ still owned, now past the size\n>\tdonor1 size 12288 -> [202]\n>\n> file1 says it is one block long while it still owns three. Nothing was\n> unmapped. file2_offset is block 2, so this exchange cannot clear a flag.\n>\n> 3. XFS_IOC_EXCHANGE_RANGE file1 against donor2, both offsets 0, length 4096.\n> By i_disk_size this is two one-block files exchanging everything, so\n> xmi_can_exchange_reflink_flags() agrees and the flag is cleared:\n>\n>\tfile1 size 4096   -> [400] [100] [300] reflink flag CLEARED\n>\tdonor2 size 4096  -> [200]\n>\n> Block 100 is still shared with peer.\n>\n> 4. pwrite(file1, 4096, 4096), which is file1's second slot, block 100.\n> xfs_is_cow_inode(file1) is false, so no CoW:\n>\n>\tpeer size 4096 -> [100] same block, new contents\n>\n> Block 100 is the only one that matters here. PoC below, it reads a file\n> called peer in the current directory. The filesystem needs reflink and\n> exchange-range, which mkfs.xfs 7.x turns on by default.\n\nSo yes, TO_EOF is screwing up the file size even if it's actually\nexchanging the data block correctly.  The following is the intended\nbehavior of XFS_EXCHANGE_RANGE_TO_EOF, as described by its manpage:\n\n\"Ignore the length parameter.  All bytes in file1_fd from file1_offset\n to EOF are moved to file2_fd, and file2's size is set to\n (file2_offset+(file1_length-file1_offset)).  Meanwhile, all bytes in\n file2 from file2_offset to EOF are moved to file1 and file1's size is\n set to (file1_offset+(file2_length-file2_offset)).\"\n\nIn other words, if we only exchange a portion of the file data, then we\nshould only exchange the portion of the file size that relates to the\nexchanged data.  Unfortunately, the code swaps the ondisk file size and\nthe incore file sizes, which is incorrect if the caller passes in a\nnonzero offset.\n\nHaving confused the file sizes, the PoC uses a second exchange-range\ncall on what looks like a non-reflinked single-block file.  Because the\nfile size is set incorrectly, exchange-range thinks it's exchanging the\nfull contents of two files and clears the reflink flag on the broken\nfile.  That enables an extending write of the broken file to rewrite the\nshared block that's just past EOF.  This has become known colloquially\nas refluxfs.\n\nOnce the file sizes are set correctly, the second exchange-range no\nlonger thinks that it's doing a full-contents swap, so it won't clear\nthe reflink flag on either of its file arguments.\n\nNorbert followed up to an earlier version of this patch with a second\ncomplaint about us not handling the i_disk_size state correctly:\n\n> The offsets are bounded against the incore i_size but subtracted from\n>\n---truncated---\n\n## Affected\n\n- `Linux >= 966ceafc7a437105ecfe1cadb3747b2965a260ca < b361d32b884f8ddcb9bad5d99b69eece648f8e43`\n- `Linux >= 966ceafc7a437105ecfe1cadb3747b2965a260ca < cf32eb20dfacfd2e92ce86ba1fece9ae5f98a7d8`\n- `Linux >= 966ceafc7a437105ecfe1cadb3747b2965a260ca < 952b5c99a840c2bff1f6645fd5e06e1db6ec2623`\n- `Linux >= 966ceafc7a437105ecfe1cadb3747b2965a260ca < 7dfb218c829c1acb626e0fe92c5fddb9a26a03e9`\n- `Linux 6.10`\n\n## Remediation\n\nRefer to the linked advisories for vendor-supplied fixes and affected version ranges.","depth":"sunlit","depthScore":3,"depthScoreParts":{"impact":2.8,"likelihood":0,"exploitation":0,"ransomware":0},"changes":[]}