CVE-2023-52854
Severity CVSS v4.0:
Pending analysis
Type:
CWE-416
Use After Free
Publication date:
21/05/2024
Last modified:
03/02/2025
Description
In the Linux kernel, the following vulnerability has been resolved:<br />
<br />
padata: Fix refcnt handling in padata_free_shell()<br />
<br />
In a high-load arm64 environment, the pcrypt_aead01 test in LTP can lead<br />
to system UAF (Use-After-Free) issues. Due to the lengthy analysis of<br />
the pcrypt_aead01 function call, I&#39;ll describe the problem scenario<br />
using a simplified model:<br />
<br />
Suppose there&#39;s a user of padata named `user_function` that adheres to<br />
the padata requirement of calling `padata_free_shell` after `serial()`<br />
has been invoked, as demonstrated in the following code:<br />
<br />
```c<br />
struct request {<br />
struct padata_priv padata;<br />
struct completion *done;<br />
};<br />
<br />
void parallel(struct padata_priv *padata) {<br />
do_something();<br />
}<br />
<br />
void serial(struct padata_priv *padata) {<br />
struct request *request = container_of(padata,<br />
struct request,<br />
padata);<br />
complete(request->done);<br />
}<br />
<br />
void user_function() {<br />
DECLARE_COMPLETION(done)<br />
padata->parallel = parallel;<br />
padata->serial = serial;<br />
padata_do_parallel();<br />
wait_for_completion(&done);<br />
padata_free_shell();<br />
}<br />
```<br />
<br />
In the corresponding padata.c file, there&#39;s the following code:<br />
<br />
```c<br />
static void padata_serial_worker(struct work_struct *serial_work) {<br />
...<br />
cnt = 0;<br />
<br />
while (!list_empty(&local_list)) {<br />
...<br />
padata->serial(padata);<br />
cnt++;<br />
}<br />
<br />
local_bh_enable();<br />
<br />
if (refcount_sub_and_test(cnt, &pd->refcnt))<br />
padata_free_pd(pd);<br />
}<br />
```<br />
<br />
Because of the high system load and the accumulation of unexecuted<br />
softirq at this moment, `local_bh_enable()` in padata takes longer<br />
to execute than usual. Subsequently, when accessing `pd->refcnt`,<br />
`pd` has already been released by `padata_free_shell()`, resulting<br />
in a UAF issue with `pd->refcnt`.<br />
<br />
The fix is straightforward: add `refcount_dec_and_test` before calling<br />
`padata_free_pd` in `padata_free_shell`.
Impact
Base Score 3.x
7.80
Severity 3.x
HIGH
Vulnerable products and versions
CPE | From | Up to |
---|---|---|
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 3.16.84 (including) | 3.17 (excluding) |
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 4.4.215 (including) | 4.5 (excluding) |
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 4.9.215 (including) | 4.10 (excluding) |
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 4.14.172 (including) | 4.15 (excluding) |
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 4.19.103 (including) | 4.20 (excluding) |
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 5.4.19 (including) | 5.5 (excluding) |
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 5.5.3 (including) | 5.10.201 (excluding) |
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 5.11 (including) | 5.15.139 (excluding) |
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 5.16 (including) | 6.1.63 (excluding) |
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 6.2 (including) | 6.5.12 (excluding) |
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 6.6 (including) | 6.6.2 (excluding) |
To consult the complete list of CPE names with products and versions, see this page
References to Advisories, Solutions, and Tools
- https://git.kernel.org/stable/c/0dd34a7ad395dbcf6ae60e48e9786050e25b9bc5
- https://git.kernel.org/stable/c/1734a79e951914f1db2c65e635012a35db1c674b
- https://git.kernel.org/stable/c/1e901bcb8af19416b65f5063a4af7996e5a51d7f
- https://git.kernel.org/stable/c/41aad9d6953984d134fc50f631f24ef476875d4d
- https://git.kernel.org/stable/c/7ddc21e317b360c3444de3023bcc83b85fabae2f
- https://git.kernel.org/stable/c/c7c26d0ef5d20f00dbb2ae3befcabbe0efa77275
- https://git.kernel.org/stable/c/0dd34a7ad395dbcf6ae60e48e9786050e25b9bc5
- https://git.kernel.org/stable/c/1734a79e951914f1db2c65e635012a35db1c674b
- https://git.kernel.org/stable/c/1e901bcb8af19416b65f5063a4af7996e5a51d7f
- https://git.kernel.org/stable/c/41aad9d6953984d134fc50f631f24ef476875d4d
- https://git.kernel.org/stable/c/7ddc21e317b360c3444de3023bcc83b85fabae2f
- https://git.kernel.org/stable/c/c7c26d0ef5d20f00dbb2ae3befcabbe0efa77275