# CVE-2025-39727: mm: swap: fix potential buffer overflow in setup_clusters()

- Severity: High 7.8 (CVSS:3.1, scored by NVD) `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H`
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Likelihood of exploitation in the next 30 days (EPSS): 0.19%, higher than 9% of CVEs (2026-12-01)
- Published: 2025-09-07T15:16:17.986Z
- Modified: 2026-10-19T21:10:00.160Z
- Weaknesses: CWE-120
- Assigned by: Linux

## Description

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

mm: swap: fix potential buffer overflow in setup_clusters()

In setup_swap_map(), we only ensure badpages are in range (0, last_page]. 
As maxpages might be < last_page, setup_clusters() will encounter a buffer
overflow when a badpage is >= maxpages.

Only call inc_cluster_info_page() for badpage which is < maxpages to fix
the issue.

(As written by CVE List.)

## Affected

- Linux Linux: from b843786b0bd01ced7fcdbf3b033d68db2f7c61b2 before 91b370800b3f2b3dda244c0ab06719c4971190a5; from b843786b0bd01ced7fcdbf3b033d68db2f7c61b2 before 9b01ada580ee84fb319e7ecb5fb5b1f54a9eb799; from b843786b0bd01ced7fcdbf3b033d68db2f7c61b2 before 815c528b13f2bb9b3130c13bedeabf2351a68129; from b843786b0bd01ced7fcdbf3b033d68db2f7c61b2 before 152c1339dc13ad46f1b136e8693de15980750835; 6.12 (not affected: before 6.12; from 6.12.42 up to 6.12.*; from 6.15.10 up to 6.15.*; from 6.16.1 up to 6.16.*; from 6.17 up to *)
- linux linux_kernel: from 6.12 before 6.12.42; from 6.13 before 6.15.10; from 6.16 before 6.16.1

## References

- <https://git.kernel.org/stable/c/91b370800b3f2b3dda244c0ab06719c4971190a5> (patch)
- <https://git.kernel.org/stable/c/9b01ada580ee84fb319e7ecb5fb5b1f54a9eb799> (patch)
- <https://git.kernel.org/stable/c/815c528b13f2bb9b3130c13bedeabf2351a68129> (patch)
- <https://git.kernel.org/stable/c/152c1339dc13ad46f1b136e8693de15980750835> (patch)

## Sources

- CVE List: [CVE-2025-39727](https://www.cve.org/CVERecord?id=CVE-2025-39727), CVE Terms of Use, modified 2026-05-11
- NVD: [CVE-2025-39727](https://nvd.nist.gov/vuln/detail/CVE-2025-39727), Public domain, modified 2026-10-19

---

Page: https://cve.day/CVE-2025-39727 · Whole record: https://cve.day/CVE-2025-39727.json · Rebuilt by cve.day 2026-11-25T22:59:04.313Z
