# CVE-2026-23161: mm/shmem, swap: fix race of truncate and swap entry split

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

- **Severity:** HIGH 7.3
- **CVSS:** 7.3 (v3.1, CNA) `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:L/I:H/A:H`
- **CVSS metrics:** Attack vector: Local; Attack complexity: Low; Privileges required: Low; User interaction: None; Scope: Unchanged; Confidentiality impact: Low; 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.15% (percentile 2, 2026-11-26)
- **CWE:** CWE-362
- **Published:** 2026-02-14T16:01:26.569Z
- **Modified:** 2026-08-05T12:20:23.871Z

## Who should check

- Anyone running Linux \>= 809bc86517cc408b5b8cb8e08e69096639432bc8, \< a99f9a4669a04662c8f9efe0e62cafc598153139; \>= 809bc86517cc408b5b8cb8e08e69096639432bc8, \< b23bee8cdb7aabce5701a7f57414db5a354ae8ed; \>= 809bc86517cc408b5b8cb8e08e69096639432bc8, \< 8a1968bd997f45a9b11aefeabdd1232e1b6c7184
- Anyone running Linux 6.12

## Description

In the Linux kernel, the following vulnerability has been resolved:

mm/shmem, swap: fix race of truncate and swap entry split

The helper for shmem swap freeing is not handling the order of swap
entries correctly.  It uses xa\_cmpxchg\_irq to erase the swap entry, but it
gets the entry order before that using xa\_get\_order without lock
protection, and it may get an outdated order value if the entry is split
or changed in other ways after the xa\_get\_order and before the
xa\_cmpxchg\_irq.

And besides, the order could grow and be larger than expected, and cause
truncation to erase data beyond the end border.  For example, if the
target entry and following entries are swapped in or freed, then a large
folio was added in place and swapped out, using the same entry, the
xa\_cmpxchg\_irq will still succeed, it's very unlikely to happen though.

To fix that, open code the Xarray cmpxchg and put the order retrieval and
value checking in the same critical section.  Also, ensure the order won't
exceed the end border, skip it if the entry goes across the border.

Skipping large swap entries crosses the end border is safe here.  Shmem
truncate iterates the range twice, in the first iteration,
find\_lock\_entries already filtered such entries, and shmem will swapin the
entries that cross the end border and partially truncate the folio (split
the folio or at least zero part of it).  So in the second loop here, if we
see a swap entry that crosses the end order, it must at least have its
content erased already.

I observed random swapoff hangs and kernel panics when stress testing
ZSWAP with shmem.  After applying this patch, all problems are gone.

## Affected and fixed versions

- Linux: \>= 809bc86517cc408b5b8cb8e08e69096639432bc8, \< a99f9a4669a04662c8f9efe0e62cafc598153139; \>= 809bc86517cc408b5b8cb8e08e69096639432bc8, \< b23bee8cdb7aabce5701a7f57414db5a354ae8ed; \>= 809bc86517cc408b5b8cb8e08e69096639432bc8, \< 8a1968bd997f45a9b11aefeabdd1232e1b6c7184 (cvelist)
- Linux: 6.12 (cvelist)

## Mitigation

- Upgrade Linux to 8a1968bd997f45a9b11aefeabdd1232e1b6c7184 or later.

## Check your systems with an agent

Paste this into a coding agent:

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

Details: https://flawdb.com/CVE-2026-23161.md
Affected: Linux >= 809bc86517cc408b5b8cb8e08e69096639432bc8, < a99f9a4669a04662c8f9efe0e62cafc598153139; >= 809bc86517cc408b5b8cb8e08e69096639432bc8, < b23bee8cdb7aabce5701a7f57414db5a354ae8ed; >= 809bc86517cc408b5b8cb8e08e69096639432bc8, < 8a1968bd997f45a9b11aefeabdd1232e1b6c7184; Linux 6.12
Fixed in: Linux 8a1968bd997f45a9b11aefeabdd1232e1b6c7184

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-2026-23161 being exploited?

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

### How serious is CVE-2026-23161?

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

### Which versions are affected by CVE-2026-23161?

Linux \>= 809bc86517cc408b5b8cb8e08e69096639432bc8, \< a99f9a4669a04662c8f9efe0e62cafc598153139; \>= 809bc86517cc408b5b8cb8e08e69096639432bc8, \< b23bee8cdb7aabce5701a7f57414db5a354ae8ed; \>= 809bc86517cc408b5b8cb8e08e69096639432bc8, \< 8a1968bd997f45a9b11aefeabdd1232e1b6c7184; Linux 6.12.

### Is there a fix for CVE-2026-23161?

Yes. Fixed in Linux 8a1968bd997f45a9b11aefeabdd1232e1b6c7184. Upgrade Linux to 8a1968bd997f45a9b11aefeabdd1232e1b6c7184 or later.

### How do I check if I'm affected by CVE-2026-23161?

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/a99f9a4669a04662c8f9efe0e62cafc598153139>
- patch: <https://git.kernel.org/stable/c/b23bee8cdb7aabce5701a7f57414db5a354ae8ed>
- patch: <https://git.kernel.org/stable/c/8a1968bd997f45a9b11aefeabdd1232e1b6c7184>

## 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-2026-23161>

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