Skip to content

mm/thp: Fix uffd-wp with fork(); crash on pmd migration entry on fork

Peter Xu linux-mm lkml stable 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2mm/thp: simplify copying of huge zero page pmd when forkmm/huge_memory.c+3 -60 replies
2/2mm/userfaultfd: fix uffd-wp special cases for fork()include/linux/huge_mm.h include/linux/swapops.h mm/huge_memory.c +1 more+30 -260 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH stable 5.10.y 0/2] mm/thp: Fix uffd-wp with fork(); crash on pmd migration entry on fork

In summary, this series should be needed for 5.10/5.12/5.13. This is the 5.10.y backport of the series. Patch 1 is a dependency of patch 2, while patch 2 should be the real fix.

There's a minor conflict on patch 2 when cherry pick due to not having the new helper called page_needs_cow_for_dma(). It's also mentioned at the entry of patch 2.

This series should be able to fix a rare race that mentioned in thread:

https://lore.kernel.org/linux-mm/[email protected]/

This fact wasn't discovered when the fix got proposed and merged, because the fix was originally about uffd-wp and its fork event. However it turns out that the problematic commit b569a1760782f3d is also causing crashing on fork() of pmd migration entries which is even more severe than the original uffd-wp problem.

Stable kernels at least on 5.12.y has the crash reproduced, and it's possible 5.13.y and 5.10.y could hit it due to having the problematic commit b569a1760782f3d but lacking of the uffd-wp fix patch (8f34f1eac382, which is also patch 2 of this series).

The pmd entry crash problem was reported by Igor Raits <[email protected]> and debugged by Hugh Dickins <[email protected]>.

Please review, thanks.

Peter Xu (2):
mm/thp: simplify copying of huge zero page pmd when fork mm/userfaultfd: fix uffd-wp special cases for fork()

 include/linux/huge_mm.h |  2 +-
 include/linux/swapops.h |  2 ++
 mm/huge_memory.c        | 36 +++++++++++++++++-------------------
 mm/memory.c             | 25 +++++++++++++------------
 4 files changed, 33 insertions(+), 32 deletions(-)
Signature · 1 line
2.31.1