HIGH Introduced in 4.9
xfs ReflinkFlag Corruption
CVE-2026-98975
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
KernelScan AI7.1HIGH
01Description
In the Linux kernel, the following vulnerability has been resolved: xfs: stop exchanging reflink flags when exchanging mappings When an exchange covers both files from offset 0 to i_disk_size, xmi_can_exchange_reflink_flags() assumes every mapping moved and hands the reflink flag over to the other file. That assumption is wrong. A file can still own shared blocks past i_disk_size, e.g. after EXCHANGE_RANGE_TO_EOF sets a smaller size without unmapping anything. The flag is cleared anyway, and the next write to such a block happens in place instead of CoW, corrupting the other file that shares it. Commit a23eca88448e ("xfs: fix exchange-range reflink flag clearing issue with INO1_WRITTEN") fixed one instance of this. Rather than add another special case, stop moving the flags. xfs_exchmaps_ensure_reflink() already sets the flag on both inodes before the exchange, so both just keep it. Nothing sets CLEAR_INO{1,2}_REFLINK anymore. Intents logged by older kernels may still carry them; recovery already masks them off, so they stay in the log format mask and are ignored. XFS_IOC_SWAPEXT has the same problem: it moves the reflink flag from one inode to the other along with the extents. Just removing that is not enough here: the exchange path flags both inodes up front in xfs_exchmaps_ensure_reflink(), but swapext has no such step, so the inode receiving the shared extents would be left without the flag. Set it on both inodes instead, and make sure both have a CoW fork, since an inode with the reflink flag is expected to have one. The flag now stays until FALLOC_FL_UNSHARE_RANGE, xfs_scrub, or a truncate to zero removes it.
02KernelScan AI Analysis
Risk summary
A local user with write access to an XFS filesystem supporting reflink can trigger data corruption by performing extent exchange operations (XFS_IOC_SWAPEXT or exchange range ioctls). The kernel incorrectly clears the reflink flag on files that still own shared blocks beyond the exchanged range, causing subsequent writes to modify shared blocks in-place instead of copy-on-write, corrupting data in other files.
Vulnerability analysis
What goes wrong: When exchanging file mappings across the full logical file size, the XFS kernel code assumed all shared block mappings were moved and transferred the copy-on-write flag from one file to the other. This assumption was incorrect because a file can retain shared blocks past its current size — for example, after an operation that shrinks the file without removing the tail blocks. Clearing the flag on such a file causes later writes to those shared blocks to occur in-place rather than via copy-on-write, silently corrupting the other file that shares the same physical blocks. The same flaw existed in the extent-swap ioctl, which swapped the flag along with the extents.
The fix stops moving the copy-on-write flag during exchanges; instead, both files are marked with the flag up front (for exchanges) or both are flagged and given copy-on-write forks (for extent swap), ensuring copy-on-write semantics are preserved. The flag is now only cleared by explicit unshare operations, filesystem scrub, or truncation to zero.
Any local user who can write to files on an XFS filesystem with copy-on-write enabled can trigger this corruption.
Lifecycle
03Fix Versions
| Branch | Introduced | Fixed in | Patch commit |
|---|---|---|---|
| 6.12 | 4.9 | 6.12.114 | 1fa2f3a7ef7e |
| 6.18 | 4.9 | 6.18.57 | 7d3b9b2c9dc5 |
| 7.2 | 4.9 | 7.2.11 | 4756c94260e6 |
| mainline | 4.9 | 7.3 | d84d6c1a7f1e |
| cip/6.12 | 4.9 | 6.12.114-cip34 | 1fa2f3a7ef7e |
04CIP Kernels
State of the newest release of each Civil Infrastructure Platform SLTS tree, from CIP's own fix records.
| CIP tree | State |
|---|---|
| cip/6.12 | Fixed in 6.12.114-cip34 |
| cip/6.1 | Affected — no CIP fix yet (latest 6.1.190-cip62) |
| cip/6.1-rt | Affected — no CIP fix yet (latest 6.1.189-cip61-rt32) |
| cip/5.10 | Affected — no CIP fix yet (latest 5.10.272-cip79) |
| cip/5.10-rt | Affected — no CIP fix yet (latest 5.10.272-cip79-rt35) |
| cip/4.19 | Affected — no CIP fix yet (latest 4.19.325-cip137) |
| cip/4.19-rt | Affected — no CIP fix yet (latest 4.19.325-cip137-rt51) |