Skip to content

Commit

Permalink
fix checks for expand-in-place mremap
Browse files Browse the repository at this point in the history
Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Dec 11, 2009
1 parent 1a0ef85 commit f106af4
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions mm/mremap.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@

#include "internal.h"

#ifndef arch_mmap_check
#define arch_mmap_check(addr, len, flags) (0)
#endif

static pmd_t *get_old_pmd(struct mm_struct *mm, unsigned long addr)
{
pgd_t *pgd;
Expand Down Expand Up @@ -368,12 +372,17 @@ static unsigned long mremap_to(unsigned long addr,

static int vma_expandable(struct vm_area_struct *vma, unsigned long delta)
{
unsigned long end = vma->vm_end + delta;
unsigned long max_addr = TASK_SIZE;
if (vma->vm_next)
max_addr = vma->vm_next->vm_start;
if (max_addr - vma->vm_end < delta)
if (max_addr < end || end < vma->vm_end)
return 0;
if (arch_mmap_check(vma->vm_start, end - vma->vm_start, MAP_FIXED))
return 0;
if (get_unmapped_area(NULL, vma->vm_start, end - vma->vm_start,
0, MAP_FIXED) & ~PAGE_MASK)
return 0;
/* we need to do arch-specific checks here */
return 1;
}

Expand Down

0 comments on commit f106af4

Please sign in to comment.