CVE-2024-56759: btrfs: fix use-after-free when COWing tree bock and tracing is enabled
In the Linux kernel, the following vulnerability has been resolved:
btrfs: fix use-after-free when COWing tree bock and tracing is enabled
When a COWing a tree block, at btrfs_cow_block(), and we have the
tracepoint trace_btrfs_cow_block() enabled and preemption is also enabled
(CONFIG_PREEMPT=y), we can trigger a use-after-free in the COWed extent
buffer while inside the tracepoint code. This is because in some paths
that call btrfs_cow_block(), such as btrfs_search_slot(), we are holding
the last reference on the extent buffer @buf so btrfs_force_cow_block()
drops the last reference on the @buf extent buffer when it calls
free_extent_buffer_stale(buf), which schedules the release of the extent
buffer with RCU. This means that if we are on a kernel with preemption,
the current task may be preempted before calling trace_btrfs_cow_block()
and the extent buffer already released by the time trace_btrfs_cow_block()
is called, resulting in a use-after-free.
Fix this by moving the trace_btrfs_cow_block() from btrfs_cow_block() to
btrfs_force_cow_block() before the COWed extent buffer is freed.
This also has a side effect of invoking the tracepoint in the tree defrag
code, at defrag.c:btrfs_realloc_node(), since btrfs_force_cow_block() is
called there, but this is fine and it was actually missing there.
Security readout for executives and security teams
Plain-English summary
A Linux Btrfs flaw can access freed kernel memory while copying filesystem metadata under specific tracing and preemption conditions. Successful triggering could seriously affect system confidentiality, integrity, or availability. Exposure requires Btrfs, kernel preemption, and the relevant tracepoint, so risk is concentrated rather than universal.
Executive priority
Treat as a high-priority kernel maintenance issue for Btrfs hosts permitting untrusted local access. Patch those systems promptly after vendor validation. Systems without Btrfs, preemption, or the tracepoint conditions have materially lower immediate exposure, but version and configuration checks are still required.
Technical view
CVE-2024-56759 is a CWE-416 use-after-free in Btrfs tree-block copy-on-write handling. With CONFIG_PREEMPT=y and trace_btrfs_cow_block enabled, preemption can allow RCU to release the old extent buffer before tracing accesses it. The fix moves tracing into btrfs_force_cow_block before the buffer is freed.
Likely exposure
Potentially exposed systems run an affected Linux kernel, use Btrfs, enable CONFIG_PREEMPT, and activate the affected tracepoint. The supplied CVSS vector requires local access with low privileges and no user interaction. The bundle's version data is ambiguous, so confirm status against distribution or kernel-vendor advisories.
Exploitation context
The supplied CVSS score is 7.8 and describes local, low-complexity exploitation with low privileges. The source bundle marks this CVE as absent from KEV and provides no evidence of active exploitation or a public exploit. Practical triggerability depends on tracing, preemption, and Btrfs activity.
Researcher notes
The vulnerable ordering occurs when btrfs_force_cow_block drops the final extent-buffer reference and schedules RCU release before trace_btrfs_cow_block reads it. Preemption creates the race window. The upstream correction invokes tracing before freeing the COWed buffer. The supplied sources do not establish exploit reliability or observed attacks.
Mitigation direction
Upgrade to a vendor-supported kernel containing the applicable upstream stable fix.
Consult the Linux distribution or appliance vendor for precise fixed package versions.
Until patched, avoid enabling the affected Btrfs tracepoint where operationally feasible.
Prioritize multi-user systems where untrusted local users can access affected hosts.
Validation and detection
Inventory systems using Btrfs and record their running kernel versions.
Confirm whether each kernel was built with CONFIG_PREEMPT enabled.
Determine whether trace_btrfs_cow_block can be or is currently enabled.
Map installed kernel packages to vendor advisories and applicable stable fixes.
After updating, reboot and verify the running kernel matches the fixed package.
Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.
Potential ATT&CK relevance
Conservative CVE-to-ATT&CK context
These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.
ATT&CK lookup starting points
Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.
cwe · low confidence lookup
CWE-416: Exact CWE lookup
Use the exact CWE identifier as the starting point before reviewing related ATT&CK behavior. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.
These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.
2CVSS vectors
3Timeline events
2ADP providers
9Source links
SSVC decision data
CISA-ADPCISA Coordinator
Timestamp
Version
2.0.3
Exploitation: noneAutomatable: noTechnical Impact: total
CVSS vector scores
2 official scores
We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.
CWE links open Glexia weakness intelligence pages with official CWE context, developer remediation guidance, and related CVE mappings.
CWE-416 · source CWE mapping
Use After Free
Use After Free represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.