]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
hugetlb: check for brk() entering a hugepage region
authorDavid Gibson <david@gibson.dropbear.id.au>
Sun, 28 Oct 2007 21:20:34 +0000 (22:20 +0100)
committerAdrian Bunk <bunk@kernel.org>
Sun, 28 Oct 2007 21:20:34 +0000 (22:20 +0100)
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>
Signed-off-by: Adrian Bunk <bunk@kernel.org>
mm/mmap.c

index f2ac461a357e7ddccba91ffddf820740db35b2b3..a04576de325467bb44a4956b225bbff2210cf966 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1870,6 +1870,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);