Skip to content

Commit

Permalink
[PATCH] hugetlb: check for brk() entering a hugepage region
Browse files Browse the repository at this point in the history
Unlike mmap(), the codepath for brk() creates a vma without first checking
that it doesn't touch a region exclusively reserved for hugepages.  On
powerpc, this can allow it to create a normal page vma in a hugepage
region, causing oopses and other badness.

Add a test to prevent this.  With this patch, brk() will simply fail if it
attempts to move the break into a hugepage reserved region.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Cc: Adam Litke <agl@us.ibm.com>
Cc: Hugh Dickins <hugh@veritas.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
dgibson authored and Linus Torvalds committed Nov 14, 2006
1 parent 68589bc commit cb07c9a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions mm/mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1880,6 +1880,10 @@ unsigned long do_brk(unsigned long addr, unsigned long len)
if ((addr + len) > TASK_SIZE || (addr + len) < addr)
return -EINVAL;

error = is_hugepage_only_range(current->mm, addr, len);
if (error)
return error;

flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;

error = arch_mmap_check(addr, len, flags);
Expand Down

0 comments on commit cb07c9a

Please sign in to comment.