CVE-2025-21860: mm/zswap: fix inconsistency when zswap_store_page() fails
In the Linux kernel, the following vulnerability has been resolved:
mm/zswap: fix inconsistency when zswapstorepage() fails
Commit b7c0ccdfbafd ("mm: zswap: support large folios in zswapstore()") skips charging any zswap entries when it failed to zswap the entire folio.
However, when some base pages are zswapped but it failed to zswap the entire folio, the zswap operation is rolled back. When freeing zswap entries for those pages, zswapentryfree() uncharges the zswap entries that were not previously charged, causing zswap charging to become inconsistent.
This inconsistency triggers two warnings with following steps: # On a machine with 64GiB of RAM and 36GiB of zswap $ stress-ng --bigheap 2 # wait until the OOM-killer kills stress-ng $ sudo reboot
The two warnings are: in mm/memcontrol.c:163, function objcgrouprelease(): WARNONONCE(nrbytes & (PAGESIZE - 1));
in mm/pagecounter.c:60, function pagecountercancel(): if (WARNONCE(new < 0, "pagecounter underflow: %ld nrpages=%lu\n", new, nrpages))
zswapstoredpages also becomes inconsistent in the same way.
As suggested by Kanchana, increment zswapstoredpages and charge zswap entries within zswapstorepage() when it succeeds. This way, zswapentryfree() will decrement the counter and uncharge the entries when it failed to zswap the entire folio.
While this could potentially be optimized by batching objcg charging and incrementing the counter, let's focus on fixing the bug this time and leave the optimization for later after some evaluation.
After resolving the inconsistency, the warnings disappear.
[42.hyeyoo@gmail.com: refactor zswapstorepage()]
Affected Software
Remediation
Event History
Frequently Asked Questions
What is the severity of CVE-2025-21860?
CVE-2025-21860 has a medium severity level due to its potential impact on system stability in the Linux kernel.
How do I fix CVE-2025-21860?
To fix CVE-2025-21860, update your Linux kernel to the latest version that includes the patch for the inconsistency in zswap_store_page().
Which systems are affected by CVE-2025-21860?
CVE-2025-21860 affects various versions of the Linux kernel that utilize the zswap feature.
What are the potential impacts of CVE-2025-21860?
The potential impacts of CVE-2025-21860 include instability and unexpected behavior when large folios are used with zswap.
What is the nature of the inconsistency in CVE-2025-21860?
The inconsistency in CVE-2025-21860 occurs when zswap_store_page() fails, leading to improper handling of zswap entries.