x86/mm/pat: fix VM_PAT handling in COW mappings
In the Linux kernel, the following vulnerability has been resolved: x86/mm/pat: fix VM_PAT handling in COW mappings PAT handling won't do the right thing in COW mappings: the first PTE (or, in fact, all PTEs) can be replaced during write faults to point at anon folios. Reliably recovering the correct PFN and cachemode using follow_phys() from PTEs will not work in COW mappings. Using follow_phys(), we might just get the address+protection of the anon folio (which is very wrong), or fail on swap/nonswap entries, failing follow_phys() and triggering a WARN_ON_ONCE() in untrack_pfn() and track_pfn_copy(), not properly calling free_pfn_range(). In free_pfn_range(), we either wouldn't call memtype_free() or would call it with the wrong range, possibly leaking memory. To fix that, let's update follow_phys() to refuse returning anon folios, and fallback to using the stored PFN inside vma->vm_pgoff for COW mappings if we run into that. We will now properly handle untrack_pfn() with COW mappings, where we don't need the cachemode. We'll have to fail fork()->track_pfn_copy() if the first page was replaced by an anon folio, though: we'd have to store the cachemode in the VMA to make this work, likely growing the VMA size. For now, lets keep it simple and let track_pfn_copy() just fail in that case: it would have failed in the past with swap/nonswap entries already, and it would have done the wrong thing with anon folios. Simple reproducer to trigger the WARN_ON_ONCE() in untrack_pfn():
- Products
- Kernel
- Affected versions
- Not specified
- Fixed versions
- 4.19.312, 5.10.215, 5.15.155, 5.4.274, 6.1.85, 6.6.26, 6.8.5
- CVEs
- CVE-2024-35877
- Confirmed fixed CVEs
- Not specified
- Updated in this feed
- 2 Nov 2026, 20:25 UTC · Revision 1
Source evidence
x86/mm/pat: fix VM_PAT handling in COW mappings
core-osv · Original sourcePublished 19 May 2024, 08:34 UTC
In the Linux kernel, the following vulnerability has been resolved: x86/mm/pat: fix VM_PAT handling in COW mappings PAT handling won't do the right thing in COW mappings: the first PTE (or, in fact, all PTEs) can be replaced during write faults to point at anon folios. Reliably recovering the correct PFN and cachemode using follow_phys() from PTEs will not work in COW mappings. Using follow_phys(), we might just get the address+protection of the anon folio (which is very wrong), or fail on swap/nonswap entries, failing follow_phys() and triggering a WARN_ON_ONCE() in untrack_pfn() and track_pfn_copy(), not properly calling free_pfn_range(). In free_pfn_range(), we either wouldn't call memtype_free() or would call it with the wrong range, possibly leaking memory. To fix that, let's update follow_phys() to refuse returning anon folios, and fallback to using the stored PFN inside vma->vm_pgoff for COW mappings if we run into that. We will now properly handle untrack_pfn() with COW mappings, where we don't need the cachemode. We'll have to fail fork()->track_pfn_copy() if the first page was replaced by an anon folio, though: we'd have to store the cachemode in the VMA to make this work, likely growing the VMA size. For now, lets keep it simple and let track_pfn_copy() just fail in that case: it would have failed in the past with swap/nonswap entries already, and it would have done the wrong thing with anon folios. Simple reproducer to trigger the WARN_ON_ONCE() in untrack_pfn():
osv:CVE-2024-35877
Kernel
Fixed versions: 4.19.312, 5.4.274, 5.10.215, 5.15.155, 6.1.85, 6.6.26, 6.8.5
Complete source record
{
"id": "73fe4ac2995274bbf2de556dc469e1365320a97f9286ac134044f30fe2b6b2cd",
"url": "https://osv.dev/vulnerability/CVE-2024-35877",
"method": "structured",
"payload": {
"kind": "advisory",
"title": "x86/mm/pat: fix VM_PAT handling in COW mappings",
"summary": "In the Linux kernel, the following vulnerability has been resolved: x86/mm/pat: fix VM_PAT handling in COW mappings PAT handling won't do the right thing in COW mappings: the first PTE (or, in fact, all PTEs) can be replaced during write faults to point at anon folios. Reliably recovering the correct PFN and cachemode using follow_phys() from PTEs will not work in COW mappings. Using follow_phys(), we might just get the address+protection of the anon folio (which is very wrong), or fail on swap/nonswap entries, failing follow_phys() and triggering a WARN_ON_ONCE() in untrack_pfn() and track_pfn_copy(), not properly calling free_pfn_range(). In free_pfn_range(), we either wouldn't call memtype_free() or would call it with the wrong range, possibly leaking memory. To fix that, let's update follow_phys() to refuse returning anon folios, and fallback to using the stored PFN inside vma->vm_pgoff for COW mappings if we run into that. We will now properly handle untrack_pfn() with COW mappings, where we don't need the cachemode. We'll have to fail fork()->track_pfn_copy() if the first page was replaced by an anon folio, though: we'd have to store the cachemode in the VMA to make this work, likely growing the VMA size. For now, lets keep it simple and let track_pfn_copy() just fail in that case: it would have failed in the past with swap/nonswap entries already, and it would have done the wrong thing with anon folios. Simple reproducer to trigger the WARN_ON_ONCE() in untrack_pfn(): ",
"evidence": "osv:CVE-2024-35877",
"products": [
{
"name": {
"value": "Kernel",
"evidence": "/affected/1/package/name"
},
"prerequisites": [],
"fixed_versions": [
{
"value": "4.19.312",
"evidence": "/affected/1/ranges"
},
{
"value": "5.4.274",
"evidence": "/affected/1/ranges"
},
{
"value": "5.10.215",
"evidence": "/affected/1/ranges"
},
{
"value": "5.15.155",
"evidence": "/affected/1/ranges"
},
{
"value": "6.1.85",
"evidence": "/affected/1/ranges"
},
{
"value": "6.6.26",
"evidence": "/affected/1/ranges"
},
{
"value": "6.8.5",
"evidence": "/affected/1/ranges"
}
],
"affected_versions": []
}
],
"severity": "unknown",
"structured": {
"id": "CVE-2024-35877",
"aliases": [
"CVE-2024-35877"
],
"affected": [
{
"ranges": [
{
"repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
"type": "GIT",
"events": [
{
"introduced": "5899329b19100c0b82dc78e9b21ed8b920c9ffb3"
},
{
"fixed": "f18681daaec9665a15c5e7e0f591aad5d0ac622b"
},
{
"fixed": "09e6bb53217bf388a0d2fd7fb21e74ab9dffc173"
},
{
"fixed": "c2b2430b48f3c9eaccd2c3d2ad75bb540d4952f4"
},
{
"fixed": "7cfee26d1950250b14c5cb0a37b142f3fcc6396a"
},
{
"fixed": "97e93367e82752e475a33839a80b33bdbef1209f"
},
{
"fixed": "51b7841f3fe84606ec0bd8da859d22e05e5419ec"
},
{
"fixed": "1341e4b32e1fb1b0acd002ccd56f07bd32f2abc6"
},
{
"fixed": "04c35ab3bdae7fefbd7c7a7355f29fa03a035221"
}
]
}
],
"database_specific": {
"source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2024-35877.json"
}
},
{
"ranges": [
{
"type": "ECOSYSTEM",
"events": [
{
"introduced": "2.6.29"
},
{
"fixed": "4.19.312"
}
]
},
{
"type": "ECOSYSTEM",
"events": [
{
"introduced": "4.20.0"
},
{
"fixed": "5.4.274"
}
]
},
{
"type": "ECOSYSTEM",
"events": [
{
"introduced": "5.5.0"
},
{
"fixed": "5.10.215"
}
]
},
{
"type": "ECOSYSTEM",
"events": [
{
"introduced": "5.11.0"
},
{
"fixed": "5.15.155"
}
]
},
{
"type": "ECOSYSTEM",
"events": [
{
"introduced": "5.16.0"
},
{
"fixed": "6.1.85"
}
]
},
{
"type": "ECOSYSTEM",
"events": [
{
"introduced": "6.2.0"
},
{
"fixed": "6.6.26"
}
]
},
{
"type": "ECOSYSTEM",
"events": [
{
"introduced": "6.7.0"
},
{
"fixed": "6.8.5"
}
]
}
],
"package": {
"name": "Kernel",
"ecosystem": "Linux"
},
"database_specific": {
"source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2024-35877.json"
}
}
],
"modified": "2026-10-28T02:30:23.523832283Z",
"provider": "osv",
"references": [
"https://cert-portal.siemens.com/productcert/html/ssa-265688.html",
"https://git.kernel.org/stable/c/04c35ab3bdae7fefbd7c7a7355f29fa03a035221",
"https://git.kernel.org/stable/c/09e6bb53217bf388a0d2fd7fb21e74ab9dffc173",
"https://git.kernel.org/stable/c/1341e4b32e1fb1b0acd002ccd56f07bd32f2abc6",
"https://git.kernel.org/stable/c/51b7841f3fe84606ec0bd8da859d22e05e5419ec",
"https://git.kernel.org/stable/c/7cfee26d1950250b14c5cb0a37b142f3fcc6396a",
"https://git.kernel.org/stable/c/97e93367e82752e475a33839a80b33bdbef1209f",
"https://git.kernel.org/stable/c/c2b2430b48f3c9eaccd2c3d2ad75bb540d4952f4",
"https://git.kernel.org/stable/c/f18681daaec9665a15c5e7e0f591aad5d0ac622b",
"https://lists.debian.org/debian-lts-announce/2024/06/msg00017.html",
"https://lists.debian.org/debian-lts-announce/2024/06/msg00020.html",
"https://github.com/CVEProject/cvelistV5/tree/main/cves/2024/35xxx/CVE-2024-35877.json",
"https://nvd.nist.gov/vuln/detail/CVE-2024-35877",
"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git"
],
"provider_metadata": {
"cna_assigner": "Linux",
"osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2024/35xxx/CVE-2024-35877.json"
}
},
"related_cves": [
{
"value": "CVE-2024-35877",
"evidence": "/id"
}
],
"security_relevant": true,
"severity_evidence": null
},
"source_id": "core-osv",
"document_id": 489837,
"published_at": "2024-05-19T08:34:34.604+00:00"
}