CVE-2024-40935 cachefiles: flush all requests after setting CACHEFILES_DEAD
A use-after-free vulnerability in the Linux kernel's cachefiles subsystem can cause a denial of service or potential code execution when the cache enters a dead state.
- Exploited in the wild
- Not known
- Login needed
- Any signed-in user
- Attackable
- Local or same network only
- Victim action needed
- Not needed
- Fix
- Available
What is CVE-2024-40935?
CVE-2024-40935 is a high-severity use after free vulnerability in Linux kernel, published on 12 Jul 2024. It can only be exploited from the same machine or local network, with no action from the victim.
Official description
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.
Weakness: CWE-416
Which versions are affected by CVE-2024-40935?
It affects 1 product.
Products include Linux kernel.
How do I fix CVE-2024-40935?
Apply the vendor's patch.
Upgrade to the fixed version. These bugs are found with fuzzing and sanitisers and avoided by memory-safe languages. More about Use after free.
Is CVE-2024-40935 being exploited?
There is no known exploitation of CVE-2024-40935 in the wild and no public exploit code.
Other vulnerabilities in Linux kernel
Sources
Also known as BELL-CVE-2024-40935, DEBIAN-CVE-2024-40935, GHSA-rqgv-9mjq-566p, UBUNTU-CVE-2024-40935.