CVE-2023-54121
Description
In the Linux kernel, the following vulnerability has been resolved:
btrfs: fix incorrect splitting in btrfs_drop_extent_map_range
In production we were seeing a variety of WARN_ON()'s in the extent_map code, specifically in btrfs_drop_extent_map_range() when we have to call add_extent_mapping() for our second split.
Consider the following extent map layout
PINNED [0 16K) [32K, 48K)
and then we call btrfs_drop_extent_map_range for [0, 36K), with skip_pinned == true. The initial loop will have
start = 0 end = 36K len = 36K
we will find the [0, 16k) extent, but since we are pinned we will skip it, which has this code
start = em_end; if (end != (u64)-1) len = start + len - em_end;
em_end here is 16K, so now the values are
start = 16K len = 16K + 36K - 16K = 36K
len should instead be 20K. This is a problem when we find the next extent at [32K, 48K), we need to split this extent to leave [36K, 48k), however the code for the split looks like this
split->start = start + len; split->len = em_end - (start + len);
In this case we have
em_end = 48K split->start = 16K + 36K // this should be 16K + 20K split->len = 48K - (16K + 36K) // this overflows as 16K + 36K is 52K
and now we have an invalid extent_map in the tree that potentially overlaps other entries in the extent map. Even in the non-overlapping case we will have split->start set improperly, which will cause problems with any block related calculations.
We don't actually need len in this loop, we can simply use end as our end point, and only adjust start up when we find a pinned extent we need to skip.
Adjust the logic to do this, which keeps us from inserting an invalid extent map.
We only skip_pinned in the relocation case, so this is relatively rare, except in the case where you are running relocation a lot, which can happen with auto relocation on.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
A bug in btrfs_drop_extent_map_range() in the Linux kernel causes incorrect extent map splitting, leading to invalid entries and potential system instability.
Vulnerability
Description
In the Linux kernel, a flaw exists in the btrfs_drop_extent_map_range() function within the Btrfs filesystem. The root cause is an incorrect calculation of the len variable when skipping pinned extent maps during a range drop operation. Specifically, when the function encounters a pinned extent and adjusts start and len, the new len value is erroneously computed, leading to an invalid split of subsequent extent maps [1].
Exploitation
Conditions
This vulnerability can be triggered during the extent map splitting process can be triggered when the function is called with skip_pinned == true, which occurs during Btrfs relocation operations. The bug manifests when the range to drop overlaps with pinned extents, causing the subsequent split to-be-split extent map to have an incorrect start offset and potentially a negative or overflowed len value. This results in an invalid extent map being inserted into the tree, which can overlap with other entries [1].
Impact
Impact
An attacker with the ability to trigger Btrfs relocation (which can happen automatically with auto relocation enabled) could exploit this bug to cause a variety of WARN_ON() splats and potentially corrupt the extent map tree. This corruption may lead to system instability, data corruption, or a denial-of-service condition. The issue is considered relatively rare but can occur frequently under heavy relocation workloads [1].
Mitigation
The fix has been applied in the Linux kernel stable tree, with commits available at the referenced Git repositories [1][2]. Users are advised to update their kernels to versions containing the patch to prevent the invalid extent map insertion and associated system issues.
AI Insight generated on May 19, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.
Affected products
2Patches
39f68e2105dd9b43a4c99d878c962098ca4afVulnerability mechanics
Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
3News mentions
0No linked articles in our index yet.