UPSTREAM: mm/mremap: write-lock VMA while remapping it to a new address range
Write-lock VMA as locked before copying it and when copy_vma produces a new VMA. Link: https://lkml.kernel.org/r/20230227173632.3292573-18-surenb@google.com Signed-off-by: Suren Baghdasaryan <surenb@google.com> Reviewed-by: Laurent Dufour <laurent.dufour@fr.ibm.com> Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> (cherry picked from commit d6ac235de4ba6dc659eebb5f4e5ba0a8523d8424) Bug: 161210518 Change-Id: I38b5c5689380754a366223caff30e1ac4aaf7cc4 Signed-off-by: Suren Baghdasaryan <surenb@google.com>
This commit is contained in:
parent
2554cb4775
commit
24ecdbc5e2
2 changed files with 2 additions and 0 deletions
|
|
@ -3295,6 +3295,7 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
|
||||||
get_file(new_vma->vm_file);
|
get_file(new_vma->vm_file);
|
||||||
if (new_vma->vm_ops && new_vma->vm_ops->open)
|
if (new_vma->vm_ops && new_vma->vm_ops->open)
|
||||||
new_vma->vm_ops->open(new_vma);
|
new_vma->vm_ops->open(new_vma);
|
||||||
|
vma_start_write(new_vma);
|
||||||
if (vma_link(mm, new_vma))
|
if (vma_link(mm, new_vma))
|
||||||
goto out_vma_link;
|
goto out_vma_link;
|
||||||
*need_rmap_locks = false;
|
*need_rmap_locks = false;
|
||||||
|
|
|
||||||
|
|
@ -622,6 +622,7 @@ static unsigned long move_vma(struct vm_area_struct *vma,
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vma_start_write(vma);
|
||||||
new_pgoff = vma->vm_pgoff + ((old_addr - vma->vm_start) >> PAGE_SHIFT);
|
new_pgoff = vma->vm_pgoff + ((old_addr - vma->vm_start) >> PAGE_SHIFT);
|
||||||
new_vma = copy_vma(&vma, new_addr, new_len, new_pgoff,
|
new_vma = copy_vma(&vma, new_addr, new_len, new_pgoff,
|
||||||
&need_rmap_locks);
|
&need_rmap_locks);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue