From: "Jose A. Perez de Azpillaga" <azpijr@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>,
Mike Rapoport <rppt@kernel.org>,
David Hildenbrand <david@kernel.org>,
Shuah Khan <shuah@kernel.org>, Peter Xu <peterx@redhat.com>
Cc: Lorenzo Stoakes <ljs@kernel.org>,
"Liam R. Howlett" <liam@infradead.org>,
Vlastimil Babka <vbabka@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org,
Muchun Song <muchun.song@linux.dev>,
Oscar Salvador <osalvador@suse.de>,
"Jose A. Perez de Azpillaga" <azpijr@gmail.com>
Subject: [PATCH v3 0/2] mm/userfaultfd: recheck WP registration in the hugetlb UFFDIO_COPY retry
Date: Tue, 3 Nov 2026 11:28:34 +0100 [thread overview]
Message-ID: <20261103102840.68903-1-azpijr@gmail.com> (raw)
The urgent fixes made hugetlb_fault() tolerate uffd bits left in VMAs
that are no longer registered for them, and asked for follow-ups that
remove the sources [1]. This is one: a hugetlb UFFDIO_COPY_MODE_WP copy
that has to fault in its source page doesn't recheck the WP registration
before retrying, so re-registering the range without WP in that window
leaves a uffd-wp PTE behind.
Patch 1 adds the missing check. Patch 2 adds a uffd-unit-tests case for
it, which fails on hugetlb without patch 1.
The other source 6/10 of [1] mentions, UFFDIO_COPY in MODE_WP racing
with UFFDIO_UNREGISTER [2], is closed by "mm/userfaultfd: write-lock the
VMA before waking waiters when unregistering" [3].
Based on mm-unstable.
Tested on x86_64 in QEMU.
[1] https://lore.kernel.org/20261015-urgent_fixes-v1-0-42796911043b@kernel.org
[2] https://lore.kernel.org/20261015-urgent_fixes-v1-6-42796911043b@kernel.org
[3] https://lore.kernel.org/20261031-fixes_core-v3-23-d6437171ecc3@kernel.org (in linux-next)
[4] https://lore.kernel.org/sashiko-outbox-194303@kernel.org
Changes in v3:
- 2/2: open the source userfaultfd with O_NONBLOCK and check for POLLIN,
so poll() waits for the fault instead of returning POLLERR at once
(reported by sashiko [4]), add Mike's Reviewed-by
- rebase on mm-unstable
Changes in v2:
- 1/2: drop the leftover sentence and the non-hugetlb reference from the
commit message, add Mike's Reviewed-by
- 2/2: "all memory types" in the commit message, rename copy to result
- rebase on mm-unstable
v2: https://lore.kernel.org/20261102081140.201987-1-azpijr@gmail.com
v1: https://lore.kernel.org/20261029221129.89068-1-azpijr@gmail.com
Jose A. Perez de Azpillaga (2):
mm/userfaultfd: recheck WP registration in the hugetlb UFFDIO_COPY
retry
selftests/mm: add a uffd test for re-registering during UFFDIO_COPY
mm/userfaultfd.c | 4 +
tools/testing/selftests/mm/uffd-unit-tests.c | 105 +++++++++++++++++++
2 files changed, 109 insertions(+)
base-commit: 0ea6dc8c4a2192227ec25768625686b8fcd5cb09
--
2.56.0
next reply other threads:[~2026-11-03 10:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 10:28 Jose A. Perez de Azpillaga [this message]
2026-11-03 10:28 ` [PATCH v3 1/2] " Jose A. Perez de Azpillaga
2026-11-03 10:28 ` [PATCH v3 2/2] selftests/mm: add a uffd test for re-registering during UFFDIO_COPY Jose A. Perez de Azpillaga
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=20261103102840.68903-1-azpijr@gmail.com \
--to=azpijr@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=muchun.song@linux.dev \
--cc=osalvador@suse.de \
--cc=peterx@redhat.com \
--cc=rppt@kernel.org \
--cc=shuah@kernel.org \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
/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
all inboxes | Powered by JetHome®