# CVE-2025-40205: btrfs: avoid potential out-of-bounds in btrfs\_encode\_fh()

> Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

- **Severity:** HIGH 7.8
- **CVSS:** 7.8 (v3.1, CNA) `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H`
- **CVSS metrics:** Attack vector: Local; Attack complexity: Low; Privileges required: Low; User interaction: None; Scope: Unchanged; Confidentiality impact: High; Integrity impact: High; Availability impact: High
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Not remotely exploitable (local or adjacent access needed)
- **EPSS:** 0.23% (percentile 9, 2026-11-26)
- **Published:** 2025-11-12T21:56:35.403Z
- **Modified:** 2026-10-19T21:10:00.160Z

## Who should check

- Anyone running Linux \>= be6e8dc0ba84029997075a1ec77b4ddb863cbe15, \< 60de2f55d2aca53e81b4ef2a67d7cc9e1eb677db; \>= be6e8dc0ba84029997075a1ec77b4ddb863cbe15, \< 742b44342204e5dfe3926433823623c1a0c581df; \>= be6e8dc0ba84029997075a1ec77b4ddb863cbe15, \< d3a9a8e1275eb9b87f006b5562a287aea3f6885f; \>= be6e8dc0ba84029997075a1ec77b4ddb863cbe15, \< d91f6626133698362bba08fbc04bd72c466806d3; \>= be6e8dc0ba84029997075a1ec77b4ddb863cbe15, \< 0276c8582488022f057b4cec21975a5edf079f47; \>= be6e8dc0ba84029997075a1ec77b4ddb863cbe15, \< 361d67276eb8ec6be8f27f4ad6c6090459438fee; \>= be6e8dc0ba84029997075a1ec77b4ddb863cbe15, \< 43143776b0a7604d873d1a6f3e552a00aa930224; \>= be6e8dc0ba84029997075a1ec77b4ddb863cbe15, \< dff4f9ff5d7f289e4545cc936362e01ed3252742
- Anyone running Linux 2.6.29

## Description

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.

## Affected and fixed versions

- Linux: \>= be6e8dc0ba84029997075a1ec77b4ddb863cbe15, \< 60de2f55d2aca53e81b4ef2a67d7cc9e1eb677db; \>= be6e8dc0ba84029997075a1ec77b4ddb863cbe15, \< 742b44342204e5dfe3926433823623c1a0c581df; \>= be6e8dc0ba84029997075a1ec77b4ddb863cbe15, \< d3a9a8e1275eb9b87f006b5562a287aea3f6885f; \>= be6e8dc0ba84029997075a1ec77b4ddb863cbe15, \< d91f6626133698362bba08fbc04bd72c466806d3; \>= be6e8dc0ba84029997075a1ec77b4ddb863cbe15, \< 0276c8582488022f057b4cec21975a5edf079f47; \>= be6e8dc0ba84029997075a1ec77b4ddb863cbe15, \< 361d67276eb8ec6be8f27f4ad6c6090459438fee; \>= be6e8dc0ba84029997075a1ec77b4ddb863cbe15, \< 43143776b0a7604d873d1a6f3e552a00aa930224; \>= be6e8dc0ba84029997075a1ec77b4ddb863cbe15, \< dff4f9ff5d7f289e4545cc936362e01ed3252742 (cvelist)
- Linux: 2.6.29 (cvelist)

## Mitigation

- No fix listed yet: follow the vendor advisory.

## Check your systems with an agent

Paste this into a coding agent:

```text
Check whether anything I run is affected by CVE-2025-40205. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2025-40205.md
Affected: Linux >= be6e8dc0ba84029997075a1ec77b4ddb863cbe15, < 60de2f55d2aca53e81b4ef2a67d7cc9e1eb677db; >= be6e8dc0ba84029997075a1ec77b4ddb863cbe15, < 742b44342204e5dfe3926433823623c1a0c581df; >= be6e8dc0ba84029997075a1ec77b4ddb863cbe15, < d3a9a8e1275eb9b87f006b5562a287aea3f6885f; >= be6e8dc0ba84029997075a1…
Fixed in: Linux 60de2f55d2aca53e81b4ef2a67d7cc9e1eb677db, Linux 742b44342204e5dfe3926433823623c1a0c581df, Linux 0276c8582488022f057b4cec21975a5edf079f47, Linux 361d67276eb8ec6be8f27f4ad6c6090459438fee, Linux 43143776b0a7604d873d1a6f3e552a00aa930224

Steps:
1. Search this machine and project for Linux: dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
```

## FAQ

### Is CVE-2025-40205 being exploited?

There is no confirmed exploitation: CVE-2025-40205 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 0.23% chance of exploitation in the next 30 days (as of 2026-11-26).

### How serious is CVE-2025-40205?

High: CVSS 7.8 (v3.1, scored by CNA). Not remotely exploitable (local or adjacent access needed).

### Which versions are affected by CVE-2025-40205?

Linux \>= be6e8dc0ba84029997075a1ec77b4ddb863cbe15, \< 60de2f55d2aca53e81b4ef2a67d7cc9e1eb677db; \>= be6e8dc0ba84029997075a1ec77b4ddb863cbe15, \< 742b44342204e5dfe3926433823623c1a0c581df; \>= be6e8dc0ba84029997075a1ec77b4ddb863cbe15, \< d3a9a8e1275eb9b87f006b5562a287aea3f6885f; \>= be6e8dc0ba84029997075a1ec77b4ddb863cbe15, \< d91f6626133698362bba08fbc04bd72c466806d3; \>= be6e8dc0ba84029997075a1ec77b4ddb863cbe15, \< 0276c8582488022f057b4cec21975a5edf079f47; \>= be6e8dc0ba84029997075a1ec77b4ddb863cbe15, \< 361d67276eb8ec6be8f27f4ad6c6090459438fee; \>= be6e8dc0ba84029997075a1ec77b4ddb863cbe15, \< 43143776b0a7604d873d1a6f3e552a00aa930224; \>= be6e8dc0ba84029997075a1ec77b4ddb863cbe15, \< dff4f9ff5d7f289e4545cc936362e01ed3252742; Linux 2.6.29.

### Is there a fix for CVE-2025-40205?

Yes. Fixed in Linux 60de2f55d2aca53e81b4ef2a67d7cc9e1eb677db, Linux 742b44342204e5dfe3926433823623c1a0c581df, Linux 0276c8582488022f057b4cec21975a5edf079f47, Linux 361d67276eb8ec6be8f27f4ad6c6090459438fee, Linux 43143776b0a7604d873d1a6f3e552a00aa930224. No fix listed yet: follow the vendor advisory.

### How do I check if I'm affected by CVE-2025-40205?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

## References

- other: <https://git.kernel.org/stable/c/60de2f55d2aca53e81b4ef2a67d7cc9e1eb677db>
- other: <https://git.kernel.org/stable/c/742b44342204e5dfe3926433823623c1a0c581df>
- other: <https://git.kernel.org/stable/c/d3a9a8e1275eb9b87f006b5562a287aea3f6885f>
- other: <https://git.kernel.org/stable/c/d91f6626133698362bba08fbc04bd72c466806d3>
- other: <https://git.kernel.org/stable/c/0276c8582488022f057b4cec21975a5edf079f47>
- other: <https://git.kernel.org/stable/c/361d67276eb8ec6be8f27f4ad6c6090459438fee>
- other: <https://git.kernel.org/stable/c/43143776b0a7604d873d1a6f3e552a00aa930224>
- other: <https://git.kernel.org/stable/c/dff4f9ff5d7f289e4545cc936362e01ed3252742>

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- NVD: This product uses data from the NVD API but is not endorsed or certified by the NVD. <https://nvd.nist.gov/vuln/detail/CVE-2025-40205>

HTML: <https://flawdb.com/CVE-2025-40205> · JSON: <https://flawdb.com/api/v1/entries/CVE-2025-40205>
