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 btrfscowblock(), and we have the tracepoint tracebtrfscowblock() enabled and preemption is also enabled (CONFIGPREEMPT=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 btrfscowblock(), such as btrfssearchslot(), we are holding the last reference on the extent buffer @buf so btrfsforcecowblock() drops the last reference on the @buf extent buffer when it calls freeextentbufferstale(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 tracebtrfscowblock() and the extent buffer already released by the time tracebtrfscowblock() is called, resulting in a use-after-free.
Fix this by moving the tracebtrfscowblock() from btrfscowblock() to btrfsforcecowblock() 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:btrfsreallocnode(), since btrfsforcecowblock() is called there, but this is fine and it was actually missing there.
Other sources
This CVE was automatically created from a reference found in an email or other text. If you are reading this, then this CVE entry is probably erroneous, since this text should be replaced by the official CVE description automatically.
— Launchpad
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
debian/linuxto a version that resolves this vulnerability.Fixed in 5.10.234-1Fixed in 6.1.129-1Fixed in 6.1.135-1Fixed in 6.12.25-1 - Upgrade
Upgrade
debian/linux-6.1to a version that resolves this vulnerability.Fixed in 6.1.129-1~deb11u1 - Configuration
Disable the btrfs tracepoint trace_btrfs_cow_block() to avoid the use-after-free when COWing tree blocks under CONFIG_PREEMPT=y.
Linux kernel btrfs tracepoint trace_btrfs_cow_block() trace_btrfs_cow_block (enabled/disabled) = disabled
Event History
Frequently Asked Questions
What is the severity of CVE-2024-56759?
CVE-2024-56759 is classified as a high-severity vulnerability affecting the Linux kernel.
How do I fix CVE-2024-56759?
To fix CVE-2024-56759, update the Linux kernel to version 6.12.8 or later.
What systems are affected by CVE-2024-56759?
CVE-2024-56759 affects multiple versions of the Linux kernel, specifically versions up to 6.12.8 and certain 6.13 release candidates.
What does CVE-2024-56759 involve?
CVE-2024-56759 involves a use-after-free vulnerability occurring during copy-on-write operations in the btrfs file system.
Is there any mitigation for CVE-2024-56759?
Disabling tracing and preemption in the kernel may mitigate the effects of CVE-2024-56759 until a patch is applied.