diff options
author | Michel Lespinasse <walken@google.com> | 2012-10-08 19:31:48 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-09 03:22:42 -0400 |
commit | 523d4e2008fd4a68b1a164e63e8c75b7b20f07e0 (patch) | |
tree | c51d7fe7c6c614cf4cf8ef09f923a502cc18d279 /mm/mmap.c | |
parent | ed8ea8150182f8d715fceb3b175ef0a9ebacd872 (diff) |
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 <walken@google.com>
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: Hugh Dickins <hughd@google.com>
Tested-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/mmap.c')
-rw-r--r-- | mm/mmap.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -2419,16 +2419,16 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap, | |||
2419 | new_vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL); | 2419 | new_vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL); |
2420 | if (new_vma) { | 2420 | if (new_vma) { |
2421 | *new_vma = *vma; | 2421 | *new_vma = *vma; |
2422 | new_vma->vm_start = addr; | ||
2423 | new_vma->vm_end = addr + len; | ||
2424 | new_vma->vm_pgoff = pgoff; | ||
2422 | pol = mpol_dup(vma_policy(vma)); | 2425 | pol = mpol_dup(vma_policy(vma)); |
2423 | if (IS_ERR(pol)) | 2426 | if (IS_ERR(pol)) |
2424 | goto out_free_vma; | 2427 | goto out_free_vma; |
2428 | vma_set_policy(new_vma, pol); | ||
2425 | INIT_LIST_HEAD(&new_vma->anon_vma_chain); | 2429 | INIT_LIST_HEAD(&new_vma->anon_vma_chain); |
2426 | if (anon_vma_clone(new_vma, vma)) | 2430 | if (anon_vma_clone(new_vma, vma)) |
2427 | goto out_free_mempol; | 2431 | 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; | ||
2432 | if (new_vma->vm_file) | 2432 | if (new_vma->vm_file) |
2433 | get_file(new_vma->vm_file); | 2433 | get_file(new_vma->vm_file); |
2434 | if (new_vma->vm_ops && new_vma->vm_ops->open) | 2434 | if (new_vma->vm_ops && new_vma->vm_ops->open) |