Skip to content

userfaultfd/pagemap: pre-existing fixes

Kiryl Shutsemau (Meta) linux-fsdevel linux-mm lkml stable 1 version Applied

Status from this message: [merged mm-stable] userfaultfd-build-__vma_uffd_flags-from-config-gated-masks.patch removed from -mm tree

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest6 patches 19 repliesApplied 6/6

Patches in v1 All 6 applied

#Subject and filesSizeRepliesApplied
1/6fs/proc/task_mmu: fix make_uffd_wp_huge_pte() prot-update racefs/proc/task_mmu.c+8 -45 repliesApplied
2/6fs/proc/task_mmu: use huge_page_size() in pagemap_scan_hugetlb_entry()fs/proc/task_mmu.c+1 -12 repliesApplied
3/6fs/proc/task_mmu: fix hugetlb self-deadlock in pagemap_scan_pte_hole()fs/proc/task_mmu.c+58 -10 repliesApplied
4/6mm/huge_memory: preserve pmd_swp_uffd_wp on device-private PMD downgrademm/huge_memory.c+2 -01 replyApplied
5/6userfaultfd: gate must_wait writability check on pte_present()mm/userfaultfd.c+20 -02 repliesApplied
6/6userfaultfd: build __VMA_UFFD_FLAGS from config-gated masksinclude/linux/mm.h include/linux/userfaultfd_k.h+41 -23 repliesApplied

Reviews trailers per patch

5 of 6 patches have a Reviewed-by or Acked-by.

PatchBalbir SinghLorenzo StoakesDev JainMike Rapoport (Microsoft)
1/6R-b R-b
2/6R-b R-b
3/6
4/6R-b
5/6R-b R-b
6/6R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v1 thread

Cover letter [PATCH 0/6] userfaultfd/pagemap: pre-existing fixes

These are pre-existing bug fixes that were carried at the front of the userfaultfd RWP working-set-tracking series up to v5 [1]. Per review feedback that fixes should not sit in the middle of a feature series, they are split out and sent on their own; the RWP series is reposted rebased on top of this.

All six were flagged by the Sashiko AI review of the RWP series and carry Reported-by: Sashiko AI review <[email protected]>. They are independent of RWP, apply to mm-new directly, and carry Cc: stable@.

1: fs/proc/task_mmu: a missing huge_ptep_modify_prot_start() in
make_uffd_wp_huge_pte() can lose hardware Dirty/Accessed updates when PAGEMAP_SCAN write-protects a hugetlb PTE.

2: fs/proc/task_mmu: pagemap_scan_hugetlb_entry() compares the range
against HPAGE_SIZE rather than the hstate page size, so it never write-protects gigantic hugetlb pages.

3: fs/proc/task_mmu: PAGEMAP_SCAN with PM_SCAN_WP_MATCHING over an
unpopulated hugetlb range self-deadlocks -- pagemap_scan_pte_hole() calls uffd_wp_range() while walk_hugetlb_range() holds the hugetlb vma lock for read, and hugetlb_change_protection() then takes it for write. Install the marker inline instead.

4: mm/huge_memory: change_non_present_huge_pmd() drops pmd_swp_uffd_wp
on a device-private PMD permission downgrade, silently losing the uffd-wp marker.

5: userfaultfd: must_wait() applies pte_write() to a locklessly read
PTE without checking pte_present(), so swap/migration entries decode random offset bits and a thread can stay parked on a stale fault.

6: userfaultfd: __VMA_UFFD_FLAGS feeds VMA_UFFD_MINOR_BIT (41) to
mk_vma_flags() unconditionally, an out-of-bounds write into the single-word vma_flags_t on 32-bit. Build the mask from config-gated per-mode masks so an unavailable bit is never materialised.

[1] https://lore.kernel.org/all/[email protected]/

Kiryl Shutsemau (Meta) (6):
fs/proc/task_mmu: fix make_uffd_wp_huge_pte() prot-update race fs/proc/task_mmu: use huge_page_size() in pagemap_scan_hugetlb_entry() fs/proc/task_mmu: fix hugetlb self-deadlock in pagemap_scan_pte_hole() mm/huge_memory: preserve pmd_swp_uffd_wp on device-private PMD
downgrade
userfaultfd: gate must_wait writability check on pte_present()
userfaultfd: build __VMA_UFFD_FLAGS from config-gated masks

 fs/proc/task_mmu.c            | 73 ++++++++++++++++++++++++++++++++---
 include/linux/mm.h            | 39 +++++++++++++++++++
 include/linux/userfaultfd_k.h |  4 +-
 mm/huge_memory.c              |  2 +
 mm/userfaultfd.c              | 20 ++++++++++
 5 files changed, 130 insertions(+), 8 deletions(-)

base-commit: 449a5df98f8dffa9b037e3b6838fc5af327df072

Signature · 1 line
2.54.0