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=8a9cb40b57c4cc5ef169e9f0fdaad5dd2adebfd2;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 80fa9ac6d886..121e17abf762 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);