CVE-2025-22035
Severity CVSS v4.0:
Pending analysis
Type:
CWE-416
Use After Free
Publication date:
16/04/2025
Last modified:
03/11/2025
Description
In the Linux kernel, the following vulnerability has been resolved:<br />
<br />
tracing: Fix use-after-free in print_graph_function_flags during tracer switching<br />
<br />
Kairui reported a UAF issue in print_graph_function_flags() during<br />
ftrace stress testing [1]. This issue can be reproduced if puting a<br />
&#39;mdelay(10)&#39; after &#39;mutex_unlock(&trace_types_lock)&#39; in s_start(),<br />
and executing the following script:<br />
<br />
$ echo function_graph > current_tracer<br />
$ cat trace > /dev/null &<br />
$ sleep 5 # Ensure the &#39;cat&#39; reaches the &#39;mdelay(10)&#39; point<br />
$ echo timerlat > current_tracer<br />
<br />
The root cause lies in the two calls to print_graph_function_flags<br />
within print_trace_line during each s_show():<br />
<br />
* One through &#39;iter->trace->print_line()&#39;;<br />
* Another through &#39;event->funcs->trace()&#39;, which is hidden in<br />
print_trace_fmt() before print_trace_line returns.<br />
<br />
Tracer switching only updates the former, while the latter continues<br />
to use the print_line function of the old tracer, which in the script<br />
above is print_graph_function_flags.<br />
<br />
Moreover, when switching from the &#39;function_graph&#39; tracer to the<br />
&#39;timerlat&#39; tracer, s_start only calls graph_trace_close of the<br />
&#39;function_graph&#39; tracer to free &#39;iter->private&#39;, but does not set<br />
it to NULL. This provides an opportunity for &#39;event->funcs->trace()&#39;<br />
to use an invalid &#39;iter->private&#39;.<br />
<br />
To fix this issue, set &#39;iter->private&#39; to NULL immediately after<br />
freeing it in graph_trace_close(), ensuring that an invalid pointer<br />
is not passed to other tracers. Additionally, clean up the unnecessary<br />
&#39;iter->private = NULL&#39; during each &#39;cat trace&#39; when using wakeup and<br />
irqsoff tracers.<br />
<br />
[1] https://lore.kernel.org/all/20231112150030.84609-1-ryncsn@gmail.com/
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:*:*:*:*:*:*:*:* | 4.14.324 (including) | 4.15 (excluding) |
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 4.19.293 (including) | 4.20 (excluding) |
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 5.4.255 (including) | 5.4.292 (excluding) |
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 5.10.193 (including) | 5.10.236 (excluding) |
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 5.15.129 (including) | 5.15.180 (excluding) |
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 6.1.50 (including) | 6.1.134 (excluding) |
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 6.4.13 (including) | 6.6.87 (excluding) |
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 6.7 (including) | 6.12.23 (excluding) |
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 6.13 (including) | 6.13.11 (excluding) |
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 6.14 (including) | 6.14.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/099ef3385800828b74933a96c117574637c3fb3a
- https://git.kernel.org/stable/c/42561fe62c3628ea3bc9623f64f047605e98857f
- https://git.kernel.org/stable/c/70be951bc01e4a0e10d443f3510bb17426f257fb
- https://git.kernel.org/stable/c/7f81f27b1093e4895e87b74143c59c055c3b1906
- https://git.kernel.org/stable/c/81a85b12132c8ffe98f5ddbdc185481790aeaa1b
- https://git.kernel.org/stable/c/a2cce54c1748216535dda02e185d07a084be837e
- https://git.kernel.org/stable/c/c85efe6e13743cac6ba4ccf144cb91f44c86231a
- https://git.kernel.org/stable/c/de7b309139f862a44379ecd96e93c9133c69f813
- https://git.kernel.org/stable/c/f14752d66056d0c7bffe5092130409417d3baa70
- https://lists.debian.org/debian-lts-announce/2025/05/msg00030.html
- https://lists.debian.org/debian-lts-announce/2025/05/msg00045.html



