From: Suren Baghdasaryan Date: Sun, 30 Oct 2022 17:35:38 +0000 (+0000) Subject: mm/mmap: write-lock VMAs affected by VMA expansion X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=4f181a975e6ab8994f27c3694da3c2fb66da7329;p=users%2Fjedix%2Flinux-maple.git mm/mmap: write-lock VMAs affected by VMA expansion vma_expand changes VMA boundaries and might result in freeing an adjacent VMA. Write-lock affected VMAs to prevent concurrent page faults. Signed-off-by: Suren Baghdasaryan --- diff --git a/mm/mmap.c b/mm/mmap.c index c25a39a4a617..ae585a6287ea 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -542,6 +542,7 @@ inline int vma_expand(struct ma_state *mas, struct vm_area_struct *vma, if (mas_preallocate(mas, vma, GFP_KERNEL)) goto nomem; + vma_write_lock(vma); vma_adjust_trans_huge(vma, start, end, 0); if (file) { @@ -588,6 +589,7 @@ inline int vma_expand(struct ma_state *mas, struct vm_area_struct *vma, } if (remove_next) { + vma_write_lock(next); if (file) { uprobe_munmap(next, next->vm_start, next->vm_end); fput(file);