CVE-2025-40205
btrfs: avoid potential out-of-bounds in btrfs_encode_fh()
Reported by linux · Published November 12, 2025
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.
Fixed versions
Upgrade to a fixed version or later. Language registries are listed first, then Linux distributions, then vendor products.
| Package | Ecosystem | Fixed in |
|---|---|---|
| kernel-tools | Amazon Linux | 1:6.1.158-178.288.amzn2023 |
Risk scores
Affected products
| Vendor | Product | Versions |
|---|---|---|
| Linux | Linux | be6e8dc0ba84029997075a1ec77b4ddb863cbe15, be6e8dc0ba84029997075a1ec77b4ddb863cbe15, be6e8dc0ba84029997075a1ec77b4ddb863cbe15 |
| Linux | Linux | 2.6.29, 0, 5.4.301 |
| amazon:2023 | kernel-tools | 0 |
| linux | linux_kernel | 2.6.29, 2.6.29, 2.6.29 |
| amazon:2023 | kernel-livepatch-6.12.55-74.119 | 0 |
| amazon:2023 | kernel6.12-libbpf | 0 |
| amazon:2023 | kernel6.12-libbpf-devel | 0 |
| amazon:2023 | kernel | 0 |
| amazon:2023 | bpftool | 0 |
| amazon:2023 | kernel-libbpf | 0 |
| amazon:2023 | perf6.12 | 0 |
| amazon:2023 | kernel6.12-tools | 0 |
| amazon:2023 | kernel6.12-devel | 0 |
| amazon:2023 | kernel-devel | 0 |
| amazon:2023 | kernel-livepatch-6.1.158-178.288 | 0 |
| amazon:2023 | kernel6.12-headers | 0 |
| amazon:2023 | kernel6.12-libbpf-static | 0 |
| amazon:2023 | kernel-libbpf-static | 0 |
| amazon:2023 | kernel-headers | 0 |
| amazon:2023 | kernel6.12-modules-extra-common | 0 |
…and 12 more
Timeline
- Nov 10, 2025 CVE Published
- Nov 12, 2025 Coalition ESS Score (4 in total, the first dated here)
- Nov 13, 2025 EPSS Score (30 in total, the first dated here)
- Dec 15, 2025 Security Advisory (136 in total, the first dated here)
- Mar 29, 2026 Distribution Patch (119 in total, the first dated here)
Query this with the API
The same record, from the CLI:
vulnetix vdb vuln CVE-2025-40205
vulnetix vdb fixes CVE-2025-40205
Or with curl, using the org id and key from your account page:
curl -s -H "Authorization: ApiKey ${VULNETIX_ORG_ID}:${VULNETIX_API_KEY}" \
"https://api.vdb.vulnetix.com/v2/vuln/CVE-2025-40205/fixes/registry"
The Community plan is free and allows 50 queries a day. Get a free API key · API quickstart