CVE-2026-138817: iomap: don't lose a fiemap iteration error when emitting the last extent
In the Linux kernel, the following vulnerability has been resolved:
iomap: don't lose a fiemap iteration error when emitting the last extent
iomapfiemap() emits extents one behind: iomapfiemapiter() flushes the previous extent and remembers the current one, and the remembered extent is written with FIEMAPEXTENTLAST after the iteration loop.
That final flush overwrites ret, so when ->iomapbegin() fails partway through the iteration the error is replaced by the result of iomaptofiemap() (zero on success) and iomapfiemap() returns success with a truncated extent list whose last entry is wrongly marked as the last extent in the file. The pre-iomapiter code returned the error from inside the loop, before flushing the pending extent.
Check for the iteration error before flushing the pending extent, so that real errors are propagated and only a successful iteration emits the final FIEMAPEXTENTLAST extent. -ENOENT (no mapping) is still not an error, and the pending extent is still emitted in that case.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Compensating control
In iomap_fiemap(), check for an iteration error before flushing the pending extent, so real errors are propagated and the final FIEMAP_EXTENT_LAST extent is emitted only after successful iteration.
Event History
Frequently Asked Questions
When does the incorrect successful result occur?
It occurs when ->iomap_begin() fails partway through FIEMAP iteration after a previous extent has been retained for the final flush. The final extent emission can overwrite the iteration error with a successful result.
What is the observable effect of the error being lost?
FIEMAP can return success with a truncated extent list. The final returned entry may also be incorrectly marked with FIEMAP_EXTENT_LAST, indicating it is the last extent in the file.
Does a no-mapping result change under the fix?
No. -ENOENT, which indicates no mapping, remains non-error behavior, and a pending extent is still emitted in that case.