Skip to content

Commit

Permalink
fix the arch checks in MREMAP_FIXED case
Browse files Browse the repository at this point in the history
Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>
Acked-by: Hugh Dickins <hugh.dickins@tiscali.co.uk>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Dec 11, 2009
1 parent f106af4 commit 097eed1
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions mm/mremap.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ static unsigned long mremap_to(unsigned long addr,
struct vm_area_struct *vma;
unsigned long ret = -EINVAL;
unsigned long charged = 0;
unsigned long map_flags;

if (new_addr & ~PAGE_MASK)
goto out;
Expand Down Expand Up @@ -362,9 +363,23 @@ static unsigned long mremap_to(unsigned long addr,
goto out;
}

ret = move_vma(vma, addr, old_len, new_len, new_addr);
map_flags = MAP_FIXED;
if (vma->vm_flags & VM_MAYSHARE)
map_flags |= MAP_SHARED;
ret = arch_mmap_check(new_addr, new_len, map_flags);
if (ret)
goto out1;
ret = get_unmapped_area(vma->vm_file, new_addr, new_len, vma->vm_pgoff +
((addr - vma->vm_start) >> PAGE_SHIFT),
map_flags);
if (ret & ~PAGE_MASK)
vm_unacct_memory(charged);
goto out1;

ret = move_vma(vma, addr, old_len, new_len, new_addr);
if (!(ret & ~PAGE_MASK))
goto out;
out1:
vm_unacct_memory(charged);

out:
return ret;
Expand Down

0 comments on commit 097eed1

Please sign in to comment.