Skip to contentSkip to conversation

userfaultfd-wp-drop-_page_uffd_wp-properly-when-fork.patch removed from -mm tree

merged [email protected] 1 participant 1 message Apr 8, 2020

lore
Share & tools
lore

[email protected]

author tree notice Applied
#0 lore raw

The patch titled
Subject: userfaultfd: wp: drop _PAGE_UFFD_WP properly when fork
has been removed from the -mm tree. Its filename was
userfaultfd-wp-drop-_page_uffd_wp-properly-when-fork.patch

This patch was dropped because it was merged into mainline or a subsystem tree

------------------------------------------------------
From: Peter Xu <[email protected]>
Subject: userfaultfd: wp: drop _PAGE_UFFD_WP properly when fork

UFFD_EVENT_FORK support for uffd-wp should be already there, except that we should clean the uffd-wp bit if uffd fork event is not enabled. Detect that to avoid _PAGE_UFFD_WP being set even if the VMA is not being tracked by VM_UFFD_WP. Do this for both small PTEs and huge PMDs.

Cc Andrea Arcangeli <[email protected]>
Cc Bobby Powers <[email protected]>
Cc Brian Geffon <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc Denis Plotnikov <[email protected]>
Cc "Dr . David Alan Gilbert" <[email protected]>
Cc Hugh Dickins <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc "Kirill A . Shutemov" <[email protected]>
Cc Martin Cracauer <[email protected]>
Cc Marty McFadden <[email protected]>
Cc Maya Gokhale <[email protected]>
Cc Mel Gorman <[email protected]>
Cc Mike Kravetz <[email protected]>
Cc Pavel Emelyanov <[email protected]>
Cc Rik van Riel <[email protected]>
Cc Shaohua Li <[email protected]>

---

 mm/huge_memory.c |    8 ++++++++
 mm/memory.c      |    8 ++++++++
 2 files changed, 16 insertions(+)
mm/huge_memory.c renamed from mm/huge_memory.c~userfaultfd-wp-drop-_page_uffd_wp-properly-when-fork +8 -0
@@ -1044,6 +1044,14 @@ int copy_huge_pmd(struct mm_struct *dst_
 	ret = -EAGAIN;
 	pmd = *src_pmd;
 
+	/*
+	 * Make sure the _PAGE_UFFD_WP bit is cleared if the new VMA
+	 * does not have the VM_UFFD_WP, which means that the uffd
+	 * fork event is not enabled.
+	 */
+	if (!(vma->vm_flags & VM_UFFD_WP))
+		pmd = pmd_clear_uffd_wp(pmd);
+
 #ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION
 	if (unlikely(is_swap_pmd(pmd))) {
 		swp_entry_t entry = pmd_to_swp_entry(pmd);
mm/memory.c renamed from mm/memory.c~userfaultfd-wp-drop-_page_uffd_wp-properly-when-fork +8 -0
@@ -785,6 +785,14 @@ copy_one_pte(struct mm_struct *dst_mm, s
 		pte = pte_mkclean(pte);
 	pte = pte_mkold(pte);
 
+	/*
+	 * Make sure the _PAGE_UFFD_WP bit is cleared if the new VMA
+	 * does not have the VM_UFFD_WP, which means that the uffd
+	 * fork event is not enabled.
+	 */
+	if (!(vm_flags & VM_UFFD_WP))
+		pte = pte_clear_uffd_wp(pte);
+
 	page = vm_normal_page(vma, addr, pte);
 	if (page) {
 		get_page(page);

_

Patches currently in -mm which might be from [email protected] are

mm-mempolicy-allow-lookup_node-to-handle-fatal-signal.patch mm-gup-mark-lock-taken-only-after-a-successful-retake.patch