From: Liam R. Howlett Date: Mon, 24 Apr 2023 20:36:31 +0000 (-0400) Subject: mm: Remove VMA Iterator reset from vma_expand() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=933e673c4e566807fdfcbdc0cdbf92a88b1e9028;p=users%2Fjedix%2Flinux-maple.git mm: Remove VMA Iterator reset from vma_expand() Update callers to vma_expand() to set the vma iterator to the correct position. Detect the incorrect location with a MAS_WARN_ON() to debug what is going on. Update the caller in shift_arg_pages() to set the vma iterator correctly. Signed-off-by: Liam R. Howlett --- diff --git a/fs/exec.c b/fs/exec.c index 87cf3a2f0e9a1..8a9a529ba1805 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -696,6 +696,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift) if (vma != vma_next(&vmi)) return -EFAULT; + vma_iter_prev_range(&vmi); + /* * cover the whole range: [new_start, old_end) */ diff --git a/mm/mmap.c b/mm/mmap.c index 4c7c0e2c8fab7..3e265c7deaeb0 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -680,8 +680,7 @@ int vma_expand(struct vma_iterator *vmi, struct vm_area_struct *vma, vma_prepare(&vp); vma_adjust_trans_huge(vma, start, end, 0); - /* VMA iterator points to previous, so set to start if necessary */ - if (vma_iter_addr(vmi) != start) + if (MAS_WARN_ON(&vmi->mas, vma_iter_addr(vmi) != start)) vma_iter_set(vmi, start); vma->vm_start = start;