CVE-2025-22035: tracing: Fix use-after-free in print_graph_function_flags during tracer switching

Published Apr 16, 2025
·
Updated

In the Linux kernel, the following vulnerability has been resolved:

tracing: Fix use-after-free in printgraphfunctionflags during tracer switching

Kairui reported a UAF issue in printgraphfunctionflags() during ftrace stress testing [1]. This issue can be reproduced if puting a 'mdelay(10)' after 'mutexunlock(&tracetypeslock)' in sstart(), and executing the following script:

$ echo functiongraph > currenttracer $ cat trace > /dev/null & $ sleep 5 # Ensure the 'cat' reaches the 'mdelay(10)' point $ echo timerlat > currenttracer

The root cause lies in the two calls to printgraphfunctionflags within printtraceline during each sshow():

One through 'iter->trace->printline()'; Another through 'event->funcs->trace()', which is hidden in printtracefmt() before printtraceline returns.

Tracer switching only updates the former, while the latter continues to use the printline function of the old tracer, which in the script above is printgraphfunctionflags.

Moreover, when switching from the 'functiongraph' tracer to the 'timerlat' tracer, sstart only calls graphtraceclose of the 'functiongraph' tracer to free 'iter->private', but does not set it to NULL. This provides an opportunity for 'event->funcs->trace()' to use an invalid 'iter->private'.

To fix this issue, set 'iter->private' to NULL immediately after freeing it in graphtraceclose(), ensuring that an invalid pointer is not passed to other tracers. Additionally, clean up the unnecessary 'iter->private = NULL' during each 'cat trace' when using wakeup and irqsoff tracers.

[1] https://lore.kernel.org/all/20231112150030.84609-1-ryncsn@gmail.com/

Affected Software

14 affected componentsFixes available
Linux Linux kernel
Linux Linux kernel>=4.14.324<4.15
Linux Linux kernel>=4.19.293<4.20
Linux Linux kernel>=5.4.255<5.4.292
Linux Linux kernel>=5.10.193<5.10.236
Linux Linux kernel>=5.15.129<5.15.180
Linux Linux kernel>=6.1.50<6.1.134
Linux Linux kernel>=6.4.13<6.6.87
Linux Linux kernel>=6.7<6.12.23
Linux Linux kernel>=6.13<6.13.11
Linux Linux kernel>=6.14<6.14.2
Microsoft cbl2 kernel 5.15.176.3-3<5.15.180.1-1
5.15.180.1-1
Microsoft azl3 kernel 6.6.85.1-4<6.6.92.2-1
6.6.92.2-1
Microsoft cbl2 kernel 5.15.180.1-1<5.15.180.1-1
5.15.180.1-1

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade to a fixed release to a version that resolves this vulnerability.

    Fixed in 5.15.180.1-1
  2. Upgrade

    Upgrade to a fixed release to a version that resolves this vulnerability.

    Fixed in 6.6.92.2-1
  3. Configuration

    Apply the described fix: set 'iter->private' to NULL immediately after it is freed in 'graph_trace_close()', preventing an invalid 'iter->private' from being used by other tracers when tracer switching occurs (where the second call path in print_trace_line uses the old/tracer print_line function).

    Linux kernel ftrace function_graph tracer switching iter->private cleanup timing in print_graph_function_flags / graph_trace_close = Set iter->private = NULL immediately after freeing iter->private (after graph_trace_close()) to ensure an invalid pointer is not passed to other tracers during tracer switching; ensure it is set to NULL during each cat trace/wakeup path when using mdelay(10) after mutex_unlock(&trace_types_lock) in s_start()

Event History

Apr 16, 2025
CVE Published
via MITRE·02:11 PM
Data Sourced
via MITRE·02:11 PM
DescriptionSeverity
Data Sourced
via NVD·03:15 PM
RemedyDescriptionSeverityWeaknessAffected Software
May 5, 2025
Data Sourced
via Microsoft·07:00 AM
DescriptionSeverityWeakness
Data Sourced
via Microsoft·07:00 AM
Affected Software
Updated
via Microsoft·07:00 AM
Severity
Updated
via Microsoft·07:00 AM
Affected Software
Updated
via Microsoft·07:00 AM
DescriptionSeverity

Frequently Asked Questions

1

What is the severity of CVE-2025-22035?

CVE-2025-22035 has a medium severity rating, indicating potential risk but not immediate critical exposure.

2

How do I fix CVE-2025-22035?

To fix CVE-2025-22035, you should update your Linux kernel to the latest version where this vulnerability has been addressed.

3

What systems are affected by CVE-2025-22035?

CVE-2025-22035 affects the Linux kernel, particularly those versions that utilize the ftrace functionality for tracing.

4

What kind of attack does CVE-2025-22035 enable?

CVE-2025-22035 can potentially allow an attacker to exploit a use-after-free condition, leading to system instability or possible arbitrary code execution.

5

Is there a workaround for CVE-2025-22035?

There is no known workaround for CVE-2025-22035, so updating the kernel is the recommended action.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203