|
@@ -92,13 +92,18 @@ unsigned long arch_mmap_rnd(void)
|
|
static unsigned long mmap_base(unsigned long rnd, unsigned long task_size)
|
|
static unsigned long mmap_base(unsigned long rnd, unsigned long task_size)
|
|
{
|
|
{
|
|
unsigned long gap = rlimit(RLIMIT_STACK);
|
|
unsigned long gap = rlimit(RLIMIT_STACK);
|
|
|
|
+ unsigned long pad = stack_maxrandom_size(task_size) + stack_guard_gap;
|
|
unsigned long gap_min, gap_max;
|
|
unsigned long gap_min, gap_max;
|
|
|
|
|
|
|
|
+ /* Values close to RLIM_INFINITY can overflow. */
|
|
|
|
+ if (gap + pad > gap)
|
|
|
|
+ gap += pad;
|
|
|
|
+
|
|
/*
|
|
/*
|
|
* Top of mmap area (just below the process stack).
|
|
* Top of mmap area (just below the process stack).
|
|
* Leave an at least ~128 MB hole with possible stack randomization.
|
|
* Leave an at least ~128 MB hole with possible stack randomization.
|
|
*/
|
|
*/
|
|
- gap_min = SIZE_128M + stack_maxrandom_size(task_size);
|
|
|
|
|
|
+ gap_min = SIZE_128M;
|
|
gap_max = (task_size / 6) * 5;
|
|
gap_max = (task_size / 6) * 5;
|
|
|
|
|
|
if (gap < gap_min)
|
|
if (gap < gap_min)
|