Re: x86: randomize brk() and RLIMIT_DATA

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Jiri Kosina
Date: Thursday, October 25, 2007 - 7:46 am

On Thu, 25 Oct 2007, Arjan van de Ven wrote:


I tend to agree here with Arjan. However it probably would make no harm to 
make at least a little bit consisten behavior of setrlimit(), though it 
has a little use in such cases.

Sami, does the patch below work for you?

diff --git a/mm/mmap.c b/mm/mmap.c
index facc1a7..c7ade18 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -251,7 +251,8 @@ asmlinkage unsigned long sys_brk(unsigned long brk)
 	 * not page aligned -Ram Gupta
 	 */
 	rlim = current->signal->rlim[RLIMIT_DATA].rlim_cur;
-	if (rlim < RLIM_INFINITY && brk - mm->start_data > rlim)
+	if (rlim < RLIM_INFINITY && brk - mm->start_data -
+			(mm->start_brk - mm->end_data) > rlim)
 		goto out;
 
 	newbrk = PAGE_ALIGN(brk);
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
x86: randomize brk() and RLIMIT_DATA, Sami Farin, (Thu Oct 25, 6:41 am)
Re: x86: randomize brk() and RLIMIT_DATA, Arjan van de Ven, (Thu Oct 25, 7:13 am)
Re: x86: randomize brk() and RLIMIT_DATA, Jiri Kosina, (Thu Oct 25, 7:46 am)
Re: x86: randomize brk() and RLIMIT_DATA, Sami Farin, (Thu Oct 25, 10:19 am)