[PATCH v2 0/4] userfaultfd: fixes for sashiko reports

From: Mike Rapoport (Microsoft)

Date: Thu Dec 03 2026 - 12:15:32 EST


These are fixes for userfaultfd bugs reported by sashiko, plus a THP
variant of one of them found while looking at the reports.

The first patch closes a race between closing a userfaultfd and uffd
operations of another userfaultfd of the same mm that can leave a
writable PTE with the uffd marker bit set.

The next two make UFFDIO_MOVE mark moved zero pages and THPs soft-dirty,
like it does for other PTEs and for the huge zero page.

The last one makes uffd-unit-tests free the test context when its setup
fails.

Signed-off-by: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>
---
Changes in v2:
- address sashiko findings in selftest
- Link to v1: https://patch.msgid.link/20261202-fixes-uffd-sashiko-v1-0-a6f5a874334a@xxxxxxxxxx

---
Mike Rapoport (Microsoft) (4):
userfaultfd: write-lock the VMA before clearing its uffd state
userfaultfd: mark zero pages moved by UFFDIO_MOVE soft-dirty
userfaultfd: mark THPs moved by UFFDIO_MOVE soft-dirty
selftests/mm: free the test context when uffd_test_ctx_init() fails

mm/huge_memory.c | 1 +
mm/userfaultfd.c | 5 +++++
tools/testing/selftests/mm/uffd-common.c | 27 +++++++++++++++++++++++----
3 files changed, 29 insertions(+), 4 deletions(-)
---
base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
change-id: 20261202-fixes-uffd-sashiko-fb173c1557eb

--
Sincerely yours,
Mike.