CVE-2025-21693·Kernel vulnerability
In the Linux kernel, the following vulnerability has been resolved: mm: zswap: properly synchronize freeing resources during CPU hotunplug In zswap_compress() and zswap_decompress(), the per-CPU acomp_ctx of the current CPU at the beginning of the operation is retrieved and used throughout. However, since neither preemption nor migration are disabled, it is possible that the operation continues on a different CPU. If the original CPU is hotunplugged while the acomp_ctx is still in use, we run into a UAF bug as some of the resources attached to the acomp_ctx are freed during hotunplug in zswap_cpu_comp_dead() (i.e. acomp_ctx.buffer, acomp_ctx.req, or acomp_ctx.acomp). The problem was introduced in commit 1ec3b5fe6eec ("mm/zswap: move to use crypto_acomp API for hardware acceleration") when the switch to the crypto_acomp API was made. Prior to that, the per-CPU crypto_comp was retrieved using get_cpu_ptr() which disables preemption and makes sure the CPU cannot go away from under us. Preemption cannot be disabled with the crypto_acomp API as a sleepable context is needed. Use the acomp_ctx.mutex to synchronize CPU hotplug callbacks allocating and freeing resources with compression/decompression paths. Make sure that acomp_ctx.req is NULL when the resources are freed. In the compression/decompression paths, check if acomp_ctx.req is NULL after acquiring the mutex (meaning the CPU was offlined) and retry on the new CPU. The initialization of acomp_ctx.mutex is moved from the CPU hotplug callback to the pool initialization where it belongs (where the mutex is allocated). In addition to adding clarity, this makes sure that CPU hotplug cannot reinitialize a mutex that is already locked by compression/decompression. Previously a fix was attempted by holding cpus_read_lock() [1]. This would have caused a potential deadlock as it is possible for code already holding the lock to fall into reclaim and enter zswap (causing a deadlock). A fix was also attempted using SRCU for synchronization, but Johannes pointed out that synchronize_srcu() cannot be used in CPU hotplug notifiers [2]. Alternative fixes that were considered/attempted and could have worked: - Refcounting the per-CPU acomp_ctx. This involves complexity in handling the race between the refcount dropping to zero in zswap_[de]compress() and the refcount being re-initialized when the CPU is onlined. - Disabling migration before getting the per-CPU acomp_ctx [3], but that's discouraged and is a much bigger hammer than needed, and could result in subtle performance issues. [1]https://lkml.kernel.org/20241219212437.2714151-1-yosryahmed@google.com/ [2]https://lkml.kernel.org/20250107074724.1756696-2-yosryahmed@google.com/ [3]https://lkml.kernel.org/20250107222236.2715883-2-yosryahmed@google.com/ [yosryahmed@google.com: remove comment]
- Severity
- high
- Software
- Kernel
- Fixed in
- 6.12.12
- Published
- 2025-02-10
Affected versions
From: 5.11
Until: 6.12.12
Fixed in: 6.12.12
How to fix this CVE
Update your Linux kernel to version 6.12.12 or later to resolve a use-after-free vulnerability in the zswap compression subsystem. The vulnerability occurs when CPU hotunplug races with compression/decompression operations, potentially freeing memory still in use. Apply this patch immediately to systems running kernel versions 5.11 through 6.12.11, particularly those with dynamic CPU scaling or frequent hotplug events.
sudo dnf upgrade kernel kernel-develDefensia detects this vulnerability
How to check if you are affected
- Step 1: Check your kernel version with `uname -r` and compare against the vulnerable range 5.11-6.12.11
- Step 2: Verify zswap is enabled by checking `cat /sys/module/zswap/parameters/enabled` (Y/1 means enabled)
- Step 3: Search system logs for UAF-related crashes using `sudo dmesg | grep -i 'use-after-free\|zswap\|acomp'` or `sudo journalctl -b | grep -i 'use-after-free'`
- Step 4: Confirm the fix by upgrading to kernel 6.12.12+ and running `uname -r` to verify the new version is active after reboot
FAQ
What is CVE-2025-21693?
This is a use-after-free vulnerability in the Linux kernel's zswap compression subsystem that occurs when a CPU is hotunplugged while compression or decompression operations are still in progress. The vulnerability can lead to kernel memory corruption and potential privilege escalation.
Is CVE-2025-21693 being actively exploited?
No, this vulnerability is not listed on the CISA Known Exploited Vulnerabilities (KEV) catalog and no public exploits are currently available. However, it poses a real risk in environments with CPU hotplug operations.
What versions of Kernel are affected by CVE-2025-21693?
Linux kernel versions 5.11 through 6.12.11 are vulnerable. Versions 6.12.12 and later contain the fix.
How do I check if my server is vulnerable to CVE-2025-21693?
Run `uname -r` to get your kernel version and verify it falls within 5.11-6.12.11, then confirm zswap is enabled with `cat /sys/module/zswap/parameters/enabled`. Both conditions must be true for vulnerability.
Does Defensia detect CVE-2025-21693?
Yes — Defensia's CVE advisory scanner compares installed package versions against the NVD database. If the Linux kernel is installed on a monitored server, CVE-2025-21693 will appear in your dashboard with remediation steps.
Related Kernel CVEs
References
Track CVEs across your fleet automatically
Defensia scans your Linux servers and tells you exactly which ones are running vulnerable versions — including CVE-2025-21693. Free for 1 server.
Get started free