aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mm/mmap.c18
-rw-r--r--mm/util.c15
2 files changed, 15 insertions, 18 deletions
diff --git a/mm/mmap.c b/mm/mmap.c
index 292ddc3cef9c..5076775a395c 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -948,24 +948,6 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
948 if (mm->map_count > sysctl_max_map_count) 948 if (mm->map_count > sysctl_max_map_count)
949 return -ENOMEM; 949 return -ENOMEM;
950 950
951 if (flags & MAP_HUGETLB) {
952 struct user_struct *user = NULL;
953 if (file)
954 return -EINVAL;
955
956 /*
957 * VM_NORESERVE is used because the reservations will be
958 * taken when vm_ops->mmap() is called
959 * A dummy user value is used because we are not locking
960 * memory so no accounting is necessary
961 */
962 len = ALIGN(len, huge_page_size(&default_hstate));
963 file = hugetlb_file_setup(HUGETLB_ANON_FILE, len, VM_NORESERVE,
964 &user, HUGETLB_ANONHUGE_INODE);
965 if (IS_ERR(file))
966 return PTR_ERR(file);
967 }
968
969 /* Obtain the address to map to. we verify (or select) it and ensure 951 /* Obtain the address to map to. we verify (or select) it and ensure
970 * that it represents a valid section of the address space. 952 * that it represents a valid section of the address space.
971 */ 953 */
diff --git a/mm/util.c b/mm/util.c
index 3bf81b294ae8..b377ce430803 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -280,9 +280,24 @@ SYSCALL_DEFINE6(mmap_pgoff, unsigned long, addr, unsigned long, len,
280 unsigned long retval = -EBADF; 280 unsigned long retval = -EBADF;
281 281
282 if (!(flags & MAP_ANONYMOUS)) { 282 if (!(flags & MAP_ANONYMOUS)) {
283 if (unlikely(flags & MAP_HUGETLB))
284 return -EINVAL;
283 file = fget(fd); 285 file = fget(fd);
284 if (!file) 286 if (!file)
285 goto out; 287 goto out;
288 } else if (flags & MAP_HUGETLB) {
289 struct user_struct *user = NULL;
290 /*
291 * VM_NORESERVE is used because the reservations will be
292 * taken when vm_ops->mmap() is called
293 * A dummy user value is used because we are not locking
294 * memory so no accounting is necessary
295 */
296 len = ALIGN(len, huge_page_size(&default_hstate));
297 file = hugetlb_file_setup(HUGETLB_ANON_FILE, len, VM_NORESERVE,
298 &user, HUGETLB_ANONHUGE_INODE);
299 if (IS_ERR(file))
300 return PTR_ERR(file);
286 } 301 }
287 302
288 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE); 303 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);