[PATCH 1/2] brk: check the lower bound properly

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Jiri Kosina
Date: Wednesday, February 6, 2008 - 6:45 am

From: Jiri Kosina <jkosina@suse.cz>

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.

Cc: Ingo Molnar <mingo@elte.hu>
Cc: Arjan van de Ven <arjan@infradead.org>
Acked-by: Hugh Dickins <hugh@veritas.com>
Acked-by: Pavel Machek <pavel@suse.cz>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>

diff --git a/mm/mmap.c b/mm/mmap.c
index 8295577..1c3b48f 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -241,7 +241,7 @@ asmlinkage unsigned long sys_brk(unsigned long brk)
 
 	down_write(&mm->mmap_sem);
 
-	if (brk < mm->end_code)
+	if (brk < mm->start_brk)
 		goto out;
 
 	/*
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/2] brk and randomization fixes, Jiri Kosina, (Wed Feb 6, 6:45 am)
[PATCH 1/2] brk: check the lower bound properly, Jiri Kosina, (Wed Feb 6, 6:45 am)
Re: [PATCH 2/2] ASLR: add possibility for more fine-graine ..., Geert Uytterhoeven, (Thu Feb 7, 3:23 am)
Re: [PATCH 2/2] ASLR: add possibility for more fine-graine ..., Geert Uytterhoeven, (Thu Feb 7, 3:43 am)