CVE-2024-56759: btrfs: fix use-after-free when COWing tree bock and tracing is enabled

Published Jan 6, 2025
·
Updated

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

7 affected componentsFixes available
Linux Linux kernel<6.12.8
Linux Linux kernel=6.13-rc1
Linux Linux kernel=6.13-rc2
Linux Linux kernel=6.13-rc3
Linux Linux kernel=6.13-rc4
debian/linux<=5.10.223-1
5.10.234-16.1.129-16.1.135-16.12.25-1
debian/linux-6.1
6.1.129-1~deb11u1

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade debian/linux to 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
  2. Upgrade

    Upgrade debian/linux-6.1 to a version that resolves this vulnerability.

    Fixed in 6.1.129-1~deb11u1
  3. 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

Jan 6, 2025
CVE Published
via MITRE·04:20 PM
Data Sourced
via MITRE·04:20 PM
DescriptionSeverity
Data Sourced
via NVD·05:15 PM
RemedyDescriptionSeverityWeaknessAffected Software
Mar 27, 2025
Data Sourced
via Launchpad·06:47 PM
Description
May 2, 2025
Data Sourced
via Ubuntu·06:55 PM
RemedyDescriptionSeverityAffected Software

Frequently Asked Questions

1

What is the severity of CVE-2024-56759?

CVE-2024-56759 is classified as a high-severity vulnerability affecting the Linux kernel.

2

How do I fix CVE-2024-56759?

To fix CVE-2024-56759, update the Linux kernel to version 6.12.8 or later.

3

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.

4

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.

5

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.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203