mm/huge_memory: fix huge_zero_pfn race
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ 3b77e8c8cde581dadab9a0f1543a347e24315f11 · < 105d04edbec83010df5728f74d17fd9c108e7553| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
mm/huge_memory: fix huge_zero_pfn race
Patch series "mm/huge_memory: fix huge_zero_pfn race", v2.
There is a subtle race in the reference-counted huge_zero_folio implementation.
The fast path atomic logic fails to account for the fact that the shrinker (which drops the final huge_zero_refcount pin) can overwrite huge_zero_pfn with the ~0UL sentinel value in shrink_huge_zero_folio_scan() after a racing get_huge_zero_folio() installed a valid value there.
This results in huge_zero_folio being correctly set but huge_zero_pfn being set incorrectly and thus is_huge_zero_pfn() and consequently is_huge_zero_pmd() will misidentify the huge zero folio as being an ordinary THP folio.
This can result in the huge zero folio being split and otherwise treated incorrectly.
The solution to this is very subtle as there is an atomic fast path, and thus ordering in weakly ordered architectures has to be treated very carefully.
From the CVE record · Linux
When CONFIG_PERSISTENT_HUGE_ZERO_FOLIO is disabled, a race between the huge zero folio shrinker and a concurrent page fault can cause the kernel to misidentify a huge zero folio as an ordinary transparent huge page and handle it incorrectly. The input does not describe an attacker-controlled trigger or specify network access, authentication requirements, or user interaction.
Engineers running Linux kernels with CONFIG_PERSISTENT_HUGE_ZERO_FOLIO disabled should check their kernel; affected versions are not specified.