HomeDefectsLIN1025-1834
Acknowledged

LIN1025-1834 : Security Advisory - linux - CVE-2022-50014

Created: Jun 18, 2025    Updated: Sep 4, 2026
Resolved Date: Jun 19, 2025
Found In Version: 10.25.33.1
Severity: Standard
Applicable for: Wind River Linux LTS 25
Component/s: Kernel

Description

In the Linux kernel, the following vulnerability has been resolved:EOL][EOL]mm/gup: fix FOLL_FORCE COW security issue and remove FOLL_COW[EOL][EOL]Ever since the Dirty COW (CVE-2016-5195) security issue happened, we know[EOL]that FOLL_FORCE can be possibly dangerous, especially if there are races[EOL]that can be exploited by user space.[EOL][EOL]Right now, it would be sufficient to have some code that sets a PTE of a[EOL]R/O-mapped shared page dirty, in order for it to erroneously become[EOL]writable by FOLL_FORCE.  The implications of setting a write-protected PTE[EOL]dirty might not be immediately obvious to everyone.[EOL][EOL]And in fact ever since commit 9ae0f87d009c ("mm/shmem: unconditionally set[EOL]pte dirty in mfill_atomic_install_pte"), we can use UFFDIO_CONTINUE to map[EOL]a shmem page R/O while marking the pte dirty.  This can be used by[EOL]unprivileged user space to modify tmpfs/shmem file content even if the[EOL]user does not have write permissions to the file, and to bypass memfd[EOL]write sealing -- Dirty COW restricted to tmpfs/shmem (CVE-2022-2590).[EOL][EOL]To fix such security issues for good, the insight is that we really only[EOL]need that fancy retry logic (FOLL_COW) for COW mappings that are not[EOL]writable (!VM_WRITE).  And in a COW mapping, we really only broke COW if[EOL]we have an exclusive anonymous page mapped.  If we have something else[EOL]mapped, or the mapped anonymous page might be shared (!PageAnonExclusive),[EOL]we have to trigger a write fault to break COW.  If we don't find an[EOL]exclusive anonymous page when we retry, we have to trigger COW breaking[EOL]once again because something intervened.[EOL][EOL]Let's move away from this mandatory-retry + dirty handling and rely on our[EOL]PageAnonExclusive() flag for making a similar decision, to use the same[EOL]COW logic as in other kernel parts here as well.  In case we stumble over[EOL]a PTE in a COW mapping that does not map an exclusive anonymous page, COW[EOL]was not properly broken and we have to trigger a fake write-fault to break[EOL]COW.[EOL][EOL]Just like we do in can_change_pte_writable() added via commit 64fe24a3e05e[EOL]("mm/mprotect: try avoiding write faults for exclusive anonymous pages[EOL]when changing protection") and commit 76aefad628aa ("mm/mprotect: fix[EOL]soft-dirty check in can_change_pte_writable()"), take care of softdirty[EOL]and uffd-wp manually.[EOL][EOL]For example, a write() via /proc/self/mem to a uffd-wp-protected range has[EOL]to fail instead of silently granting write access and bypassing the[EOL]userspace fault handler.  Note that FOLL_FORCE is not only used for debug[EOL]access, but also triggered by applications without debug intentions, for[EOL]example, when pinning pages via RDMA.[EOL][EOL]This fixes CVE-2022-2590. Note that only x86_64 and aarch64 are[EOL]affected, because only those support CONFIG_HAVE_ARCH_USERFAULTFD_MINOR.[EOL][EOL]Fortunately, FOLL_COW is no longer required to handle FOLL_FORCE. So[EOL]let's just get rid of it.[EOL][EOL]Thanks to Nadav Amit for pointing out that the pte_dirty() check in[EOL]FOLL_FORCE code is problematic and might be exploitable.[EOL][EOL]Note 1: We don't check for the PTE being dirty because it doesn't matter[EOL]\tfor making a "was COWed" decision anymore, and whoever modifies the[EOL]\tpage has to set the page dirty either way.[EOL][EOL]Note 2: Kernels before extended uffd-wp support and before[EOL]\tPageAnonExclusive (< 5.19) can simply revert the problematic[EOL]\tcommit instead and be safe regarding UFFDIO_CONTINUE. A backport to[EOL]\tv5.19 requires minor adjustments due to lack of[EOL]\tvma_soft_dirty_enabled().

CREATE(Triage):(User=lchen-cn) [CVE-2022-50014 (https://nvd.nist.gov/vuln/detail/CVE-2022-50014)