Skip to content

Commit 59f2f4b

Browse files
howletttorvalds
authored andcommitted
fs/userfaultfd: Fix maple tree iterator in userfaultfd_unregister()
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: syzbot+0d2014e4da2ccced5b41@syzkaller.appspotmail.com Fixes: 69dbe6d (userfaultfd: use maple tree iterator to iterate VMAs) Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent a1de832 commit 59f2f4b

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

fs/userfaultfd.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,17 +1630,20 @@ static int userfaultfd_unregister(struct userfaultfd_ctx *ctx,
16301630
NULL_VM_UFFD_CTX, anon_vma_name(vma));
16311631
if (prev) {
16321632
vma = prev;
1633+
mas_pause(&mas);
16331634
goto next;
16341635
}
16351636
if (vma->vm_start < start) {
16361637
ret = split_vma(mm, vma, start, 1);
16371638
if (ret)
16381639
break;
1640+
mas_pause(&mas);
16391641
}
16401642
if (vma->vm_end > end) {
16411643
ret = split_vma(mm, vma, end, 0);
16421644
if (ret)
16431645
break;
1646+
mas_pause(&mas);
16441647
}
16451648
next:
16461649
/*

0 commit comments

Comments
 (0)