CVE-2024-40913 cachefiles: defer exposing anon_fd until after copy_to_user() succeeds
A use-after-free vulnerability in the Linux kernel cachefiles subsystem allows local attackers to potentially execute code or escalate privileges.
- 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-40913?
CVE-2024-40913 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: defer exposing anon_fd until after copy_to_user() succeeds
After installing the anonymous fd, we can now see it in userland and close it. However, at this point we may not have gotten the reference count of the cache, but we will put it during colse fd, so this may cause a cache UAF.
So grab the cache reference count before fd_install(). In addition, by kernel convention, fd is taken over by the user land after fd_install(), and the kernel should not call close_fd() after that, i.e., it should call fd_install() after everything is ready, thus fd_install() is called after copy_to_user() succeeds.
Weakness: CWE-416
Which versions are affected by CVE-2024-40913?
It affects 1 product.
Products include Linux kernel.
How do I fix CVE-2024-40913?
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-40913 being exploited?
There is no known exploitation of CVE-2024-40913 in the wild and no public exploit code.
Other vulnerabilities in Linux kernel
Sources
Also known as BELL-CVE-2024-40913, DEBIAN-CVE-2024-40913, GHSA-7542-c7w8-qr6j, UBUNTU-CVE-2024-40913.