From patchwork Wed Apr 5 16:02:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13202128 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6612FC76188 for ; Wed, 5 Apr 2023 16:02:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CC7D36B0072; Wed, 5 Apr 2023 12:02:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C77B26B0074; Wed, 5 Apr 2023 12:02:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B3FC36B0075; Wed, 5 Apr 2023 12:02:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id A65926B0072 for ; Wed, 5 Apr 2023 12:02:45 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 53D0E1A0C3F for ; Wed, 5 Apr 2023 16:02:45 +0000 (UTC) X-FDA: 80647805490.19.3E537D6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf20.hostedemail.com (Postfix) with ESMTP id E40BE1C0018 for ; Wed, 5 Apr 2023 16:02:42 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="HT/hLTzG"; spf=pass (imf20.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680710563; a=rsa-sha256; cv=none; b=428Z8i18hyRKgiPyaaui1gcyxEuHuzthqVbu9un6H9Lf47ZQixuNAh6RiSSO2axdqliFio ZB7xyhS4UdcZwElagm/lMKQI7zpELpl/nSIKVRa/OQvdyMDXApPq2Dt8Trc2S9ikTrg89H 56F6ZOK+0vzUUW2eRUhgN+CXZTc8snk= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="HT/hLTzG"; spf=pass (imf20.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1680710563; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=9SgMl0U05ydcYM0cFwFg6RkUkX/SVGBlhLdBNLErgqU=; b=uVSaHr5cEUtVNYh5ZpNvQmdSHZSx2SQexgSelDkl/KWXtedaTsQj2o1Y/7iKyT3SeuOinp 7dQ8dfOFCPlW22zFrAy77Ynkr7MuL1QtHwVSziKrBmjhRNwGbe/ndSkEAkBLfEFfcwVEkU qIQaS5mEM3ZO5CGn67azdXNcMqFogsw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680710562; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9SgMl0U05ydcYM0cFwFg6RkUkX/SVGBlhLdBNLErgqU=; b=HT/hLTzGRsnKiptOFq3qcrYA7nwWPRR+3QsgYGgGfIehJTDimPZRYNzj7KMYRkouibMERf KZiDMGJ/29DjHF/Ny9R7QMKaqqh88HHNXxlFAPvYNTt81h9fQr075F0PICGuaMsO2H5up+ dPrdwi6cHbeMbjK/xQDNihq86Lg1jvI= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-167-QqiIz_h_NguASfvv2dusNA-1; Wed, 05 Apr 2023 12:02:40 -0400 X-MC-Unique: QqiIz_h_NguASfvv2dusNA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 27BE238221CD; Wed, 5 Apr 2023 16:02:40 +0000 (UTC) Received: from t480s.fritz.box (unknown [10.39.195.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id DD0DF492C14; Wed, 5 Apr 2023 16:02:38 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Peter Xu , Muhammad Usama Anjum , stable@vger.kernel.org Subject: [PATCH v2 1/2] mm/userfaultfd: fix uffd-wp handling for THP migration entries Date: Wed, 5 Apr 2023 18:02:35 +0200 Message-Id: <20230405160236.587705-2-david@redhat.com> In-Reply-To: <20230405160236.587705-1-david@redhat.com> References: <20230405160236.587705-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Rspam-User: X-Rspamd-Queue-Id: E40BE1C0018 X-Rspamd-Server: rspam01 X-Stat-Signature: aimupqztccd64nh1fdpiuunsgk7srx46 X-HE-Tag: 1680710562-596741 X-HE-Meta: U2FsdGVkX1+gbsNKzV851Opghp+9zwXikDN9DfbeARpTpq8SePlagjli9xMbTnhe9y0aB99W0TGbczfCmcZN0uTqY5eaBBtNDlrHlx1KYI3Wo5KbTl3NRiQkw5ucx7P3D1z0Xvd+yLNNzCag71zJphnWUIPvsNIMyUAU79grk4b5r6ReuoTYAM72d4j2aRB7LTIaarKuk6T7m0dm1a28Coju12orkGVEl8JUFfS0T4wQuOV17q71zOxJUpHvkoqYmZD6fw536W+xcZsY7PT8+OWZVKrG0uNFcrbmHDiu4E2IMjx2PpiiIrHntOw+dD9oNmMReJ470GbjeTbOZ/bfU2KNsUvAuaAoIra0lg5kjIGC4w1dSbBRBEzAl5lcaEjPg9v/NnOH/x/dbPPqfnTr0w8NSqmO3BKeQYpv7gPtZgeTyBiQX9ryK3MFelihceOyu1XAjGUYDmOBEaFoirLH9645wsLRELSant5KzBBPEcfy4YvL2k9UWzbVhSSL7eFB4LmlKy9JR8xnKfKTki7ylPWxhSA4bVdDn9rR3rLEi7Y6sCDe1lQR+1dBbUpfs+5YTOzeQKBmRovvK49U3t4VM4irLGHdzCwUOcilM5fCQWR7iXlACgTSEVSCxlRcdAdjARigxbvMn4zPyXrAkC6nZ/RGIMfeQAWymL6VcoRlaUSOQJcYUcrccBUr+MfLc5Az5UZofgLnWh7RfP42At2R7K9Z9XOelLjLr7C/bSzc+DlZsyE3AO98N+82IXUJO8adrA8AGEBvkrY7AWbQMm2WmX9WxCf+duMPw3dZP8UqiKiigfwj0SBhB7qGT3g3BFTomdFyyThDbQxniCIMq5juI2rAr5KxtBoxsCsty5lpMzC814L+xayktk1usjNcuo7d40aG6dhkt7at2Fpa4uuFeDfUz2/TYI15UwIn+1RJqs32Jq8odYnYGcOl4ooWFvdwpV0+2C6L5nXSrXdzG9P rq/Hh8ak vHuqXN9stF/w4cPg35IMYvVxWmvnPjfoukES8Fkhgjfm+6R09Tx1fpb3TDd/EWAXmQmf/scIuP6Im5GJ/8TpVO1QnL+dyiitws+qSKCvfiKYaJNuB5I3o7ne2MTu3k3yIB2CqodwohfBYkFErblHWT/krpGaAjzdbCYl9qY9Cm8YoFU84tfPOBrlLxUVNKw2NLx75CRe3A70ehKTYJl9bNxxRc/sNSg6M1kXr5YrNbLopr8Tuh1z7EdfrWg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Looks like what we fixed for hugetlb in commit 44f86392bdd1 ("mm/hugetlb: fix uffd-wp handling for migration entries in hugetlb_change_protection()") similarly applies to THP. Setting/clearing uffd-wp on THP migration entries is not implemented properly. Further, while removing migration PMDs considers the uffd-wp bit, inserting migration PMDs does not consider the uffd-wp bit. We have to set/clear independently of the migration entry type in change_huge_pmd() and properly copy the uffd-wp bit in set_pmd_migration_entry(). Verified using a simple reproducer that triggers migration of a THP, that the set_pmd_migration_entry() no longer loses the uffd-wp bit. Fixes: f45ec5ff16a7 ("userfaultfd: wp: support swap and page migration") Reviewed-by: Peter Xu Cc: stable@vger.kernel.org Signed-off-by: David Hildenbrand --- mm/huge_memory.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 032fb0ef9cd1..e3706a2b34b2 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1838,10 +1838,10 @@ int change_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, if (is_swap_pmd(*pmd)) { swp_entry_t entry = pmd_to_swp_entry(*pmd); struct page *page = pfn_swap_entry_to_page(entry); + pmd_t newpmd; VM_BUG_ON(!is_pmd_migration_entry(*pmd)); if (is_writable_migration_entry(entry)) { - pmd_t newpmd; /* * A protection check is difficult so * just be safe and disable write @@ -1855,8 +1855,16 @@ int change_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, newpmd = pmd_swp_mksoft_dirty(newpmd); if (pmd_swp_uffd_wp(*pmd)) newpmd = pmd_swp_mkuffd_wp(newpmd); - set_pmd_at(mm, addr, pmd, newpmd); + } else { + newpmd = *pmd; } + + if (uffd_wp) + newpmd = pmd_swp_mkuffd_wp(newpmd); + else if (uffd_wp_resolve) + newpmd = pmd_swp_clear_uffd_wp(newpmd); + if (!pmd_same(*pmd, newpmd)) + set_pmd_at(mm, addr, pmd, newpmd); goto unlock; } #endif @@ -3251,6 +3259,8 @@ int set_pmd_migration_entry(struct page_vma_mapped_walk *pvmw, pmdswp = swp_entry_to_pmd(entry); if (pmd_soft_dirty(pmdval)) pmdswp = pmd_swp_mksoft_dirty(pmdswp); + if (pmd_uffd_wp(pmdval)) + pmdswp = pmd_swp_mkuffd_wp(pmdswp); set_pmd_at(mm, address, pvmw->pmd, pmdswp); page_remove_rmap(page, vma, true); put_page(page); From patchwork Wed Apr 5 16:02:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13202130 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C6F3C7619A for ; Wed, 5 Apr 2023 16:02:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3C6AC6B0075; Wed, 5 Apr 2023 12:02:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 377386B0078; Wed, 5 Apr 2023 12:02:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 23F846B007B; Wed, 5 Apr 2023 12:02:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 15D536B0075 for ; Wed, 5 Apr 2023 12:02:55 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D8A9F1410BD for ; Wed, 5 Apr 2023 16:02:54 +0000 (UTC) X-FDA: 80647805868.19.82F2826 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf14.hostedemail.com (Postfix) with ESMTP id 0458E10004B for ; Wed, 5 Apr 2023 16:02:49 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Syajd34a; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf14.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1680710570; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=haUnYelB5LusrEoBxVPl4UNNfNfVynWBkPKVNWIDj2U=; b=taxGNDUiKLS4jc7HTk/zRP5lj3bmBoAmR06RjpUDv+vkRGBEMp6/byaUdQXLrVRw/yFnhT orKzJ85DIOCOMCBaAeqL2Q8vtJaCwZLHKCO5DBx9ZkFfFXFHrGUveKjaP6592zsxKHuGF3 X4oEQE6TitdFb/ybEqgXbISMctyPLzU= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Syajd34a; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf14.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680710570; a=rsa-sha256; cv=none; b=e13PzUVA+thghp7/XbUJdZmVKsy9rR7cAEaoAdEASiY8kuZVXONqym+xo8ym51myAfyCrS BUCoN0OFq+dWRmbuTqhxCZSX5Ek2xr6O2yl7sZKI1QYHKlyqf69NaKMgqFA8S3osLfGJXc 2iwdiAsAePf6XcCWBtu3T/mQ9STtAuU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680710569; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=haUnYelB5LusrEoBxVPl4UNNfNfVynWBkPKVNWIDj2U=; b=Syajd34ab0PjiryPvfcj4ZKv3oHUu7PpgOTG6agSHWbMIlKn/u9uR3pn51uA8hdP6cHdS8 xq7xcaa3yPxJ9TCWPP0eE7OFytGHvJr9zzhgxWjg6LeKD62E/hpmSLziEN+9hJwiEn+kQG 22+bD8NvmEZKD26s+2otOPhngbeFWyU= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-643-_hSYB7tFOaKls9fUcmn9jQ-1; Wed, 05 Apr 2023 12:02:42 -0400 X-MC-Unique: _hSYB7tFOaKls9fUcmn9jQ-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1837C1C02D3D; Wed, 5 Apr 2023 16:02:42 +0000 (UTC) Received: from t480s.fritz.box (unknown [10.39.195.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8AEDF492C14; Wed, 5 Apr 2023 16:02:40 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Peter Xu , Muhammad Usama Anjum Subject: [PATCH v2 2/2] mm/userfaultfd: don't consider uffd-wp bit of writable migration entries Date: Wed, 5 Apr 2023 18:02:36 +0200 Message-Id: <20230405160236.587705-3-david@redhat.com> In-Reply-To: <20230405160236.587705-1-david@redhat.com> References: <20230405160236.587705-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 0458E10004B X-Stat-Signature: dqgyp3kbj3btmke14zm4f5rd653hzyem X-HE-Tag: 1680710569-820202 X-HE-Meta: U2FsdGVkX19YbbioybNHMMBm0P/+ikg5Z/QAV1kILW5U78+CyRC/1EO1apxeev04+JOi9LLVnTl+y8aJiy9//zq+hj6VBd0iru9bL5qpQTKegQO6TyXK367iuvxq07kEb39CiTU0YCD8jOOo1xfDBquK+FWiP3jsAWshJG51OYpOS+SOYR7NomY5wCOcwK/shatzVt9bzUWB0o9hmUVisuJOEpZEhR/8j07ORHL+GOOh3kOuK7POL4xcbd1YdMlbpKieGqZRQXVCju5S7yprwyFMbZCeNks3+LRKXoGzZ6laXbFGEpQ2K7QD6l31yrbovM+f/Vib4+jvctXTZBwQjdymvGJ2jMk98Vsp1g41c6jwnj3grurPYc28WDUQzFMUANgpDZ+yUk3yPIx5pk1C654qRQnwi3D6tTVOleeocsYoGtxbW1Kjp0J9Q5P0EVV/ZNRpmLuHYCG5DbZsNMIOg2ARU+WQBnQaNvzzjjv5TEjYtof+eoodUeVbVW4dba2a5YPkF0cSlD0hThN5DoCsNggDV59OkmUYHlH4AINyjsmzgCicLgQ7TPtHmUf/QrFMZR0JrUMtmtfIO7pFspf2J2lUscxj88nqyIZ2zS61vrV4GzaTnD5wSG90KFheXGXVrmrOCWRbpNENAohs+zlAe2x5e6eQLuaY4aLcOckqcnsh9czjGjkOj87MgRZp3A9tMEsyg613m+opcGGzPYtP1SgllIKOd8p5Gio/gOPpRAsGvQWNKFtu2muZWUJW7qRrP8/xcywthoeZJqHS7YUPeoTSQsUorwVJDa8fREknXHuxXncnRYRoVSkPj1LfYA3H/YxkP34F3qumtSZFMXPuJ9s/J7t1eJ4yv7dtNT6zhkO4CHSMFQFMDGmmDbfzJgVUnQgj5jWTIpZzw8/y8cOGa0lYMWelQSUqPbJwKXqQWKpIg+h33RaW4Kh2zj/kxjsMIAWlfFGIXJa4LTkZOnO kf7I/qoj TTzdI9oQ/iZfX7RxtxNuvyMd5MjvvEM+AdJrqBKd0ImwI2D8bTFxibaM6Fu8KxdwWzrSmFUwA4nkZH0K61Y+hA0T+IigdGzCJq6+DNcQJuQ0e/qzP6uqDm8vQFDbGNyS5GQxC5ac/m3M3U4790dUs4y2Y1nI4bRfcarPu3JKe4xXZ9lzBHOo7tfmfvA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: If we end up with a writable migration entry that has the uffd-wp bit set, we already messed up: the source PTE/PMD was writable, which means we could have modified the page without notifying uffd first. Setting the uffd-wp bit always implies converting migration entries to !writable migration entries. Commit 8f34f1eac382 ("mm/userfaultfd: fix uffd-wp special cases for fork()") documents that "3. Forget to carry over uffd-wp bit for a write migration huge pmd entry", but it doesn't really say why that should be relevant. So let's remove that code to avoid hiding an eventual underlying issue (in the future, we might want to warn when creating writable migration entries that have the uffd-wp bit set -- or even better when turning a PTE writable that still has the uffd-wp bit set). This now matches the handling for hugetlb migration entries in hugetlb_change_protection(). In copy_huge_pmd()/copy_nonpresent_pte()/copy_hugetlb_page_range(), we still transfer the uffd-bit also for writable migration entries, but simply because we have unified handling for "writable" and "readable-exclusive" migration entries, and we care about transferring the uffd-wp bit for the latter. Reviewed-by: Peter Xu Signed-off-by: David Hildenbrand --- mm/huge_memory.c | 2 -- mm/mprotect.c | 2 -- 2 files changed, 4 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index e3706a2b34b2..fffc953fa6ea 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1853,8 +1853,6 @@ int change_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, newpmd = swp_entry_to_pmd(entry); if (pmd_swp_soft_dirty(*pmd)) newpmd = pmd_swp_mksoft_dirty(newpmd); - if (pmd_swp_uffd_wp(*pmd)) - newpmd = pmd_swp_mkuffd_wp(newpmd); } else { newpmd = *pmd; } diff --git a/mm/mprotect.c b/mm/mprotect.c index 13e84d8c0797..e04e9ea62ae7 100644 --- a/mm/mprotect.c +++ b/mm/mprotect.c @@ -223,8 +223,6 @@ static long change_pte_range(struct mmu_gather *tlb, newpte = swp_entry_to_pte(entry); if (pte_swp_soft_dirty(oldpte)) newpte = pte_swp_mksoft_dirty(newpte); - if (pte_swp_uffd_wp(oldpte)) - newpte = pte_swp_mkuffd_wp(newpte); } else if (is_writable_device_private_entry(entry)) { /* * We do not preserve soft-dirtiness. See