mm/mglru: fix and remove redundant unevictable folio handling
Linux Linux
At a glance
In the Linux kernel, the following vulnerability has been resolved: mm/mglru: fix and remove redundant unevictable folio handling sort_folio() has a shortcut for moving folios that are no longer evictable but are still sitting on a generation list. However, this shortcut is buggy. It does not follow the PG_lru usage convention, and it has a more serious issue. Unevictable folios are not threaded on lists[LRU_UNEVICTABLE], so that folio->lru can be reused to hold folio->mlock_count (see the comment in lruvec_init()). Hence lruvec_add_folio() skips the list_add() for them, and every other place that turns a folio unevictable initialises mlock_count explicitly: lru_add() sets it to 0, __mlock_folio() and __mlock_new_folio() set it to !!folio_test_mlocked(folio). sort_folio() sets nothing, and the lru_gen_del_folio() right above it may have already poisoned folio->lru via list_del(), so mlock_count ends up aliasing LIST_POISON2, which reads as 0x122, i.e. 290. The result is user visible. On munlock, __munlock_folio() decrements that bogus count, finds it still non-zero and bails out before clearing PG_mlocked, so the folio remains unevictable and the Mlocked accounting stays inflated until the folio is freed. The shortcut also touches the LRU flags in the wrong order. It calls lru_gen_del_folio() while PG_lru is still set, so a concurrent folio_test_clear_lru() (e.g.…
Full source description
In the Linux kernel, the following vulnerability has been resolved: mm/mglru: fix and remove redundant unevictable folio handling sort_folio() has a shortcut for moving folios that are no longer evictable but are still sitting on a generation list. However, this shortcut is buggy. It does not follow the PG_lru usage convention, and it has a more serious issue. Unevictable folios are not threaded on lists[LRU_UNEVICTABLE], so that folio->lru can be reused to hold folio->mlock_count (see the comment in lruvec_init()). Hence lruvec_add_folio() skips the list_add() for them, and every other place that turns a folio unevictable initialises mlock_count explicitly: lru_add() sets it to 0, __mlock_folio() and __mlock_new_folio() set it to !!folio_test_mlocked(folio). sort_folio() sets nothing, and the lru_gen_del_folio() right above it may have already poisoned folio->lru via list_del(), so mlock_count ends up aliasing LIST_POISON2, which reads as 0x122, i.e. 290. The result is user visible. On munlock, __munlock_folio() decrements that bogus count, finds it still non-zero and bails out before clearing PG_mlocked, so the folio remains unevictable and the Mlocked accounting stays inflated until the folio is freed. The shortcut also touches the LRU flags in the wrong order. It calls lru_gen_del_folio() while PG_lru is still set, so a concurrent folio_test_clear_lru() (e.g. compaction, folio_isolate_lru()) can succeed on a folio that has already been taken off the generation list, which may lead to unexpected behavior. So fix it by isolating them as common folios and letting the generic shrink path cull them. This matches the classical LRU behavior, and there should be no visible effect on the generic eviction or isolation behavior. There is no performance concern either, such a folio goes through this once, and then it is off the generation lists for good.
Source description · CVE List / CNA
System impact
CVSS summary v3.1
- Published:
- Updated:
- EPSS:
- 0.215%
- Exploited in attacks:
- Not confirmed
- Ransomware campaigns:
- Not confirmed
- Attack vector:
- Local
Related CWE
Affected software
Vendor, product and affected version ranges.
| Vendor | Product | Affected versions |
|---|---|---|
| Vendor:Linux | Linux | Affected versions:6.1Show full version range for Linux
Git commit ranges (source code)
|
| Vendor:Red Hat | Red Hat Enterprise Linux 10 | Affected versions:Source does not specify a version range |
| Vendor:Red Hat | Red Hat Enterprise Linux 6 | Affected versions:Source does not specify a version range |
| Vendor:Red Hat | Red Hat Enterprise Linux 9 | Affected versions:Source does not specify a version range |
| Vendor:Red Hat | Red Hat OpenShift Container Platform 4 | Affected versions:Source does not specify a version range |
| Vendor:Red Hat | Red Hat OpenShift Container Platform 5 | Affected versions:Source does not specify a version range |
| Vendor:SUSE | SUSE Linux Enterprise Desktop 15 SP7 | Affected versions:Source does not specify a version range |
| Vendor:SUSE | SUSE Linux Enterprise High Availability Extension 15 SP7 | Affected versions:Source does not specify a version range |
| Vendor:SUSE | SUSE Linux Enterprise High Availability Extension 16.0 | Affected versions:Source does not specify a version range |
| Vendor:SUSE | SUSE Linux Enterprise High Availability Extension 16.1 | Affected versions:Source does not specify a version range |
1–10 of 34 · Page 1 of 4
CVSS scores and metrics2
Red Hat · Red Hat VEX (adp)Primary5.5 / 10MediumCVSS 3.1Details
- Attack complexity
- Low
- Confidentiality
- None
- Integrity
- None
- Availability
- High
- Attack vector
- Local
- Privileges required
- Low
- User interaction
- Not required
- Scope
- Unchanged
Source vector
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:HSUSE · SUSE VEX (adp)5.5 / 10MediumCVSS 3.1Details
- Attack complexity
- Low
- Confidentiality
- None
- Integrity
- None
- Availability
- High
- Attack vector
- Local
- Privileges required
- Low
- User interaction
- Not required
- Scope
- Unchanged
Source vector
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:HCVSS measures severity; EPSS estimates exploitation probability. Lack of confirmed attacks does not mean lack of risk.
This product uses the NVD API but is not endorsed or certified by the NVD. CVE® records © The MITRE Corporation, reproduced under the CVE Terms of Use. Data sources and licences