From 8a9cb40b57c4cc5ef169e9f0fdaad5dd2adebfd2 Mon Sep 17 00:00:00 2001 From: Suren Baghdasaryan Date: Sun, 30 Oct 2022 17:35:38 +0000 Subject: [PATCH] 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 --- mm/mmap.c | 2 ++ 1 file changed, 2 insertions(+) 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); -- 2.50.1