CVE-2024-40935 in Linuxinfo

Summary

by MITRE • 07/12/2024

In the Linux kernel, the following vulnerability has been resolved:

cachefiles: flush all requests after setting CACHEFILES_DEAD

In ondemand mode, when the daemon is processing an open request, if the kernel flags the cache as CACHEFILES_DEAD, the cachefiles_daemon_write() will always return -EIO, so the daemon can't pass the copen to the kernel. Then the kernel process that is waiting for the copen triggers a hung_task.

Since the DEAD state is irreversible, it can only be exited by closing /dev/cachefiles. Therefore, after calling cachefiles_io_error() to mark the cache as CACHEFILES_DEAD, if in ondemand mode, flush all requests to avoid the above hungtask. We may still be able to read some of the cached data before closing the fd of /dev/cachefiles.

Note that this relies on the patch that adds reference counting to the req, otherwise it may UAF.

Be aware that VulDB is the high quality source for vulnerability data.

Analysis

by VulDB Data Team • 09/17/2025

The vulnerability CVE-2024-40935 resides within the Linux kernel's cachefiles subsystem, specifically addressing a critical race condition and resource management issue that can lead to system instability and potential denial of service conditions. This flaw manifests in the ondemand operation mode of the cachefiles daemon, where the kernel's handling of cache state transitions creates a scenario that can result in indefinite task hanging. The core issue stems from the improper management of request processing when the cache transitions to the irreversible CACHEFILES_DEAD state, which fundamentally impacts the daemon's ability to properly handle open requests and maintain system responsiveness.

The technical implementation of this vulnerability involves a specific sequence of events that occurs during cache state management within the kernel's cachefiles subsystem. When the daemon operates in ondemand mode and encounters an open request while the kernel has already marked the cache as CACHEFILES_DEAD, the cachefiles_daemon_write() function consistently returns -EIO error codes, effectively preventing the daemon from successfully passing the copen operation to the kernel. This creates a deadlock scenario where kernel processes waiting for the copen operation become stuck in a hung_task state, as the system cannot proceed with the normal request processing flow. The fundamental flaw lies in the lack of proper request flushing mechanisms when transitioning to the irreversible DEAD state, which prevents the system from gracefully handling the termination condition.

The operational impact of this vulnerability extends beyond simple system performance degradation to potentially creating complete system lockups that require manual intervention. The hung_task condition that results from this vulnerability can cause the entire system to become unresponsive, as kernel threads remain stuck indefinitely waiting for resources that will never become available. This represents a significant security and stability concern, particularly in production environments where system availability is critical. The vulnerability affects systems using the Linux kernel's cachefiles functionality, which is commonly employed in enterprise storage solutions and caching mechanisms that rely on the kernel's file caching infrastructure for performance optimization.

Mitigation strategies for this vulnerability must address both the immediate race condition and the underlying resource management issues. The recommended approach involves implementing proper request flushing mechanisms when transitioning to the CACHEFILES_DEAD state, ensuring that all pending requests are properly processed or canceled before allowing the cache to enter the irreversible state. This solution aligns with the established principle of defensive programming and proper resource cleanup in kernel space operations. Additionally, the fix requires careful consideration of reference counting mechanisms to prevent use-after-free conditions, as noted in the vulnerability description. Organizations should prioritize applying the kernel patches that address this specific issue, particularly those that implement proper request flushing and reference counting for cachefiles requests. The solution also emphasizes the importance of proper state management and the need for robust error handling in kernel subsystems that operate in concurrent environments where multiple processes may be accessing shared resources simultaneously.

This vulnerability demonstrates the critical importance of proper state transition management in kernel subsystems and aligns with common security patterns identified in the CWE database, specifically relating to improper handling of resource states and race conditions. The ATT&CK framework would categorize this vulnerability under privilege escalation and denial of service techniques, as it can be exploited to create system instability and potentially gain unauthorized access to system resources. The fix for CVE-2024-40935 represents a fundamental improvement in kernel resource management and demonstrates the importance of comprehensive testing for edge cases in kernel development, particularly in subsystems that handle file caching and resource management operations.

Responsible

Linux

Reservation

07/12/2024

Disclosure

07/12/2024

Moderation

accepted

CPE

ready

EPSS

0.00259

KEV

no

Activities

very low

Sources

Interested in the pricing of exploits?

See the underground prices here!