CVE-2025-38170: arm64/fpsimd: Discard stale CPU state when handling SME traps
In the Linux kernel, the following vulnerability has been resolved:
arm64/fpsimd: Discard stale CPU state when handling SME traps
The logic for handling SME traps manipulates saved FPSIMD/SVE/SME state incorrectly, and a race with preemption can result in a task having TIFSME set and TIFFOREIGNFPSTATE clear even though the live CPU state is stale (e.g. with SME traps enabled). This can result in warnings from dosmeacc() where SME traps are not expected while TIFSME is set:
| / With TIFSME userspace shouldn't generate any traps / | if (testandsetthreadflag(TIFSME)) | WARNON(1);
This is very similar to the SVE issue we fixed in commit:
751ecf6afd6568ad ("arm64/sve: Discard stale CPU state when handling SVE traps")
The race can occur when the SME trap handler is preempted before and after manipulating the saved FPSIMD/SVE/SME state, starting and ending on the same CPU, e.g.
| void dosmeacc(unsigned long esr, struct ptregs regs) | { | // Trap on CPU 0 with TIFSME clear, SME traps enabled | // task->fpsimdcpu is 0. | // percpuptr(&fpsimdlaststate, 0) is task. | | ... | | // Preempted; migrated from CPU 0 to CPU 1. | // TIFFOREIGNFPSTATE is set. | | getcpufpsimdcontext(); | | / With TIFSME userspace shouldn't generate any traps / | if (testandsetthreadflag(TIFSME)) | WARNON(1); | | if (!testthreadflag(TIFFOREIGNFPSTATE)) { | unsigned long vqminusone = | svevqfromvl(taskgetsmevl(current)) - 1; | smesetvq(vqminusone); | | fpsimdbindtasktocpu(); | } | | putcpufpsimdcontext(); | | // Preempted; migrated from CPU 1 to CPU 0. | // task->fpsimdcpu is still 0 | // If percpuptr(&fpsimdlaststate, 0) is still task then: | // - Stale HW state is reused (with SME traps enabled) | // - TIFFOREIGNFPSTATE is cleared | // - A return to userspace skips HW state restore | }
Fix the case where the state is not live and TIFFOREIGNFPSTATE is set by calling fpsimdflushtaskstate() to detach from the saved CPU state. This ensures that a subsequent context switch will not reuse the stale CPU state, and will instead set TIFFOREIGNFPSTATE, forcing the new state to be reloaded from memory prior to a return to userspace.
Note: this was originallly posted as [1].
[ Rutland: rewrite commit message ]
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
debian/linuxto a version that resolves this vulnerability.Fixed in 6.1.176-1Fixed in 6.1.190-1Fixed in 6.12.107-1Fixed in 6.12.113-1Fixed in 7.2.12-1Fixed in 7.2.13-1 - Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Patch 751ecf6afd6568ad
Event History
Frequently Asked Questions
What is the severity of CVE-2025-38170?
CVE-2025-38170 has a medium severity level due to the potential for task state corruption.
How do I fix CVE-2025-38170?
To fix CVE-2025-38170, update to the latest version of the Linux kernel where this vulnerability has been addressed.
What versions of the Linux kernel are affected by CVE-2025-38170?
CVE-2025-38170 affects versions of the Linux kernel that do not include the patches addressing SME traps.
What can happen if CVE-2025-38170 is exploited?
Exploitation of CVE-2025-38170 could lead to data corruption and instability in affected systems.
Is CVE-2025-38170 specific to certain CPU architectures?
Yes, CVE-2025-38170 specifically affects the arm64 architecture due to issues with FPSIMD/SVE/SME state management.