CVE-2024-41087 Overview
CVE-2024-41087 is a double free vulnerability discovered in the Linux kernel's libata-core component, specifically within the ATA host allocation error handling path. The flaw occurs when ata_port_alloc() fails during ata_host_alloc() execution, leading to improper memory management where the host structure is freed twice—once through devres_release_group() calling ata_host_release(), and again directly via kfree(host) in the error handling code.
Critical Impact
Local attackers with low privileges can trigger a kernel panic or potentially achieve code execution by exploiting this double free condition in the memory allocator, resulting in system instability or complete compromise.
Affected Products
- Linux Kernel (multiple versions with libata-core component)
- Systems using AHCI storage controllers
- Debian Linux (addressed in LTS announcement)
Discovery Timeline
- 2024-07-29 - CVE-2024-41087 published to NVD
- 2025-11-03 - Last updated in NVD database
Technical Details for CVE-2024-41087
Vulnerability Analysis
This vulnerability represents a classic double free memory corruption issue (CWE-415) in the Linux kernel's ATA subsystem. The root cause lies in improper coordination between the device resource management (devres) framework and explicit memory deallocation in error paths.
When ata_host_alloc() encounters a failure—for example, if ata_port_alloc() returns an error—the function jumps to its err_out label. This triggers a call to devres_release_group(), which in turn invokes ata_host_release(). The ata_host_release() function includes a kfree(host) call to free the host structure. However, the error handling code in ata_host_alloc() also contains a separate kfree(host) call, resulting in the same memory being freed twice.
The kernel stack trace provided in the vulnerability report confirms this behavior, showing the crash occurring in kfree+0x2cf/0x2f0 with an "invalid opcode" exception at mm/slub.c:553, which is the SLUB allocator's detection of a double free condition.
Root Cause
The vulnerability stems from a logic error in the ata_host_alloc() function's error handling path. The code failed to account for the fact that when devres_open_group() succeeds and a subsequent operation fails, calling devres_release_group() will automatically release all resources managed by that group—including the host structure via the registered ata_host_release() callback. The additional explicit kfree(host) call in the error path therefore operates on already-freed memory.
Attack Vector
The attack requires local access to the system. An attacker with low privileges could potentially trigger this vulnerability by manipulating conditions that cause ata_port_alloc() or other allocation functions to fail during ATA host initialization. This could be achieved through:
- Exhausting system memory to force allocation failures
- Loading/unloading kernel modules that interact with the ATA subsystem
- Triggering device hotplug events that exercise the vulnerable code path
The vulnerability manifests in the ata_host_alloc() function within the libata-core module. When allocation fails after the device resource group is opened, the cleanup path incorrectly frees the host structure twice. The fix ensures kfree(host) is only called if devres_open_group() failed, preventing the double free condition.
Detection Methods for CVE-2024-41087
Indicators of Compromise
- Kernel panic messages containing "kernel BUG at mm/slub.c" with invalid opcode errors
- Stack traces showing kfree called from ata_host_alloc or related libata functions
- System crashes during ATA/AHCI device initialization or hotplug events
- Kernel log entries indicating double free detection in the SLUB allocator
Detection Strategies
- Monitor kernel logs (dmesg, /var/log/kern.log) for SLUB allocator warnings or BUG messages related to double free conditions
- Implement kernel crash dump analysis (kdump/crash) to identify exploitation attempts targeting this vulnerability
- Deploy runtime memory debugging tools like KASAN (Kernel Address Sanitizer) to detect memory corruption in development/testing environments
- Use SentinelOne's kernel-level monitoring capabilities to detect anomalous behavior in the ATA subsystem
Monitoring Recommendations
- Enable kernel debugging options (CONFIG_DEBUG_SLAB, CONFIG_KASAN) in non-production environments to catch memory corruption issues
- Monitor for unusual patterns of module loading/unloading involving libata or ahci modules
- Track system stability metrics and correlate unexpected reboots with storage subsystem activity
- Implement centralized log aggregation to identify patterns of exploitation attempts across multiple systems
How to Mitigate CVE-2024-41087
Immediate Actions Required
- Update the Linux kernel to a patched version as soon as available from your distribution
- Review and apply patches from the official kernel git repository for affected kernel versions
- Monitor systems running vulnerable kernel versions for signs of exploitation
- Consider restricting local user access on critical systems until patches are applied
Patch Information
The Linux kernel development team has released patches addressing this vulnerability across multiple stable kernel branches. The fix modifies the error handling logic in ata_host_alloc() to only call kfree(host) when devres_open_group() fails, preventing the double free condition.
Official patches are available from the following kernel git commits:
- Linux Kernel Commit 010de9a
- Linux Kernel Commit 062e256
- Linux Kernel Commit 290073b
- Linux Kernel Commit 56f1c7e
- Linux Kernel Commit 5dde5f8
- Linux Kernel Commit 702c1ed
- Linux Kernel Commit 8106da4
- Linux Kernel Commit ab9e0c5
Debian users should refer to the Debian LTS Announcement for distribution-specific updates.
Workarounds
- Limit local user access to systems running vulnerable kernel versions to reduce the attack surface
- Implement resource quotas (ulimit) to make memory exhaustion attacks more difficult
- Monitor and restrict module loading/unloading operations on production systems
- Consider using kernel lockdown mode to prevent unauthorized kernel modifications
# Check current kernel version for vulnerability assessment
uname -r
# Verify if libata module is loaded
lsmod | grep libata
# Monitor kernel logs for double free warnings
dmesg | grep -i "double free\|slub\|kfree"
# Restrict module loading (requires root)
echo 1 > /proc/sys/kernel/modules_disabled
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

