CVE-2024-36943: fs/proc/task_mmu: fix loss of young/dirty bits during pagemap scan
Description
===========
In the Linux kernel, the following vulnerability has been resolved:
fs/proc/task_mmu: fix loss of young/dirty bits during pagemap scan
make_uffd_wp_pte() was previously doing:
pte = ptep_get(ptep); ptep_modify_prot_start(ptep); pte = pte_mkuffd_wp(pte); ptep_modify_prot_commit(ptep, pte);
But if another thread accessed or dirtied the pte between the first 2 calls, this could lead to loss of that information. Since ptep_modify_prot_start() gets and clears atomically, the following is the correct pattern and prevents any possible race. Any access after the first call would see an invalid pte and cause a fault:
pte = ptep_modify_prot_start(ptep); pte = pte_mkuffd_wp(pte); ptep_modify_prot_commit(ptep, pte);
The Linux kernel CVE team has assigned CVE-2024-36943 to this issue.
Affected and fixed versions
===========================
Issue introduced in 6.7 with commit 52526ca7fdb9 and fixed in 6.8.10 with commit 74b3d66f91d9 Issue introduced in 6.7 with commit 52526ca7fdb9 and fixed in 6.9 with commit c70dce4982ce
Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community.
Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at
https://cve.org/CVERecord/?id=CVE-2024-36943
will be updated if fixes are backported, please check that for the most up to date information about this issue.
Affected files
==============
The file(s) affected by this issue are:
fs/proc/task_mmu.c
Mitigation
==========
The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits:
https://git.kernel.org/stable/c/74b3d66f91d9f539f99faad74d796fa9a389a015 https://git.kernel.org/stable/c/c70dce4982ce1718bf978a35f8e26160b82081f4