CVE-2025-40205: btrfs: avoid potential out-of-bounds in btrfs_encode_fh()
In the Linux kernel, the following vulnerability has been resolved:
btrfs: avoid potential out-of-bounds in btrfs_encode_fh()
The function btrfs_encode_fh() does not properly account for the three
cases it handles.
Before writing to the file handle (fh), the function only returns to the
user BTRFS_FID_SIZE_NON_CONNECTABLE (5 dwords, 20 bytes) or
BTRFS_FID_SIZE_CONNECTABLE (8 dwords, 32 bytes).
However, when a parent exists and the root ID of the parent and the
inode are different, the function writes BTRFS_FID_SIZE_CONNECTABLE_ROOT
(10 dwords, 40 bytes).
If *max_len is not large enough, this write goes out of bounds because
BTRFS_FID_SIZE_CONNECTABLE_ROOT is greater than
BTRFS_FID_SIZE_CONNECTABLE originally returned.
This results in an 8-byte out-of-bounds write at
fid->parent_root_objectid = parent_root_id.
A previous attempt to fix this issue was made but was lost.
https://lore.kernel.org/all/4CADAEEC020000780001B32C@vpn.id2.novell.com/
Although this issue does not seem to be easily triggerable, it is a
potential memory corruption bug that should be fixed. This patch
resolves the issue by ensuring the function returns the appropriate size
for all three cases and validates that *max_len is large enough before
writing any data.
Security readout for executives and security teams
Plain-English summary
A Linux Btrfs file-handle operation can write eight bytes beyond an allocated buffer under a specific parent/root relationship. This may corrupt kernel memory, potentially affecting confidentiality, integrity, or availability. The source says triggering appears difficult, but the kernel-level impact warrants timely remediation on exposed Btrfs systems.
Executive priority
Treat as a high-priority kernel maintenance issue, especially on multi-user or shared systems using Btrfs. It is not supported as an emergency internet-wide threat because exploitation requires local access, the trigger appears difficult, and no active exploitation evidence is supplied. Remediate through scheduled accelerated patching rather than deferral.
Technical view
btrfs_encode_fh() can report an eight-dword buffer requirement while later writing the ten-dword connectable-root format. When a parent exists and its root ID differs from the inode root ID, writing parent_root_objectid causes an eight-byte out-of-bounds write. The fix returns the correct size and validates max_len before writing.
Likely exposure
Exposure requires an affected Linux kernel and use of the relevant Btrfs file-handle encoding path. The supplied affected-version data includes several kernel versions through 6.18, but does not clearly express complete version ranges. Confirm applicability through the distribution or kernel vendor rather than relying solely on those flattened entries.
Exploitation context
CVSS 3.1 rates this 7.8 with local access and low privileges required, without user interaction. The source describes potential kernel memory corruption but says the issue does not appear easily triggerable. It is not listed as KEV, and the supplied sources provide no evidence of active exploitation or a public exploit.
Researcher notes
The vulnerable condition involves a parent whose root object ID differs from the inode root ID. The function can understate required storage by two dwords before an eight-byte write. No CWE is supplied. The record establishes memory-corruption potential, but does not establish reliable privilege escalation, exploitability, observed attacks, or complete affected-version boundaries.
Mitigation direction
Update to a vendor-supported kernel containing the referenced Btrfs stable fix.
Check distribution advisories for the exact fixed package and affected release mapping.
Prioritize systems using Btrfs and allowing access by untrusted local users.
Apply normal kernel-update reboot requirements so the corrected kernel is running.
Validation and detection
Inventory running kernel versions and identify systems with active Btrfs filesystems.
Compare each kernel package against its distribution advisory and fixed build.
Confirm the running kernel incorporates the applicable referenced stable commit or vendor backport.
Regression-test legitimate Btrfs file-handle and export workflows after updating.
Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.
Potential ATT&CK relevance
Conservative CVE-to-ATT&CK context
These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.
ATT&CK lookup starting points
Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.
cve · low confidence lookup
CVE-2025-40205 mapping review
Open the CVE-to-ATT&CK bridge for reviewed, inferred, or future official mappings tied to this CVE.
These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.
1CVSS vectors
3Timeline events
0ADP providers
9Source links
CVSS vector scores
1 official score
We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.