Re: [PATCH 2/2] mm: Fix a few rare cases of using swapin error pte marker

From: David Hildenbrand
Date: Fri Dec 16 2022 - 11:04:59 EST


diff --git a/mm/memory.c b/mm/memory.c
index 032ef700c3e8..3e836fecd035 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -828,7 +828,7 @@ copy_nonpresent_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm,
return -EBUSY;
return -ENOENT;
} else if (is_pte_marker_entry(entry)) {
- if (userfaultfd_wp(dst_vma))
+ if (is_swapin_error_entry(entry) || userfaultfd_wp(dst_vma))
set_pte_at(dst_mm, addr, dst_pte, pte);

As discussed, it would be great if we could in the future avoid such allow lists and instead have default allow and only handle problematic cases. Maybe we can do that in the future with selective clearing of markers.

--
Thanks,

David / dhildenb