This patch is [RFC] as I am not sure whether it is worth it (see Arjan's
comment above).
From: Jiri Kosina <jkosina@suse.cz>
brk randomization: compute RLIMIT_DATA properly
In cases of heap area placed at randomly-generated offset from
mm->end_data (arch_randomize_brk()), we need to subtract the value of the
offset for setrlimit(RLIMIT_DATA) to work properly -- otherwise we count
the unoccupied memory between mm->end_data and mm->start_brk as occupied.
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
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);
-