From: Umang Pokhriyal <umangpokhriyall@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Mike Rapoport <rppt@kernel.org>, Peter Xu <peterx@redhat.com>,
David Hildenbrand <david@kernel.org>,
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>, Shuah Khan <shuah@kernel.org>,
linux-mm@kvack.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org,
Umang Pokhriyal <umangpokhriyall@gmail.com>
Subject: [PATCH 0/2] userfaultfd: validate the whole range before changing write protection
Date: Mon, 2 Nov 2026 16:06:19 +0530 [thread overview]
Message-ID: <20261102103621.156928-1-umangpokhriyall@gmail.com> (raw)
A UFFDIO_WRITEPROTECT range that spans an unregistered VMA fails, but
the VMAs before it are already (un)protected, and on unprotect no waiter
is woken. Patch 1 validates the whole range first, as
mrwprotect_range() does; it is open-coded rather than shared with it so
that it applies to stable kernels without RWP. Patch 2 adds a uffd
selftest.
The problem was found while reviewing the userfaultfd range ioctls with
an LLM, which also helped write the patches. Tested on mm-new in a VM:
the new selftest and a standalone reproducer (both directions, and a
misaligned hugetlb range) fail without patch 1 and pass with it, and the
rest of uffd-unit-tests gives the same results with and without it.
Umang Pokhriyal (2):
userfaultfd: validate the whole range before changing write protection
selftests/mm: test a uffd write-protect range with an unregistered
page
mm/userfaultfd.c | 20 +++++--
tools/testing/selftests/mm/uffd-unit-tests.c | 56 ++++++++++++++++++++
2 files changed, 71 insertions(+), 5 deletions(-)
base-commit: d42dfde37af766d1c272467352c0a56d3169ee58
--
2.53.0
next reply other threads:[~2026-11-02 10:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 10:36 Umang Pokhriyal [this message]
2026-11-02 10:36 ` [PATCH 1/2] " Umang Pokhriyal
2026-11-02 10:36 ` [PATCH 2/2] selftests/mm: test a uffd write-protect range with an unregistered page Umang Pokhriyal
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=20261102103621.156928-1-umangpokhriyall@gmail.com \
--to=umangpokhriyall@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=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®