Commit a5b4592cf77b973c29e7c9695873a26052b58951
Committed by
Linus Torvalds
1 parent
33dda515a1
Exists in
master
and in
4 other branches
brk: make sys_brk() honor COMPAT_BRK when computing lower bound
Fix a regression introduced by commit 4cc6028d4040f95cdb590a87db478b42b8be0508 Author: Jiri Kosina <jkosina@suse.cz> Date: Wed Feb 6 22:39:44 2008 +0100 brk: check the lower bound properly The check in sys_brk() on minimum value the brk might have must take CONFIG_COMPAT_BRK setting into account. When this option is turned on (i.e. we support ancient legacy binaries, e.g. libc5-linked stuff), the lower bound on brk value is mm->end_code, otherwise the brk start is allowed to be arbitrarily shifted. Signed-off-by: Jiri Kosina <jkosina@suse.cz> Tested-by: Geert Uytterhoeven <geert@linux-m68k.org> Cc: <stable@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 7 additions and 1 deletions Side-by-side Diff
mm/mmap.c
... | ... | @@ -245,10 +245,16 @@ |
245 | 245 | unsigned long rlim, retval; |
246 | 246 | unsigned long newbrk, oldbrk; |
247 | 247 | struct mm_struct *mm = current->mm; |
248 | + unsigned long min_brk; | |
248 | 249 | |
249 | 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 | 258 | goto out; |
253 | 259 | |
254 | 260 | /* |