The patch titled Subject: fs/userfaultfd: fix maple state in userfaultfd_register() has been added to the -mm tree. Its filename is userfaultfd-use-maple-tree-iterator-to-iterate-vmas-fix.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/userfaultfd-use-maple-tree-iterator-to-iterate-vmas-fix.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/userfaultfd-use-maple-tree-iterator-to-iterate-vmas-fix.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Liam Howlett <liam.howlett@xxxxxxxxxx> Subject: fs/userfaultfd: fix maple state in userfaultfd_register() When VMAs are split/merged, the maple tree node may be replaced. Re-walk the tree in such cases by calling mas_pause(). Link: https://lkml.kernel.org/r/20220427154314.2o32gn46323hllnb@revolver Signed-off-by: Liam R. Howlett <Liam.Howlett@xxxxxxxxxx> Cc: Peter Xu <peterx@xxxxxxxxxx> Cc: Stephen Rothwell <sfr@xxxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- fs/userfaultfd.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/fs/userfaultfd.c~userfaultfd-use-maple-tree-iterator-to-iterate-vmas-fix +++ a/fs/userfaultfd.c @@ -1437,6 +1437,8 @@ static int userfaultfd_register(struct u ((struct vm_userfaultfd_ctx){ ctx }), anon_vma_name(vma)); if (prev) { + /* vma_merge() invalidated the mas */ + mas_pause(&mas); vma = prev; goto next; } @@ -1444,11 +1446,15 @@ static int userfaultfd_register(struct u ret = split_vma(mm, vma, start, 1); if (ret) break; + /* split_vma() invalidated the mas */ + mas_pause(&mas); } if (vma->vm_end > end) { ret = split_vma(mm, vma, end, 0); if (ret) break; + /* split_vma() invalidated the mas */ + mas_pause(&mas); } next: /* _ Patches currently in -mm which might be from liam.howlett@xxxxxxxxxx are maple-tree-add-new-data-structure-fix.patch userfaultfd-use-maple-tree-iterator-to-iterate-vmas-fix.patch