Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB
CVE-2024-56582 Overview
CVE-2024-56582 is a use-after-free vulnerability in the Linux kernel Btrfs filesystem, specifically in the btrfs_encoded_read_endio() function. The flaw was discovered when fstests' btrfs/284 test triggered a KASAN slab-use-after-free report on a TCMU runner device. The bug involves a race between the endio completion handler and the thread freeing the private data structure allocated by btrfs_encoded_read_regular_fill_pages(). A local attacker with filesystem access could trigger kernel memory corruption, leading to privilege escalation, denial of service, or information disclosure. The vulnerability is tracked under [CWE-416: Use After Free].
Critical Impact
Local exploitation can corrupt kernel memory via the Btrfs encoded read I/O path, enabling privilege escalation or system crash.
Affected Products
- Linux kernel versions prior to the fix commits
- Linux kernel 6.13-rc1
- Distributions tracking the stable kernel branches (Debian LTS advisory issued March 2025)
Discovery Timeline
- 2024-12-27 - CVE-2024-56582 published to the National Vulnerability Database (NVD)
- 2025-03 - Debian LTS advisory published addressing the vulnerability
- 2026-06-17 - Last updated in NVD database
Technical Details for CVE-2024-56582
Vulnerability Analysis
The vulnerability resides in the Btrfs encoded read path used by the BTRFS_IOC_SEND ioctl. When btrfs_encoded_read_regular_fill_pages() submits bios and waits for completion, it allocates a private structure that is referenced by the endio callback btrfs_encoded_read_endio(). Under certain timing conditions, the waiter thread observes completion and frees the structure before the endio handler finishes dereferencing it to call __wake_up(). The KASAN report shows a slab-use-after-free of 8 bytes inside a 96-byte object allocated from kmalloc-rnd-07-96, triggered during lock_release() inside __wake_up(). This classic completion-vs-free race corrupts the wait queue head after the memory has been returned to the slab allocator.
Root Cause
The root cause is incorrect lifetime management of the shared private structure between the producer (btrfs_encoded_read_regular_fill_pages) and the consumer (btrfs_encoded_read_endio). The waiter frees the object once it observes the atomic pending counter reach zero, but the endio handler still needs to touch the embedded wait queue after decrementing that counter. Without a reference count or a separate owning context, the endio code races with kfree().
Attack Vector
Exploitation requires local access and permission to invoke Btrfs ioctls such as BTRFS_IOC_SEND, which exercises the encoded read regular fill pages path. An attacker schedules repeated send operations on crafted subvolumes while competing I/O workloads create the completion race window. Successful triggering corrupts freed slab memory touched by the endio callback, which can be converted into privilege escalation using standard heap-grooming techniques against the kmalloc-rnd-07-96 cache. No network access or user interaction is required.
No verified proof-of-concept code is published for this issue. The upstream KASAN trace in the kernel advisory documents the exact faulting path through btrfs_check_read_bio → btrfs_encoded_read_endio → __wake_up → lock_release. Refer to the Linux Kernel Commit 05b36b04 and related stable patches for the full fix.
Detection Methods for CVE-2024-56582
Indicators of Compromise
- KASAN reports containing slab-use-after-free in lock_release with a call trace referencing btrfs_encoded_read_endio and btrfs_check_read_bio.
- Unexpected kernel oopses or panics originating from the btrfs-endio workqueue (btrfs_end_bio_work).
- dmesg entries showing bad accesses inside the kmalloc-rnd-07-96 slab cache correlated with Btrfs send operations.
Detection Strategies
- Monitor kernel ring buffer and /var/log/kern.log for KASAN or oops signatures tied to Btrfs endio paths on hosts running vulnerable kernels.
- Audit which local users and containers hold CAP_SYS_ADMIN or can issue BTRFS_IOC_SEND, since the vulnerable code path is reachable through that ioctl.
- Compare the running kernel version against the fixed stable commits listed in the vendor advisories to identify unpatched systems.
Monitoring Recommendations
- Centralize kernel logs and alert on signatures matching btrfs_encoded_read_endio, btrfs_check_read_bio, or sudden btrfs-endio workqueue crashes.
- Track process execution of btrfs send and direct ioctl callers that invoke Btrfs encoded reads on multi-tenant systems.
- Correlate kernel crash telemetry with the kernel build identifier to confirm patch coverage across the fleet.
How to Mitigate CVE-2024-56582
Immediate Actions Required
- Update the Linux kernel to a stable release containing the fix commits 05b36b04, 6228f13f, a40de033, or f8a5129e.
- Apply distribution kernel updates such as the Debian LTS advisory published in March 2025.
- Restrict local shell and container access to trusted users on hosts that cannot be patched immediately.
Patch Information
The upstream fix is distributed across four stable backports: Linux Kernel Commit 05b36b04, Linux Kernel Commit 6228f13f, Linux Kernel Commit a40de033, and Linux Kernel Commit f8a5129e. Debian users should follow the Debian LTS Announcement March 2025 for packaged kernel updates.
Workarounds
- Limit access to the BTRFS_IOC_SEND ioctl by restricting users and containers that can run btrfs send against Btrfs subvolumes.
- Avoid exposing Btrfs filesystems to untrusted local users on hosts running an unpatched kernel.
- Consider temporarily switching workloads to a non-Btrfs filesystem on multi-tenant hosts until kernel updates are deployed.
# Verify running kernel version and confirm it includes the fix
uname -r
# Debian/Ubuntu: apply kernel updates
sudo apt update && sudo apt upgrade linux-image-$(uname -r | sed 's/.*-//')
# RHEL/Fedora: apply kernel updates
sudo dnf update kernel
# Reboot to activate the patched kernel
sudo systemctl reboot
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB

