Look up another CVE · open CVE-2025-21693 in the interactive tracker
CVE-2025-21693
mm: zswap: properly synchronize freeing resources during CPU hotunplug
Published 2025-02-10 (20 months ago) by the Linux kernel CNA. Subsystem mm. Debian urgency: not yet assigned.
What to do, per Debian release
Debian's own status for CVE-2025-21693 in every release this site tracks, and what each one means in practice. Every status below is the one the Debian Security Team publishes for this CVE. source
| Release | Status | Version | What this means |
|---|---|---|---|
| Debian 12bookworm | vulnerable | 6.1.190-1 | No fix published anywhere yet, neither in Debian nor upstream for the series bookworm tracks. Watch the Debian tracker page for this CVE. Advisories for bookworm have historically landed a median of 23 days after publication. |
| Debian 13trixie | fixed | 6.12.12-1 | Update the kernel and reboot. Fixed in 6.12.12-1. A running kernel keeps the old code until the machine restarts. |
| Debian 14forky | fixed | 6.12.12-1 | Update the kernel and reboot. Fixed in 6.12.12-1. A running kernel keeps the old code until the machine restarts. |
| Debian unstablesid | fixed | 6.12.12-1 | Update the kernel and reboot. Fixed in 6.12.12-1. A running kernel keeps the old code until the machine restarts. |
The vulnerability
What the bug is
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]
Where it lives
The fix touches these files. If the subsystem is one you do not use, the practical exposure is lower, though the package is still the vulnerable one.
mm/zswap.c
- What this is
- ZSWAP COMPRESSED SWAP CACHINGMAINTAINERS section matched on mm/zswap.c · linux-mm@kvack.org · Maintained
Check it on the machine
grep -w CONFIG_ZSWAP /boot/config-$(uname -r)Reads the booted kernel's own configuration, on the machine and nowhere else. =y is built in, =m is a module, and an is not set line means the code is not there.
Show whether Debian builds this, per release
Debian builds this, but not on every flavour. At least one release below builds the code on some of its kernel flavours and not on others, so the answer depends on the architecture and flavour installed.
- bookworm, trixieYnot built on amd64/cloud-amd64, arm64/cloud-arm64
- forky, sidy
- Y
- built in where it is built at all; some flavours do not build it
- y
- built into the kernel image on every flavour - only a patch removes it
- Build switch
- CONFIG_ZSWAP
From the configuration Debian publishes for every kernel flavour it builds. It covers only the architectures Debian ships a linux-config package for, and nothing about a kernel you built yourself. Debian's own status above stays authoritative about the source package.MAINTAINERS kbuild Makefiles Debian linux-config packages
Signals
- Published
- 2025-02-10 (20 months ago)source
- CVSS
- 7.8 high
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:Hsource recompute it - Attack vector
- local (AV:L)source
- EPSS
- 0.20%, higher than 9.6% of all CVEssource
- CISA KEV
- not listedthe KEV catalogue
- Debian urgency
- not yet assignedsource
- Subsystem
- mm
Upstream fixes
The versions the CNA records as introducing and fixing this, and the commit for each. source
| Introduced | Fixed in | Commit |
|---|---|---|
| 5.11 | 6.12.12 | 8d29ff5d5030 |
| 5.11 | 6.13 | 12dcb0ef5406 |
Why the CNA scored it this way
Quoted from the kernel CNA's own scoring file, word for word. A highlighted metric carries the most severe value CVSS v3.1 defines for it, which is what pushes the score up. source
- AV:LAttack vector, local
- The UAF is reached through local memory-management activity — `madvise(MADV_PAGEOUT)`/reclaim driving `zswap_store()`→`zswap_compress()` and swap-in faults driving `zswap_load()`→`zswap_decompress()` — raced against a local CPU offline transition (sysfs `cpuN/online`, suspend/resume, or hypervisor vCPU hot-remove). No remote peer or network input reaches `mm/zswap.c`.
- AC:LAttack complexity, low
- The attacker fully controls the zswap side (unbounded `MADV_PAGEOUT`/swap-in loops on threads pinned to each CPU via `sched_setaffinity()`), and the offline operation itself performs the migration that opens the window, since `CPUHP_MM_ZSWP_POOL_PREPARE` teardown runs only after the dying CPU's tasks have been pushed to other CPUs; the pre-fix per-CPU mutex additionally parks several attacker threads on the dying CPU's ctx so they all wake onto freed resources. Hotplug or suspend/resume cycles can be repeated indefinitely until the race lands, and zswap is a mainstream distro config (`CONFIG_ZSWAP`, `CONFIG_ZSWAP_DEFAULT_ON`).
- PR:LPrivileges required, low
- The compress/decompress half needs no privilege at all — any user's own anonymous memory plus `madvise()` reaches it with no `capable()` check — and the offline half requires no elevated credentials in realistic deployments: the identical CPU-down sequence runs on every suspend/resume, which an unprivileged desktop/laptop/Android session can request via logind/polkit, and cloud guests (Xen vCPU availability, pseries DLPAR, s390, ACPI eject) and vendor Android hotplug governors offline CPUs autonomously while the attacker keeps zswap traffic in flight.
- UI:NUser interaction, none
- The attacker drives both the reclaim/swap-in traffic and the hotplug or suspend cycle itself; no victim action, mount, or file open is needed, and on hotplug-driven platforms the offline event occurs during normal operation.
- S:UScope, unchanged
- The freed `acomp_ctx` resources and the resulting corruption are entirely within the kernel's own memory and security authority, with no crossing of a VM, IOMMU, or sandbox boundary.
- C:HConfidentiality impact, high
- `zswap_decompress()` memcpys into and then decompresses out of the freed 8 KB `acomp_ctx->buffer`, writing the result into the folio returned to userspace by the swap-in fault, so a groomed reallocation of that slab object leaks arbitrary kernel data into an attacker-readable page; the freed `acomp_req`/`crypto_acomp` are also read as live objects.
- I:HIntegrity impact, high
- `crypto_acomp_compress()` expands to `crypto_acomp_reqtfm(req)->compress(req)`, an indirect call through a function pointer loaded from the freed tfm, giving control-flow hijack after heap grooming; additionally the compressor writes up to `PAGE_SIZE * 2` of attacker-influenced output into the freed buffer and `acomp_request_set_params()` writes into the freed request.
- A:HAvailability impact, high
- The use-after-free reliably oopses or panics the kernel, and `zswap_decompress()` carries two unconditional `BUG_ON()`s on the crypto result and `req->dlen` that fire immediately on garbage from freed structures — the bug was reported precisely as a crash by both Johannes Weiner and Sam Sun.