From fa48a327efac04ddc97e653a38f5b537d4af79a4 Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Mon, 9 Nov 2020 14:45:37 -0500 Subject: [PATCH] mm/mmap: Fix do_brk_munmap() multiple pages. This is rare, so just use the slower __do_munmap() Signed-off-by: Liam R. Howlett --- mm/mmap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 25ac50c669d4..1036a6b7146a 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2861,8 +2861,8 @@ static int do_brk_munmap(struct ma_state *mas, struct vm_area_struct *vma, arch_unmap(mm, newbrk, oldbrk); - if (vma->vm_start >= newbrk) { // remove entire mapping. - ret = __do_munmap(mm, newbrk, oldbrk - newbrk, &uf, true); + if (vma->vm_start >= newbrk) { // remove entire mapping(s) + ret = __do_munmap(mm, newbrk, oldbrk-newbrk, uf, true); goto munmap_full_vma; } @@ -2872,6 +2872,7 @@ static int do_brk_munmap(struct ma_state *mas, struct vm_area_struct *vma, ret = userfaultfd_unmap_prep(&unmap, newbrk, oldbrk, uf); if (ret) return ret; + ret = 1; // Change the oldbrk of vma to the newbrk of the munmap area vma_adjust_trans_huge(vma, vma->vm_start, newbrk, 0); -- 2.50.1