Baokun Li

Researcher fromHuawei
#1136of 53,633
187.6Total CVSS
Vulnerabilities · 28
Medium
13
High
15
PT-2024-5424
7.8
2024-06-21
Linux · Linux Kernel · CVE-2024-40899
**Name of the Vulnerable Software and Affected Versions** Linux kernel versions prior to 6.8.0-rc7-dirty #542 **Description** The issue is caused by a slab-use-after-free vulnerability in the `cachefiles ondemand daemon read` function. This occurs when a restore command is issued while the daemon is still alive, resulting in a request being processed multiple times and triggering a use-after-free (UAF) error. The vulnerability can be exploited by issuing a restore command when the daemon is still alive. Technical details about exploitation include: - The `cachefiles ondemand get fd` function is vulnerable to a UAF error. - The `REQ A` variable is used to store a request, and its `done` field is waited on using `wait for completion`. - The `cachefiles ondemand daemon read` function reads data from a file descriptor, and the `copy to user` function is used to copy data to a user-space buffer. - The `xas for each` function is used to iterate over a set of requests, and the `xas set mark` function is used to set a mark on a request. - The `cachefiles ondemand restore` function is used to restore a request, and the `xa erase` function is used to erase a request from a cache. **Recommendations** To resolve the issue, add an additional reference count to `cachefiles req`, which is held while waiting and reading, and then released when the waiting and reading is over. As a temporary workaround, consider disabling the `cachefiles ondemand daemon read` function until a patch is available. Restrict access to the vulnerable `cachefiles ondemand get fd` function to minimize the risk of exploitation. Avoid using the `REQ A` variable in the affected API endpoint until the issue is resolved.