From: Peter Xu <peterx@redhat.com>
To: David Hildenbrand <david@redhat.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Andrew Morton <akpm@linux-foundation.org>,
Muhammad Usama Anjum <usama.anjum@collabora.com>
Subject: Re: [PATCH v1 2/2] mm/userfaultfd: don't consider uffd-wp bit of writable migration entries
Date: Wed, 5 Apr 2023 11:15:12 -0400 [thread overview]
Message-ID: <ZC2QgGCWyc41x7Je@x1n> (raw)
In-Reply-To: <20230405142535.493854-3-david@redhat.com>
On Wed, Apr 05, 2023 at 04:25:35PM +0200, David Hildenbrand wrote:
> 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.
>
> Signed-off-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
I think that's mostly for sanity to carry over one generic bit between
present <-> !present, even if uffd-wp is not that generic and currently
closely bound to write bit.
E.g., we will need to be more careful when we want to change the meaning of
uffd-wp bit some day, but that'll always be challenging anyway, so not
something this will change.
Thanks,
--
Peter Xu
next prev parent reply other threads:[~2023-04-05 15:15 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-05 14:25 [PATCH v1 0/2] mm/userfaultfd: fix and cleanup for migration entries with uffd-wp David Hildenbrand
2023-04-05 14:25 ` [PATCH v1 1/2] mm/userfaultfd: fix uffd-wp handling for THP migration entries David Hildenbrand
2023-04-05 15:12 ` Peter Xu
2023-04-05 15:17 ` David Hildenbrand
2023-04-05 15:43 ` Peter Xu
2023-04-05 15:51 ` David Hildenbrand
2023-04-05 14:25 ` [PATCH v1 2/2] mm/userfaultfd: don't consider uffd-wp bit of writable " David Hildenbrand
2023-04-05 15:15 ` Peter Xu [this message]
2023-04-05 15:17 ` [PATCH v1 0/2] mm/userfaultfd: fix and cleanup for migration entries with uffd-wp Peter Xu
2023-04-05 15:19 ` 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=ZC2QgGCWyc41x7Je@x1n \
--to=peterx@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.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