# CVE-2026-139798: mm: do not unintentionally overwrite atomic VMA flags

- **Severity:** UNSCORED
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Unknown
- **Published:** 2026-11-30T13:38:05.841Z
- **Modified:** 2026-11-30T14:20:14.127Z

> **AI summary (AI-generated, claude-haiku-5-5):** A race in Linux kernel memory management lets stale VMA flags overwrite atomically set guard-page flags, causing missing page table copies on fork or wrong mlock accounting.

## Who should check

- Anyone running Linux \>= 2ab7f1bbafc927c69374d45578011c814c26ae2f, \< a336cd46459c1a7608cc805ec04a59890e993baa; \>= 2ab7f1bbafc927c69374d45578011c814c26ae2f, \< 13fc99f46399c9d38d1b54ecf0a3f387ba04d05d
- Anyone running Linux 6.19

## Description

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

mm: do not unintentionally overwrite atomic VMA flags

Patch series "mm: avoid losing atomic VMA flags", v1.

Since commit 2ab7f1bbafc9 ("mm/madvise: allow guard page install/remove
under VMA lock"), VMA\_MAYBE\_GUARD\_BIT can be set atomically under the VMA
read lock.

However, a number of places wrongly assume the flags are stable under the
read lock, which can cause stale atomic VMA flags to overwrite existing
valid ones.

Additionally, one case in which VMA\_SOFTDIRTY\_BIT was overwritten is also
addressed.

This series addresses each of these, while keeping the logic inline with
existing conventions.

Each patch in this series is a hotfix.


This patch (of 4):

madvise, mlock and mprotect take a copy of a VMA's flags holding only the
VMA read lock, later writing it back under the write lock (in
madvise\_update\_vma(), mlock\_fixup(), mlock\_vma\_pages\_range() and
mprotect\_fixup()).

This was done on the assumption that VMA flags cannot change with a read
lock held.

However this changed in commit 2ab7f1bbafc9 ("mm/madvise: allow guard page
install/remove under VMA lock"), which allowed VM\_ATOMIC\_SET\_ALLOWED
flags (currently only VMA\_MAYBE\_GUARD\_BIT) to be written concurrently under
a VMA read lock.

The actual write itself is safe as this is done under the VMA write lock
at which point no further concurrent writes can occur, however at this
point the stale flags mean that these callers can unintentionally overwrite
atomic flags incorrectly.

The consequences of this are significant - a missing VMA\_MAYBE\_GUARD\_BIT
could result in page tables not being copied on fork (the vma\_needs\_copy()
check can return false) or being overwritten on file-backed THP
collapse (the file\_backed\_vma\_is\_retractable() can return true).

Resolve the issue by always taking care to retain existing atomic flags
when overwriting VMA flags, replacing the inconsistently named
vma\_flags\_reset\_once() with vma\_overwrite\_flags() to do so, and always
invoking it when flags are overwritten like this.

Reads are a problem too - madvise, mlock and mprotect all compare VMA flags
without a VMA write lock held via vma\_flags\_same\_pair().

This has more serious impact, as concurrent changes to atomic VMA flags can
cause two sets of VMA flags to be wrongly considered different.

For mprotect and madvise this causes a useless split, but mlock is impacted
more seriously as it can result in mm-\>locked\_vm underflow.

Fix this by updating vma\_flags\_same\_pair() to disregard
VM\_ATOMIC\_SET\_ALLOWED VMAs - VMA equality is the same as VMA mergeability,
and atomic VMA flags are disregarded when comparing VMA flags for merge -
so this is justified semantically.

Additionally, remove the redundant vma\_flags\_same\_mask() and the unused
vma\_flags\_same() as part of the change, and replace VM\_ATOMIC\_SET\_ALLOWED
with VMA\_ATOMIC\_SET\_ALLOWED, using the new VMA flag API.

Finally, update userland VMA tests to reflect the changes.

## Affected and fixed versions

- Linux: \>= 2ab7f1bbafc927c69374d45578011c814c26ae2f, \< a336cd46459c1a7608cc805ec04a59890e993baa; \>= 2ab7f1bbafc927c69374d45578011c814c26ae2f, \< 13fc99f46399c9d38d1b54ecf0a3f387ba04d05d (cvelist)
- Linux: 6.19 (cvelist)

## Technologies

Linux kernel

## Mitigation

- Upgrade Linux to 13fc99f46399c9d38d1b54ecf0a3f387ba04d05d 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-139798. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2026-139798.md
Affected: Linux >= 2ab7f1bbafc927c69374d45578011c814c26ae2f, < a336cd46459c1a7608cc805ec04a59890e993baa; >= 2ab7f1bbafc927c69374d45578011c814c26ae2f, < 13fc99f46399c9d38d1b54ecf0a3f387ba04d05d; Linux 6.19
Fixed in: Linux 13fc99f46399c9d38d1b54ecf0a3f387ba04d05d

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-139798 being exploited?

There is no confirmed exploitation: CVE-2026-139798 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known.

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

It has no CVSS score yet. Unknown.

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

Linux \>= 2ab7f1bbafc927c69374d45578011c814c26ae2f, \< a336cd46459c1a7608cc805ec04a59890e993baa; \>= 2ab7f1bbafc927c69374d45578011c814c26ae2f, \< 13fc99f46399c9d38d1b54ecf0a3f387ba04d05d; Linux 6.19.

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

Yes. Fixed in Linux 13fc99f46399c9d38d1b54ecf0a3f387ba04d05d. Upgrade Linux to 13fc99f46399c9d38d1b54ecf0a3f387ba04d05d or later.

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

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

- other: <https://git.kernel.org/stable/c/a336cd46459c1a7608cc805ec04a59890e993baa>
- other: <https://git.kernel.org/stable/c/13fc99f46399c9d38d1b54ecf0a3f387ba04d05d>

## 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-139798>

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