CVE-2026-139657

mm/gup: honour FOLL_PIN in NOMMU __get_user_pages_locked()

Published Nov 30, 2026 CVSS n/a EPSS n/a KEV · Not listed
Description
In the Linux kernel, the following vulnerability has been resolved:

mm/gup: honour FOLL_PIN in NOMMU __get_user_pages_locked()

The !CONFIG_MMU implementation of __get_user_pages_locked() takes a bare
get_page() reference for each page regardless of foll_flags:
if (pages[i])
get_page(pages[i]);

This is reached from pin_user_pages*() with FOLL_PIN set.
unpin_user_page() is shared between MMU and NOMMU configurations and
unconditionally calls gup_put_folio(..., FOLL_PIN), which subtracts
GUP_PIN_COUNTING_BIAS (1024) from the folio refcount.

This means that pin adds 1, and then unpin will subtract 1024.

If a user maps a page (refcount 1), registers it 1023 times as an
io_uring fixed buffer (1023 pin_user_pages calls -> refcount 1024), then
unregisters: the first unpin_user_page subtracts 1024, refcount hits 0,
the page is freed and returned to the buddy allocator. The remaining
1022 unpins write into whatever was reallocated, and the user's VMA
still maps the freed page (NOMMU has no MMU to invalidate it).
Reallocating the page for an io_uring pbuf_ring then lets userspace
corrupt the new owner's data through the stale mapping.

Use try_grab_folio() which adds GUP_PIN_COUNTING_BIAS for FOLL_PIN and 1
for FOLL_GET, mirroring the CONFIG_MMU path so pin and unpin are
symmetric. Keep supporting the traditional behavior where users specify
a pages array but don't set FOLL_GET.

While at it, don't return NULL pointers in the page array,
as this is really not expected for GUP users; instead, just fail and return
-EFAULT.

[ david: support traditional behavior with no FOLL_GET, extend
description ]

Analysis

AI-generated

Technical impact

A flaw in the kernel’s page pinning logic on non-MMU configurations causes the reference count for pinned pages to drop by a large bias instead of by one. When a pinned page is unregistered, the reference count can become negative, freeing memory that is subsequently reallocated. The kernel continues to expose the stale mapping, allowing user space to write to an address that now belongs to another process or object. This use‑after‑free and stale‑mapping combination is a classic vector for arbitrary memory writes, which can lead to privilege escalation or arbitrary code execution if an attacker can trigger the sequence.

Affected Systems

The issue affects all Linux kernel builds that contain the described __get_user_pages_locked implementation and are compiled without the CONFIG_MMU option. Many embedded, minimal, or older kernels fall into this category. No specific version range is listed, so any kernel that has not yet applied the identified patch is vulnerable. The vulnerability is tied to the io_uring fixed‑buffer registration path and the deprecated NOMMU path.

Risk and Exploitability

The flaw is a local attacker scenario; it requires the attacker to run with privileges that allow mapping memory and registering io_uring buffers, or the attacker must exploit the vulnerability as part of a broader kernel compromise. The absence of an EPSS score or KEV listing suggests the exploit has not yet been observed in the wild, but the severity of a use‑after‑free that corrupts arbitrary memory is high, and the kernel’s lack of a memory protection mechanism in NOMMU builds removes a key mitigation. The attack vector is therefore likely local with elevated privileges and may require coordinated staging to trigger the reference count mismatch and memory reuse. The CVSS score is not provided, but the nature of the bug warrants a high risk assessment for any affected system.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Update the kernel to a version that includes the commit fixing __get_user_pages_locked, which symmetrically handles FOLL_PIN and returns an error when a page array entry is NULL.
  • If a patch cannot be applied immediately, disable the io_uring subsystem for non‑privileged users or remove support for io_uring fixed buffers from the kernel configuration.
  • For systems compiled without CONFIG_MMU, consider recompiling with CONFIG_MMU enabled or applying a temporary RPM/patch that adjusts the reference counting logic as a workaround.
  • Monitor system logs for abnormal memory allocation patterns or signs of memory corruption and enforce integrity checks on critical processes.

Generated by OpenCVE AI on December 1, 2026 at 00:30 UTC.

Tracking

Sign in to view the affected projects.

Advisories

No advisories available
History
Type Values Removed Values Added
Weaknesses CWE-416
Type Values Removed Values Added
Description In the Linux kernel, the following vulnerability has been resolved: mm/gup: honour FOLL_PIN in NOMMU __get_user_pages_locked() The !CONFIG_MMU implementation of __get_user_pages_locked() takes a bare get_page() reference for each page regardless of foll_flags: if (pages[i]) get_page(pages[i]); This is reached from pin_user_pages*() with FOLL_PIN set. unpin_user_page() is shared between MMU and NOMMU configurations and unconditionally calls gup_put_folio(..., FOLL_PIN), which subtracts GUP_PIN_COUNTING_BIAS (1024) from the folio refcount. This means that pin adds 1, and then unpin will subtract 1024. If a user maps a page (refcount 1), registers it 1023 times as an io_uring fixed buffer (1023 pin_user_pages calls -> refcount 1024), then unregisters: the first unpin_user_page subtracts 1024, refcount hits 0, the page is freed and returned to the buddy allocator. The remaining 1022 unpins write into whatever was reallocated, and the user's VMA still maps the freed page (NOMMU has no MMU to invalidate it). Reallocating the page for an io_uring pbuf_ring then lets userspace corrupt the new owner's data through the stale mapping. Use try_grab_folio() which adds GUP_PIN_COUNTING_BIAS for FOLL_PIN and 1 for FOLL_GET, mirroring the CONFIG_MMU path so pin and unpin are symmetric. Keep supporting the traditional behavior where users specify a pages array but don't set FOLL_GET. While at it, don't return NULL pointers in the page array, as this is really not expected for GUP users; instead, just fail and return -EFAULT. [ david: support traditional behavior with no FOLL_GET, extend description ]
Title mm/gup: honour FOLL_PIN in NOMMU __get_user_pages_locked()
First Time appeared Linux
Linux linux Kernel
CPEs cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
Vendors & Products Linux
Linux linux Kernel
References
Weaknesses

Sources

Status
PUBLISHED
Assigner
Linux
Published
Updated
Nov 30, 2026, 1:36 PM
Reserved
Nov 30, 2026, 1:22 PM
Status
Received
Published
Nov 30, 2026, 2:19 PM
Modified
Nov 30, 2026, 2:19 PM