CVE-2025-40205
btrfs: avoid potential out-of-bounds in btrfs_encode_fh()
Check your servers for CVE-2025-40205
The Vulnpocalypse collector sends the package list of each Linux server and of its container images once a day. Vulnpocalypse shows every server where CVE-2025-40205 affects the running kernel, with the command that installs the fix. The free plan covers one server and one domain and does not need a credit card.
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.
Severity (CVSS)
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
- Attack vector
- local: the attacker needs local access, or a user has to open a prepared file
- Attack complexity
- low: an attack works without special conditions
- Privileges required
- low: the attacker needs an ordinary user account
- User interaction
- none: nobody has to click or open anything
- Scope
- unchanged: the damage stays inside the vulnerable component
- Impact
- confidentiality high, integrity high, availability high: what an attacker can read (confidentiality), change (integrity) or stop (availability)
Exploitation
EPSS 0.15%: the probability of exploitation activity in the next 30 days, from the EPSS model of FIRST. The score is higher than 4.80% of all scored CVEs. Scores of 1 Dec 2026.
The assessment of CISA (SSVC, 15 Oct 2026):
- Exploitation
- none: CISA did not find evidence of exploitation or a public proof of concept
- Automatable
- no: each attack takes manual steps
- Technical impact
- total: full control of the component or of its data
Affected products
As the CNA lists them.
| Product | Versions |
|---|---|
| Linux |
affected from be6e8dc0ba84029997075a1ec77b4ddb863cbe15, before 60de2f55d2aca53e81b4ef2a67d7cc9e1eb677db affected from be6e8dc0ba84029997075a1ec77b4ddb863cbe15, before 742b44342204e5dfe3926433823623c1a0c581df affected from be6e8dc0ba84029997075a1ec77b4ddb863cbe15, before d3a9a8e1275eb9b87f006b5562a287aea3f6885f affected from be6e8dc0ba84029997075a1ec77b4ddb863cbe15, before d91f6626133698362bba08fbc04bd72c466806d3 affected from be6e8dc0ba84029997075a1ec77b4ddb863cbe15, before 0276c8582488022f057b4cec21975a5edf079f47 affected from be6e8dc0ba84029997075a1ec77b4ddb863cbe15, before 361d67276eb8ec6be8f27f4ad6c6090459438fee affected from be6e8dc0ba84029997075a1ec77b4ddb863cbe15, before 43143776b0a7604d873d1a6f3e552a00aa930224 affected from be6e8dc0ba84029997075a1ec77b4ddb863cbe15, before dff4f9ff5d7f289e4545cc936362e01ed3252742
Other versions: unaffected
|
| Linux |
affected 2.6.29 unaffected before 2.6.29 unaffected from 5.4.301 up to and including 5.4.* unaffected from 5.10.246 up to and including 5.10.* unaffected from 5.15.195 up to and including 5.15.* unaffected from 6.1.157 up to and including 6.1.* unaffected from 6.6.113 up to and including 6.6.* unaffected from 6.12.54 up to and including 6.12.* unaffected from 6.17.4 up to and including 6.17.* unaffected 6.18 and later
Other versions: affected
|
Is my server affected?
This CVE is in the Linux kernel. Compare the running kernel with the fixed kernel version of your distribution, and reboot after a kernel update:
uname -r
# Debian, Ubuntu: does the changelog of the running kernel name the CVE?
zgrep -l CVE-2025-40205 /usr/share/doc/linux-image-$(uname -r)/changelog.Debian.gz
# RHEL, Rocky, Alma
rpm -q --changelog kernel | grep CVE-2025-40205
With Trivy, on the host and for a container image. When a package is affected, it prints the installed and the fixed version:
trivy rootfs --scanners vuln / | grep CVE-2025-40205
trivy image --scanners vuln IMAGE | grep CVE-2025-40205
Vulnpocalypse makes this comparison every day for the package lists of your servers and container images, including language packages (npm, PyPI, Go, Maven and others), and sends the command that installs the fix. Start free with one server and one domain or read how to install the collector.
References
Other references
- https://git.kernel.org/stable/c/60de2f55d2aca53e81b4ef2a67d7cc9e1eb677db git.kernel.org
- https://git.kernel.org/stable/c/742b44342204e5dfe3926433823623c1a0c581df git.kernel.org
- https://git.kernel.org/stable/c/d3a9a8e1275eb9b87f006b5562a287aea3f6885f git.kernel.org
- https://git.kernel.org/stable/c/d91f6626133698362bba08fbc04bd72c466806d3 git.kernel.org
- https://git.kernel.org/stable/c/0276c8582488022f057b4cec21975a5edf079f47 git.kernel.org
- https://git.kernel.org/stable/c/361d67276eb8ec6be8f27f4ad6c6090459438fee git.kernel.org
- https://git.kernel.org/stable/c/43143776b0a7604d873d1a6f3e552a00aa930224 git.kernel.org
- https://git.kernel.org/stable/c/dff4f9ff5d7f289e4545cc936362e01ed3252742 git.kernel.org
Source: the record CVE-2025-40205 of the CVE List (CVE Program), CVE Terms of Use; the CISA KEV catalog and the CISA ADP container; EPSS of FIRST. The text of the record is shown as published. Data sources and licences.
Vulnpocalypse