CVE-2024-26726
btrfs: don't drop extent_map for free space inode on write error
Reported by linux · Published April 3, 2024
In the Linux kernel, the following vulnerability has been resolved: btrfs: don't drop extent_map for free space inode on write error While running the CI for an unrelated change I hit the following panic with generic/648 on btrfs_holes_spacecache. assertion failed: block_start != EXTENT_MAP_HOLE, in fs/btrfs/extent_io.c:1385 ------------[ cut here ]------------ kernel BUG at fs/btrfs/extent_io.c:1385! invalid opcode: 0000 [#1] PREEMPT SMP NOPTI CPU: 1 PID: 2695096 Comm: fsstress Kdump: loaded Tainted: G W 6.8.0-rc2+ #1 RIP: 0010:__extent_writepage_io.constprop.0+0x4c1/0x5c0 Call Trace: <TASK> extent_write_cache_pages+0x2ac/0x8f0 extent_writepages+0x87/0x110 do_writepages+0xd5/0x1f0 filemap_fdatawrite_wbc+0x63/0x90 __filemap_fdatawrite_range+0x5c/0x80 btrfs_fdatawrite_range+0x1f/0x50 btrfs_write_out_cache+0x507/0x560 btrfs_write_dirty_block_groups+0x32a/0x420 commit_cowonly_roots+0x21b/0x290 btrfs_commit_transaction+0x813/0x1360 btrfs_sync_file+0x51a/0x640 __x64_sys_fdatasync+0x52/0x90 do_syscall_64+0x9c/0x190 entry_SYSCALL_64_after_hwframe+0x6e/0x76 This happens because we fail to write out the free space cache in one instance, come back around and attempt to write it again. However on the second pass through we go to call btrfs_get_extent() on the inode to get the extent mapping. Because this is a new block group, and with the free space inode we always search the commit root to avoid deadlocking with the tree, we find nothing and return a EXTENT_MAP_HOLE for the requested range. This happens because the first time we try to write the space cache out we hit an error, and on an error we drop the extent mapping. This is normal for normal files, but the free space cache inode is special. We always expect the extent map to be correct. Thus the second time through we end up with a bogus extent map. Since we're deprecating this feature, the most straightforward way to fix this is to simply skip dropping the extent map range for this failed range. I shortened the test by using error injection to stress the area to make it easier to reproduce. With this patch in place we no longer panic with my error injection test.
Fixed versions
Upgrade to a fixed version or later. Language registries are listed first, then Linux distributions, then vendor products.
| Package | Ecosystem | Fixed in |
|---|---|---|
| bpftool | Amazon Linux | 6.1.79-99.164.amzn2023 |
| python3-perf | Amazon Linux | 6.1.79-99.164.amzn2023 |
| kernel-modules-extra-common | Amazon Linux | 6.1.79-99.164.amzn2023 |
| kernel-headers | Amazon Linux | 6.1.79-99.164.amzn2023 |
| kernel-tools-devel | Amazon Linux | 6.1.79-99.164.amzn2023 |
| kernel-livepatch-6.1.79-99.164 | Amazon Linux | 1.0-0.amzn2023 |
| kernel-libbpf-devel | Amazon Linux | 6.1.79-99.164.amzn2023 |
| kernel-libbpf-static | Amazon Linux | 6.1.79-99.164.amzn2023 |
| kernel-tools | Amazon Linux | 6.1.79-99.164.amzn2023 |
| kernel-devel | Amazon Linux | 6.1.79-99.164.amzn2023 |
| kernel | Amazon Linux | 6.1.79-99.164.amzn2023 |
| kernel-libbpf | Amazon Linux | 6.1.79-99.164.amzn2023 |
1 more packages have a fixed version. See every fix in Lookup.
Affected products
| Vendor | Product | Versions |
|---|---|---|
| Linux | Linux | 77cef2ec5484564eca6bd12a2b4a1e88fd766fbc, 77cef2ec5484564eca6bd12a2b4a1e88fd766fbc, 77cef2ec5484564eca6bd12a2b4a1e88fd766fbc |
| Linux | Linux | 3.12, 0, 5.15.187 |
| amazon:2023 | bpftool | 0 |
| amazon:2023 | python3-perf | 0 |
| amazon:2023 | kernel-modules-extra-common | 0 |
| amazon:2023 | kernel-headers | 0 |
| amazon:2023 | kernel-tools-devel | 0 |
| amazon:2023 | kernel-livepatch-6.1.79-99.164 | 0 |
| amazon:2023 | kernel-libbpf-devel | 0 |
| amazon:2023 | kernel-libbpf-static | 0 |
| amazon:2023 | kernel-tools | 0 |
| amazon:2023 | kernel-devel | 0 |
| amazon:2023 | kernel | 0 |
| amazon:2023 | kernel-libbpf | 0 |
| linux | linux_kernel | 3.12, 3.12, 3.12 |
| amazon:2023 | perf | 0 |
| Linux | Linux | 6.8, 77cef2ec5484564eca6bd12a2b4a1e88fd766fbc, 77cef2ec5484564eca6bd12a2b4a1e88fd766fbc |
| amazon:2023 | kernel-modules-extra | 0 |
Timeline
- Mar 5, 2024 CVE Published
- Apr 4, 2024 EPSS Score (30 in total, the first dated here)
- Oct 4, 2024 Coalition ESS Score (13 in total, the first dated here)
- Jan 15, 2026 Security Advisory (302 in total, the first dated here)
- Mar 31, 2026 Distribution Patch (264 in total, the first dated here)
Query this with the API
The same record, from the CLI:
vulnetix vdb vuln CVE-2024-26726
vulnetix vdb fixes CVE-2024-26726
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-2024-26726/fixes/registry"
The Community plan is free and allows 50 queries a day. Get a free API key · API quickstart