mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] userfaultfd: validate the whole range before changing write protection
@ 2026-11-02 10:36 Umang Pokhriyal
  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
  0 siblings, 2 replies; 3+ messages in thread
From: Umang Pokhriyal @ 2026-11-02 10:36 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Mike Rapoport, Peter Xu, David Hildenbrand, Lorenzo Stoakes,
	Liam R . Howlett, Vlastimil Babka, Suren Baghdasaryan,
	Michal Hocko, Shuah Khan, linux-mm, linux-kselftest,
	linux-kernel, Umang Pokhriyal

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-02 10:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-02 10:36 [PATCH 0/2] userfaultfd: validate the whole range before changing write protection Umang Pokhriyal
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

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®