diff options
Diffstat (limited to 'mm/mmap.c')
-rw-r--r-- | mm/mmap.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -80,7 +80,7 @@ EXPORT_SYMBOL(vm_get_page_prot); | |||
80 | int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */ | 80 | int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */ |
81 | int sysctl_overcommit_ratio = 50; /* default is 50% */ | 81 | int sysctl_overcommit_ratio = 50; /* default is 50% */ |
82 | int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT; | 82 | int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT; |
83 | atomic_t vm_committed_space = ATOMIC_INIT(0); | 83 | atomic_long_t vm_committed_space = ATOMIC_LONG_INIT(0); |
84 | 84 | ||
85 | /* | 85 | /* |
86 | * Check that a process has enough memory to allocate a new virtual | 86 | * Check that a process has enough memory to allocate a new virtual |
@@ -177,7 +177,7 @@ int __vm_enough_memory(struct mm_struct *mm, long pages, int cap_sys_admin) | |||
177 | * cast `allowed' as a signed long because vm_committed_space | 177 | * cast `allowed' as a signed long because vm_committed_space |
178 | * sometimes has a negative value | 178 | * sometimes has a negative value |
179 | */ | 179 | */ |
180 | if (atomic_read(&vm_committed_space) < (long)allowed) | 180 | if (atomic_long_read(&vm_committed_space) < (long)allowed) |
181 | return 0; | 181 | return 0; |
182 | error: | 182 | error: |
183 | vm_unacct_memory(pages); | 183 | vm_unacct_memory(pages); |
@@ -245,10 +245,16 @@ asmlinkage unsigned long sys_brk(unsigned long brk) | |||
245 | unsigned long rlim, retval; | 245 | unsigned long rlim, retval; |
246 | unsigned long newbrk, oldbrk; | 246 | unsigned long newbrk, oldbrk; |
247 | struct mm_struct *mm = current->mm; | 247 | struct mm_struct *mm = current->mm; |
248 | unsigned long min_brk; | ||
248 | 249 | ||
249 | down_write(&mm->mmap_sem); | 250 | down_write(&mm->mmap_sem); |
250 | 251 | ||
251 | if (brk < mm->start_brk) | 252 | #ifdef CONFIG_COMPAT_BRK |
253 | min_brk = mm->end_code; | ||
254 | #else | ||
255 | min_brk = mm->start_brk; | ||
256 | #endif | ||
257 | if (brk < min_brk) | ||
252 | goto out; | 258 | goto out; |
253 | 259 | ||
254 | /* | 260 | /* |