diff options
Diffstat (limited to 'mm/mmap.c')
-rw-r--r-- | mm/mmap.c | 16 |
1 files changed, 7 insertions, 9 deletions
@@ -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); |