|
@@ -220,6 +220,17 @@ asmlinkage unsigned long sys_brk(unsigned long brk)
|
|
|
|
|
|
if (brk < mm->end_code)
|
|
if (brk < mm->end_code)
|
|
goto out;
|
|
goto out;
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ * Check against rlimit here. If this check is done later after the test
|
|
|
|
+ * of oldbrk with newbrk then it can escape the test and let the data
|
|
|
|
+ * segment grow beyond its set limit the in case where the limit is
|
|
|
|
+ * not page aligned -Ram Gupta
|
|
|
|
+ */
|
|
|
|
+ rlim = current->signal->rlim[RLIMIT_DATA].rlim_cur;
|
|
|
|
+ if (rlim < RLIM_INFINITY && brk - mm->start_data > rlim)
|
|
|
|
+ goto out;
|
|
|
|
+
|
|
newbrk = PAGE_ALIGN(brk);
|
|
newbrk = PAGE_ALIGN(brk);
|
|
oldbrk = PAGE_ALIGN(mm->brk);
|
|
oldbrk = PAGE_ALIGN(mm->brk);
|
|
if (oldbrk == newbrk)
|
|
if (oldbrk == newbrk)
|
|
@@ -232,11 +243,6 @@ asmlinkage unsigned long sys_brk(unsigned long brk)
|
|
goto out;
|
|
goto out;
|
|
}
|
|
}
|
|
|
|
|
|
- /* Check against rlimit.. */
|
|
|
|
- rlim = current->signal->rlim[RLIMIT_DATA].rlim_cur;
|
|
|
|
- if (rlim < RLIM_INFINITY && brk - mm->start_data > rlim)
|
|
|
|
- goto out;
|
|
|
|
-
|
|
|
|
/* Check against existing mmap mappings. */
|
|
/* Check against existing mmap mappings. */
|
|
if (find_vma_intersection(mm, oldbrk, newbrk+PAGE_SIZE))
|
|
if (find_vma_intersection(mm, oldbrk, newbrk+PAGE_SIZE))
|
|
goto out;
|
|
goto out;
|