Skip to content

Commit a5b4592

Browse files
Jiri Kosinatorvalds
authored andcommitted
brk: make sys_brk() honor COMPAT_BRK when computing lower bound
Fix a regression introduced by commit 4cc6028 Author: Jiri Kosina <[email protected]> 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 <[email protected]> Tested-by: Geert Uytterhoeven <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 33dda51 commit a5b4592

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

mm/mmap.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,16 @@ asmlinkage unsigned long sys_brk(unsigned long brk)
245245
unsigned long rlim, retval;
246246
unsigned long newbrk, oldbrk;
247247
struct mm_struct *mm = current->mm;
248+
unsigned long min_brk;
248249

249250
down_write(&mm->mmap_sem);
250251

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)
252258
goto out;
253259

254260
/*

0 commit comments

Comments
 (0)