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():
CVE-2024-35877
Primary source · Revision 1
Imported from structured advisory data. Source references identify upstream records or fields; verify affected versions and your deployed configuration.
Security context
Source reference: cve:CVE-2024-35877
Linux
Source reference: /containers/cna/affected/0/product
- Affected versions
- Not stated in this record
- Fixed versions
- Not stated in this record
- Prerequisites
- Not stated in this record
Linux
Source reference: /containers/cna/affected/1/product
- Affected versions
- Not stated in this record
- Fixed versions
- Not stated in this record
- Prerequisites
- Not stated in this record
Structured affected-version data
Original package identities and version rules from this source.
[
{
"repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
"vendor": "Linux",
"product": "Linux",
"versions": [
{
"status": "affected",
"version": "5899329b19100c0b82dc78e9b21ed8b920c9ffb3",
"lessThan": "f18681daaec9665a15c5e7e0f591aad5d0ac622b",
"versionType": "git"
},
{
"status": "affected",
"version": "5899329b19100c0b82dc78e9b21ed8b920c9ffb3",
"lessThan": "09e6bb53217bf388a0d2fd7fb21e74ab9dffc173",
"versionType": "git"
},
{
"status": "affected",
"version": "5899329b19100c0b82dc78e9b21ed8b920c9ffb3",
"lessThan": "c2b2430b48f3c9eaccd2c3d2ad75bb540d4952f4",
"versionType": "git"
},
{
"status": "affected",
"version": "5899329b19100c0b82dc78e9b21ed8b920c9ffb3",
"lessThan": "7cfee26d1950250b14c5cb0a37b142f3fcc6396a",
"versionType": "git"
},
{
"status": "affected",
"version": "5899329b19100c0b82dc78e9b21ed8b920c9ffb3",
"lessThan": "97e93367e82752e475a33839a80b33bdbef1209f",
"versionType": "git"
},
{
"status": "affected",
"version": "5899329b19100c0b82dc78e9b21ed8b920c9ffb3",
"lessThan": "51b7841f3fe84606ec0bd8da859d22e05e5419ec",
"versionType": "git"
},
{
"status": "affected",
"version": "5899329b19100c0b82dc78e9b21ed8b920c9ffb3",
"lessThan": "1341e4b32e1fb1b0acd002ccd56f07bd32f2abc6",
"versionType": "git"
},
{
"status": "affected",
"version": "5899329b19100c0b82dc78e9b21ed8b920c9ffb3",
"lessThan": "04c35ab3bdae7fefbd7c7a7355f29fa03a035221",
"versionType": "git"
}
],
"programFiles": [
"arch/x86/mm/pat/memtype.c",
"mm/memory.c"
],
"defaultStatus": "unaffected"
},
{
"repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
"vendor": "Linux",
"product": "Linux",
"versions": [
{
"status": "affected",
"version": "2.6.29"
},
{
"status": "unaffected",
"version": "0",
"lessThan": "2.6.29",
"versionType": "semver"
},
{
"status": "unaffected",
"version": "4.19.312",
"versionType": "semver",
"lessThanOrEqual": "4.19.*"
},
{
"status": "unaffected",
"version": "5.4.274",
"versionType": "semver",
"lessThanOrEqual": "5.4.*"
},
{
"status": "unaffected",
"version": "5.10.215",
"versionType": "semver",
"lessThanOrEqual": "5.10.*"
},
{
"status": "unaffected",
"version": "5.15.155",
"versionType": "semver",
"lessThanOrEqual": "5.15.*"
},
{
"status": "unaffected",
"version": "6.1.85",
"versionType": "semver",
"lessThanOrEqual": "6.1.*"
},
{
"status": "unaffected",
"version": "6.6.26",
"versionType": "semver",
"lessThanOrEqual": "6.6.*"
},
{
"status": "unaffected",
"version": "6.8.5",
"versionType": "semver",
"lessThanOrEqual": "6.8.*"
},
{
"status": "unaffected",
"version": "6.9",
"versionType": "original_commit_for_fix",
"lessThanOrEqual": "*"
}
],
"programFiles": [
"arch/x86/mm/pat/memtype.c",
"mm/memory.c"
],
"defaultStatus": "affected"
}
]- Related CVEs
- CVE-2024-35877
Source reference:
/cveMetadata/cveId
Publisher severity
No explicit severity was provided.
- Event
- #26526 · Revision 1
- Added to Heist Feed
- Publisher date