# CVE-2025-21693: mm: zswap: properly synchronize freeing resources during CPU hotunplug

> Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

- **Severity:** HIGH 7.8
- **CVSS:** 7.8 (v3.1, CNA) `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H`
- **CVSS metrics:** Attack vector: Local; Attack complexity: Low; Privileges required: Low; User interaction: None; Scope: Unchanged; Confidentiality impact: High; Integrity impact: High; Availability impact: High
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Not remotely exploitable (local or adjacent access needed)
- **EPSS:** 0.30% (percentile 15, 2026-11-28)
- **CWE:** CWE-416
- **Published:** 2025-02-10T15:58:49.056Z
- **Modified:** 2026-08-05T11:53:39.821Z

## Who should check

- Anyone running Linux \>= 1ec3b5fe6eec782f4e5e0a80e4ce1909ffd5d161, \< 8d29ff5d50304daa41dc3cfdda4a9d1e46cf5be1; \>= 1ec3b5fe6eec782f4e5e0a80e4ce1909ffd5d161, \< 12dcb0ef540629a281533f9dedc1b6b8e14cfb65
- Anyone running Linux 5.11

## Description

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\]

## Affected and fixed versions

- Linux: \>= 1ec3b5fe6eec782f4e5e0a80e4ce1909ffd5d161, \< 8d29ff5d50304daa41dc3cfdda4a9d1e46cf5be1; \>= 1ec3b5fe6eec782f4e5e0a80e4ce1909ffd5d161, \< 12dcb0ef540629a281533f9dedc1b6b8e14cfb65 (cvelist)
- Linux: 5.11 (cvelist)

## Mitigation

- Upgrade Linux to 12dcb0ef540629a281533f9dedc1b6b8e14cfb65 or later.

## Check your systems with an agent

Paste this into a coding agent:

```text
Check whether anything I run is affected by CVE-2025-21693. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2025-21693.md
Affected: Linux >= 1ec3b5fe6eec782f4e5e0a80e4ce1909ffd5d161, < 8d29ff5d50304daa41dc3cfdda4a9d1e46cf5be1; >= 1ec3b5fe6eec782f4e5e0a80e4ce1909ffd5d161, < 12dcb0ef540629a281533f9dedc1b6b8e14cfb65; Linux 5.11
Fixed in: Linux 8d29ff5d50304daa41dc3cfdda4a9d1e46cf5be1, Linux 12dcb0ef540629a281533f9dedc1b6b8e14cfb65

Steps:
1. Search this machine and project for Linux: dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
```

## FAQ

### Is CVE-2025-21693 being exploited?

There is no confirmed exploitation: CVE-2025-21693 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 0.30% chance of exploitation in the next 30 days (as of 2026-11-28).

### How serious is CVE-2025-21693?

High: CVSS 7.8 (v3.1, scored by CNA). Not remotely exploitable (local or adjacent access needed).

### Which versions are affected by CVE-2025-21693?

Linux \>= 1ec3b5fe6eec782f4e5e0a80e4ce1909ffd5d161, \< 8d29ff5d50304daa41dc3cfdda4a9d1e46cf5be1; \>= 1ec3b5fe6eec782f4e5e0a80e4ce1909ffd5d161, \< 12dcb0ef540629a281533f9dedc1b6b8e14cfb65; Linux 5.11.

### Is there a fix for CVE-2025-21693?

Yes. Fixed in Linux 8d29ff5d50304daa41dc3cfdda4a9d1e46cf5be1, Linux 12dcb0ef540629a281533f9dedc1b6b8e14cfb65. Upgrade Linux to 12dcb0ef540629a281533f9dedc1b6b8e14cfb65 or later.

### How do I check if I'm affected by CVE-2025-21693?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

## References

- patch: <https://git.kernel.org/stable/c/8d29ff5d50304daa41dc3cfdda4a9d1e46cf5be1>
- patch: <https://git.kernel.org/stable/c/12dcb0ef540629a281533f9dedc1b6b8e14cfb65>

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- NVD: This product uses data from the NVD API but is not endorsed or certified by the NVD. <https://nvd.nist.gov/vuln/detail/CVE-2025-21693>

HTML: <https://flawdb.com/CVE-2025-21693> · JSON: <https://flawdb.com/api/v1/entries/CVE-2025-21693>
