Skip to content

Commit 4cc6028

Browse files
Jiri KosinaIngo Molnar
authored andcommitted
brk: check the lower bound properly
There is a check in sys_brk(), that tries to make sure that we do not underflow the area that is dedicated to brk heap. The check is however wrong, as it assumes that brk area starts immediately after the end of the code (+bss), which is wrong for example in environments with randomized brk start. The proper way is to check whether the address is not below the start_brk address. Signed-off-by: Jiri Kosina <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
1 parent 2d684cd commit 4cc6028

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mm/mmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ asmlinkage unsigned long sys_brk(unsigned long brk)
245245

246246
down_write(&mm->mmap_sem);
247247

248-
if (brk < mm->end_code)
248+
if (brk < mm->start_brk)
249249
goto out;
250250

251251
/*

0 commit comments

Comments
 (0)