Skip to content

Commit 523d4e2

Browse files
walken-googletorvalds
authored andcommitted
mm anon rmap: in mremap, set the new vma's position before anon_vma_clone()
anon_vma_clone() expects new_vma->vm_{start,end,pgoff} to be correctly set so that the new vma can be indexed on the anon interval tree. copy_vma() was failing to do that, which broke mremap(). Signed-off-by: Michel Lespinasse <[email protected]> Cc: Jiri Slaby <[email protected]> Cc: Hugh Dickins <[email protected]> Tested-by: Sasha Levin <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent ed8ea81 commit 523d4e2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

mm/mmap.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2419,16 +2419,16 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
24192419
new_vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
24202420
if (new_vma) {
24212421
*new_vma = *vma;
2422+
new_vma->vm_start = addr;
2423+
new_vma->vm_end = addr + len;
2424+
new_vma->vm_pgoff = pgoff;
24222425
pol = mpol_dup(vma_policy(vma));
24232426
if (IS_ERR(pol))
24242427
goto out_free_vma;
2428+
vma_set_policy(new_vma, pol);
24252429
INIT_LIST_HEAD(&new_vma->anon_vma_chain);
24262430
if (anon_vma_clone(new_vma, vma))
24272431
goto out_free_mempol;
2428-
vma_set_policy(new_vma, pol);
2429-
new_vma->vm_start = addr;
2430-
new_vma->vm_end = addr + len;
2431-
new_vma->vm_pgoff = pgoff;
24322432
if (new_vma->vm_file)
24332433
get_file(new_vma->vm_file);
24342434
if (new_vma->vm_ops && new_vma->vm_ops->open)

0 commit comments

Comments
 (0)