]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm-hugetlb-fix-uffd-wr-protection-for-cow-optimization-path-v3
authorPeter Xu <peterx@redhat.com>
Fri, 24 Mar 2023 14:26:20 +0000 (10:26 -0400)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 5 Apr 2023 23:01:33 +0000 (16:01 -0700)
Link: https://lkml.kernel.org/r/20230324142620.2344140-1-peterx@redhat.com
Reported-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
Cc: linux-stable <stable@vger.kernel.org>
Fixes: 166f3ecc0daf ("mm/hugetlb: hook page faults for uffd write protection")
Signed-off-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/hugetlb.c

index 9aea548b665c84264a79180e3930c6fc0ce07971..245038a9fe4eaa27e51ad83ba0abf4cb2c403deb 100644 (file)
@@ -5491,11 +5491,11 @@ static vm_fault_t hugetlb_wp(struct mm_struct *mm, struct vm_area_struct *vma,
         * Never handle CoW for uffd-wp protected pages.  It should be only
         * handled when the uffd-wp protection is removed.
         *
-        * Note that only the CoW optimization path can trigger this and
-        * got skipped, because hugetlb_fault() will always resolve uffd-wp
-        * bit first.
+        * Note that only the CoW optimization path (in hugetlb_no_page())
+        * can trigger this, because hugetlb_fault() will always resolve
+        * uffd-wp bit first.
         */
-       if (huge_pte_uffd_wp(pte))
+       if (!unshare && huge_pte_uffd_wp(pte))
                return 0;
 
        /*