aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mm/mmap.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/mm/mmap.c b/mm/mmap.c
index 88da687bde89..a6b7c796352b 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1200,6 +1200,9 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
1200 if (len > TASK_SIZE) 1200 if (len > TASK_SIZE)
1201 return -ENOMEM; 1201 return -ENOMEM;
1202 1202
1203 if (flags & MAP_FIXED)
1204 return addr;
1205
1203 if (addr) { 1206 if (addr) {
1204 addr = PAGE_ALIGN(addr); 1207 addr = PAGE_ALIGN(addr);
1205 vma = find_vma(mm, addr); 1208 vma = find_vma(mm, addr);
@@ -1273,6 +1276,9 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
1273 if (len > TASK_SIZE) 1276 if (len > TASK_SIZE)
1274 return -ENOMEM; 1277 return -ENOMEM;
1275 1278
1279 if (flags & MAP_FIXED)
1280 return addr;
1281
1276 /* requesting a specific address */ 1282 /* requesting a specific address */
1277 if (addr) { 1283 if (addr) {
1278 addr = PAGE_ALIGN(addr); 1284 addr = PAGE_ALIGN(addr);
@@ -1361,22 +1367,21 @@ get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
1361 unsigned long pgoff, unsigned long flags) 1367 unsigned long pgoff, unsigned long flags)
1362{ 1368{
1363 unsigned long ret; 1369 unsigned long ret;
1364 1370 unsigned long (*get_area)(struct file *, unsigned long,
1365 if (!(flags & MAP_FIXED)) { 1371 unsigned long, unsigned long, unsigned long);
1366 unsigned long (*get_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long); 1372
1367 1373 get_area = current->mm->get_unmapped_area;
1368 get_area = current->mm->get_unmapped_area; 1374 if (file && file->f_op && file->f_op->get_unmapped_area)
1369 if (file && file->f_op && file->f_op->get_unmapped_area) 1375 get_area = file->f_op->get_unmapped_area;
1370 get_area = file->f_op->get_unmapped_area; 1376 addr = get_area(file, addr, len, pgoff, flags);
1371 addr = get_area(file, addr, len, pgoff, flags); 1377 if (IS_ERR_VALUE(addr))
1372 if (IS_ERR_VALUE(addr)) 1378 return addr;
1373 return addr;
1374 }
1375 1379
1376 if (addr > TASK_SIZE - len) 1380 if (addr > TASK_SIZE - len)
1377 return -ENOMEM; 1381 return -ENOMEM;
1378 if (addr & ~PAGE_MASK) 1382 if (addr & ~PAGE_MASK)
1379 return -EINVAL; 1383 return -EINVAL;
1384
1380 if (file && is_file_hugepages(file)) { 1385 if (file && is_file_hugepages(file)) {
1381 /* 1386 /*
1382 * Check if the given range is hugepage aligned, and 1387 * Check if the given range is hugepage aligned, and