From: Mike Kravetz <mike.kravetz@oracle.com>
To: Peter Xu <peterx@redhat.com>
Cc: David Hildenbrand <david@redhat.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Mike Rapoport <rppt@linux.vnet.ibm.com>,
Nadav Amit <nadav.amit@gmail.com>,
Axel Rasmussen <axelrasmussen@google.com>,
Andrea Arcangeli <aarcange@redhat.com>,
Muhammad Usama Anjum <usama.anjum@collabora.com>,
linux-stable <stable@vger.kernel.org>
Subject: Re: [PATCH v3] mm/hugetlb: Fix uffd wr-protection for CoW optimization path
Date: Mon, 27 Mar 2023 11:34:38 -0700 [thread overview]
Message-ID: <20230327183438.GC4184@monkey> (raw)
In-Reply-To: <ZCBavqZE2cyVOzaW@x1n>
On 03/26/23 10:46, Peter Xu wrote:
> On Fri, Mar 24, 2023 at 11:36:53PM +0100, David Hildenbrand wrote:
> > > > @@ -5487,6 +5487,17 @@ static vm_fault_t hugetlb_wp(struct mm_struct *mm, struct vm_area_struct *vma,
> > > > unsigned long haddr = address & huge_page_mask(h);
> > > > struct mmu_notifier_range range;
> > > > + /*
> > > > + * 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 (in hugetlb_no_page())
> > > > + * can trigger this, because hugetlb_fault() will always resolve
> > > > + * uffd-wp bit first.
> > > > + */
> > > > + if (!unshare && huge_pte_uffd_wp(pte))
> > > > + return 0;
> > >
> > > This looks correct. However, since the previous version looked correct I must
> > > ask. Can we have unshare set and huge_pte_uffd_wp true? If so, then it seems
> > > we would need to possibly propogate that uffd_wp to the new pte as in v2
>
> Good point, thanks for spotting!
>
> >
> > We can. A reproducer would share an anon hugetlb page because parent and
> > child. In the parent, we would uffd-wp that page. We could trigger unsharing
> > by R/O-pinning that page.
>
> Right. This seems to be a separate bug.. It should be triggered in
> totally different context and much harder due to rare use of RO pins,
> meanwhile used with userfault-wp.
>
> If both of you agree, I can prepare a separate patch for this bug, and I'll
> better prepare a reproducer/selftest with it.
>
I am OK with separate patches, and agree that the R/O pinning case is less
likely to happen.
Since this patch addresses the issue found by Muhammad,
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
--
Mike Kravetz
next prev parent reply other threads:[~2023-03-27 18:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-24 14:26 Peter Xu
2023-03-24 14:33 ` Muhammad Usama Anjum
2023-03-24 22:27 ` Mike Kravetz
2023-03-24 22:36 ` David Hildenbrand
2023-03-26 14:46 ` Peter Xu
2023-03-27 18:34 ` Mike Kravetz [this message]
2023-03-27 20:57 ` David Hildenbrand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230327183438.GC4184@monkey \
--to=mike.kravetz@oracle.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=axelrasmussen@google.com \
--cc=david@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nadav.amit@gmail.com \
--cc=peterx@redhat.com \
--cc=rppt@linux.vnet.ibm.com \
--cc=stable@vger.kernel.org \
--cc=usama.anjum@collabora.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox