[PATCH] hugetlb: check for brk() entering a hugepage region

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>

authored by David Gibson and committed by Linus Torvalds cb07c9a1 68589bc3

+4
+4
mm/mmap.c
··· 1880 1880 if ((addr + len) > TASK_SIZE || (addr + len) < addr) 1881 1881 return -EINVAL; 1882 1882 1883 + error = is_hugepage_only_range(current->mm, addr, len); 1884 + if (error) 1885 + return error; 1886 + 1883 1887 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags; 1884 1888 1885 1889 error = arch_mmap_check(addr, len, flags);