projects/linux·commit 59f2f4b8

fs/userfaultfd: Fix maple tree iterator in userfaultfd_unregister()

59f2f4b8 · Liam Howlett <[email protected]> · 2022-11-07 20:11:42 +00:00

When iterating the VMAs, the maple state needs to be invalidated if the
tree is modified by a split or merge to ensure the maple tree node
contained in the maple state is still valid.  These invalidations were
missed, so add them to the paths which alter the tree.

Reported-by: [email protected]
Fixes: 69dbe6daf104 (userfaultfd: use maple tree iterator to iterate VMAs)
Signed-off-by: Liam R. Howlett <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Commit
59f2f4b8a757412fce372f6d0767bdb55da127a8
Parents
a1de832b

Changes

1 files changed · +3 −0

FileStatusAddDelContent
fs/userfaultfd.cmodified+3−0View file

fs/userfaultfd.c

View file
diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
index 07c81ab..98ac37e 100644
--- a/fs/userfaultfd.c
+++ b/fs/userfaultfd.c
@@ -1630,17 +1630,20 @@ static int userfaultfd_unregister(struct userfaultfd_ctx *ctx,
NULL_VM_UFFD_CTX, anon_vma_name(vma));
if (prev) {
vma = prev;
+ mas_pause(&mas);
goto next;
}
if (vma->vm_start < start) {
ret = split_vma(mm, vma, start, 1);
if (ret)
break;
+ mas_pause(&mas);
}
if (vma->vm_end > end) {
ret = split_vma(mm, vma, end, 0);
if (ret)
break;
+ mas_pause(&mas);
}
next:
/*