aboutsummaryrefslogtreecommitdiffstats
path: root/mm/mmap.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-11-13 01:45:43 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-11-13 01:45:43 -0500
commit5cbb3d216e2041700231bcfc383ee5f8b7fc8b74 (patch)
treea738fa82dbcefa9bd283c08bc67f38827be63937 /mm/mmap.c
parent9bc9ccd7db1c9f043f75380b5a5b94912046a60e (diff)
parent4e9b45a19241354daec281d7a785739829b52359 (diff)
Merge branch 'akpm' (patches from Andrew Morton)
Merge first patch-bomb from Andrew Morton: "Quite a lot of other stuff is banked up awaiting further next->mainline merging, but this batch contains: - Lots of random misc patches - OCFS2 - Most of MM - backlight updates - lib/ updates - printk updates - checkpatch updates - epoll tweaking - rtc updates - hfs - hfsplus - documentation - procfs - update gcov to gcc-4.7 format - IPC" * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (269 commits) ipc, msg: fix message length check for negative values ipc/util.c: remove unnecessary work pending test devpts: plug the memory leak in kill_sb ./Makefile: export initial ramdisk compression config option init/Kconfig: add option to disable kernel compression drivers: w1: make w1_slave::flags long to avoid memory corruption drivers/w1/masters/ds1wm.cuse dev_get_platdata() drivers/memstick/core/ms_block.c: fix unreachable state in h_msb_read_page() drivers/memstick/core/mspro_block.c: fix attributes array allocation drivers/pps/clients/pps-gpio.c: remove redundant of_match_ptr kernel/panic.c: reduce 1 byte usage for print tainted buffer gcov: reuse kbasename helper kernel/gcov/fs.c: use pr_warn() kernel/module.c: use pr_foo() gcov: compile specific gcov implementation based on gcc version gcov: add support for gcc 4.7 gcov format gcov: move gcov structs definitions to a gcc version specific file kernel/taskstats.c: return -ENOMEM when alloc memory fails in add_del_listener() kernel/taskstats.c: add nla_nest_cancel() for failure processing between nla_nest_start() and nla_nest_end() kernel/sysctl_binary.c: use scnprintf() instead of snprintf() ...
Diffstat (limited to 'mm/mmap.c')
-rw-r--r--mm/mmap.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/mm/mmap.c b/mm/mmap.c
index ab199dfc9e26..5a6baddde15d 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -179,14 +179,12 @@ int __vm_enough_memory(struct mm_struct *mm, long pages, int cap_sys_admin)
179 goto error; 179 goto error;
180 } 180 }
181 181
182 allowed = (totalram_pages - hugetlb_total_pages()) 182 allowed = vm_commit_limit();
183 * sysctl_overcommit_ratio / 100;
184 /* 183 /*
185 * Reserve some for root 184 * Reserve some for root
186 */ 185 */
187 if (!cap_sys_admin) 186 if (!cap_sys_admin)
188 allowed -= sysctl_admin_reserve_kbytes >> (PAGE_SHIFT - 10); 187 allowed -= sysctl_admin_reserve_kbytes >> (PAGE_SHIFT - 10);
189 allowed += total_swap_pages;
190 188
191 /* 189 /*
192 * Don't let a single process grow so big a user can't recover 190 * Don't let a single process grow so big a user can't recover
@@ -1856,7 +1854,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
1856 struct vm_area_struct *vma; 1854 struct vm_area_struct *vma;
1857 struct vm_unmapped_area_info info; 1855 struct vm_unmapped_area_info info;
1858 1856
1859 if (len > TASK_SIZE) 1857 if (len > TASK_SIZE - mmap_min_addr)
1860 return -ENOMEM; 1858 return -ENOMEM;
1861 1859
1862 if (flags & MAP_FIXED) 1860 if (flags & MAP_FIXED)
@@ -1865,14 +1863,14 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
1865 if (addr) { 1863 if (addr) {
1866 addr = PAGE_ALIGN(addr); 1864 addr = PAGE_ALIGN(addr);
1867 vma = find_vma(mm, addr); 1865 vma = find_vma(mm, addr);
1868 if (TASK_SIZE - len >= addr && 1866 if (TASK_SIZE - len >= addr && addr >= mmap_min_addr &&
1869 (!vma || addr + len <= vma->vm_start)) 1867 (!vma || addr + len <= vma->vm_start))
1870 return addr; 1868 return addr;
1871 } 1869 }
1872 1870
1873 info.flags = 0; 1871 info.flags = 0;
1874 info.length = len; 1872 info.length = len;
1875 info.low_limit = TASK_UNMAPPED_BASE; 1873 info.low_limit = mm->mmap_base;
1876 info.high_limit = TASK_SIZE; 1874 info.high_limit = TASK_SIZE;
1877 info.align_mask = 0; 1875 info.align_mask = 0;
1878 return vm_unmapped_area(&info); 1876 return vm_unmapped_area(&info);
@@ -1895,7 +1893,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
1895 struct vm_unmapped_area_info info; 1893 struct vm_unmapped_area_info info;
1896 1894
1897 /* requested length too big for entire address space */ 1895 /* requested length too big for entire address space */
1898 if (len > TASK_SIZE) 1896 if (len > TASK_SIZE - mmap_min_addr)
1899 return -ENOMEM; 1897 return -ENOMEM;
1900 1898
1901 if (flags & MAP_FIXED) 1899 if (flags & MAP_FIXED)
@@ -1905,14 +1903,14 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
1905 if (addr) { 1903 if (addr) {
1906 addr = PAGE_ALIGN(addr); 1904 addr = PAGE_ALIGN(addr);
1907 vma = find_vma(mm, addr); 1905 vma = find_vma(mm, addr);
1908 if (TASK_SIZE - len >= addr && 1906 if (TASK_SIZE - len >= addr && addr >= mmap_min_addr &&
1909 (!vma || addr + len <= vma->vm_start)) 1907 (!vma || addr + len <= vma->vm_start))
1910 return addr; 1908 return addr;
1911 } 1909 }
1912 1910
1913 info.flags = VM_UNMAPPED_AREA_TOPDOWN; 1911 info.flags = VM_UNMAPPED_AREA_TOPDOWN;
1914 info.length = len; 1912 info.length = len;
1915 info.low_limit = PAGE_SIZE; 1913 info.low_limit = max(PAGE_SIZE, mmap_min_addr);
1916 info.high_limit = mm->mmap_base; 1914 info.high_limit = mm->mmap_base;
1917 info.align_mask = 0; 1915 info.align_mask = 0;
1918 addr = vm_unmapped_area(&info); 1916 addr = vm_unmapped_area(&info);