CVE-2026-98975: xfs: stop exchanging reflink flags when exchanging mappings
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 idisksize, xmicanexchangereflinkflags() 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 idisksize, e.g. after EXCHANGERANGETOEOF 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 INO1WRITTEN") fixed one instance of this. Rather than add another special case, stop moving the flags. xfsexchmapsensurereflink() already sets the flag on both inodes before the exchange, so both just keep it.
Nothing sets CLEARINO{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.
XFSIOCSWAPEXT 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 xfsexchmapsensurereflink(), 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 FALLOCFLUNSHARERANGE, xfsscrub, or a truncate to zero removes it.