CVE-2024-26726

btrfs: don't drop extent_map for free space inode on write error

MEDIUM
5.5
CVSS Score
Published: April 3, 2024 at 02:55 PM UTC
Updated: June 17, 2026 at 07:18 AM UTC
1 product affected across 1 vendorLinux Kernel

Using Linux by Linux?

Get instant alerts when new vulnerabilities affect Linux - before attackers find them.

Real-time alertsTrack your software stackFree plan available
Severity
MEDIUM5.5
Exploit prediction
EPSS 0.3%
SSVC
No known exploit

Description

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.

Affected

Our own answer: ranges merged, affected separated from platform-only, with confidence and review flags.

v < 6.1.793.12 ≤ v < 5.15.1873.12 ≤ v < 6.1.793.12 ≤ v < 6.6.183.12 ≤ v < 6.7.63.12 ≤ v < 6.86.2 ≤ v < 6.6.186.7 ≤ v < 6.7.66.8 rc16.8 rc26.8 rc36.8 rc477cef2ec5484564eca6bd12a2b4a1e88fd766fbc
Vendor states this is fixed in 02f2b95b00bf57d20320ee168b30fb7f3db8e555 (fixed)
Vendor states this is fixed in 143842584c1237ebc248b2547c29d16bbe400a92 (fixed)
Vendor states this is fixed in 5571e41ec6e56e35f34ae9f5b3a335ef510e0ade (fixed)
Vendor states this is fixed in 7bddf18f474f166c19f91b2baf67bf7c5eda03f7 (fixed)
Vendor states this is fixed in a4b7741c8302e28073bfc6dd1c2e73598e5e535e (fixed)
Vendor states this is fixed in 3.12 (unaffected)
Vendor states this is fixed in 5.15.187 (unaffected)
Vendor states this is fixed in 6.1.79 (unaffected)
Vendor states this is fixed in 6.6.18 (unaffected)
Vendor states this is fixed in 6.7.6 (unaffected)
Vendor states this is fixed in 6.8 (unaffected)

References (5)

Patch
Source: 416baaa9-dc9f-4396-8d5f-8c081fb06d67
https://git.kernel.org/stable/c/02f2b95b00bf57d20320ee168b30fb7f3db8e555
Patch
Source: 416baaa9-dc9f-4396-8d5f-8c081fb06d67
https://git.kernel.org/stable/c/5571e41ec6e56e35f34ae9f5b3a335ef510e0ade
Patch
Source: 416baaa9-dc9f-4396-8d5f-8c081fb06d67
https://git.kernel.org/stable/c/7bddf18f474f166c19f91b2baf67bf7c5eda03f7
Patch
Source: 416baaa9-dc9f-4396-8d5f-8c081fb06d67
https://git.kernel.org/stable/c/a4b7741c8302e28073bfc6dd1c2e73598e5e535e

SSVC — Action Prioritization

SSVCNo known exploitNot automatablePartial impact

SSVC signals action urgency (what to patch first), separate from CVSS which measures severity.

CVSS

Attack Vector
LOCAL
Complexity
LOW
Privileges
LOW
User Interaction
NONE
Scope
UNCHANGED
Confidentiality
NONE
Integrity
NONE
Availability
HIGH
Vector?

Quick Info

StatusMODIFIED
CWE
CWE-617

Get alerted

Stop reading CVE feeds looking for your own stack

Track the products you run and VulnTracker tells you when a new CVE affects them — with what is known about fixing it, and nothing about the rest.

Free plan, no card