From dd4ac4b05883dbdf5573976ce9bbdaffaf978afd Mon Sep 17 00:00:00 2001 From: Anton Blanchard Date: Sun, 22 Feb 2009 01:50:05 +0000 Subject: [PATCH] --- yaml --- r: 138495 b: refs/heads/master c: a5adc91a4b44b5d1706b9d906cc14fe4f312afe9 h: refs/heads/master i: 138493: 02313e775214657138c768117cbd3fde1f5e430d 138491: 3e906035cc7295812516c3d5de516786cd839e68 138487: 4d127648ea01e2ef2e6070661b89fb8389d27f17 138479: 761cdf78c7cb2bca76ba70949d639f0f1954bfb7 138463: a5c8210cc921f06b2fed04db79d694cce9a138a1 138431: c3df475b850636a833f3e0a10917c251c0a64d60 138367: b6cfeed8699a546ea9f43cd2acb3899f52ee5c10 138239: d81b1198dfc83d73aa2885c4043bb341e4d4b586 v: v3 --- [refs] | 2 +- trunk/arch/powerpc/mm/mmap.c | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/[refs] b/[refs] index 57f5853bc2e3..2511f4e806e8 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 912f9ee21c836081e3c96dfe61025841ebeb95da +refs/heads/master: a5adc91a4b44b5d1706b9d906cc14fe4f312afe9 diff --git a/trunk/arch/powerpc/mm/mmap.c b/trunk/arch/powerpc/mm/mmap.c index f7376dbb653b..75dc7faaf917 100644 --- a/trunk/arch/powerpc/mm/mmap.c +++ b/trunk/arch/powerpc/mm/mmap.c @@ -46,6 +46,14 @@ static inline int mmap_is_legacy(void) return sysctl_legacy_va_layout; } +/* + * Since get_random_int() returns the same value within a 1 jiffy window, + * we will almost always get the same randomisation for the stack and mmap + * region. This will mean the relative distance between stack and mmap will + * be the same. + * + * To avoid this we can shift the randomness by 1 bit. + */ static unsigned long mmap_rnd(void) { unsigned long rnd = 0; @@ -53,11 +61,11 @@ static unsigned long mmap_rnd(void) if (current->flags & PF_RANDOMIZE) { /* 8MB for 32bit, 1GB for 64bit */ if (is_32bit_task()) - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT))); + rnd = (long)(get_random_int() % (1<<(22-PAGE_SHIFT))); else - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT))); + rnd = (long)(get_random_int() % (1<<(29-PAGE_SHIFT))); } - return rnd << PAGE_SHIFT; + return (rnd << PAGE_SHIFT) * 2; } static inline unsigned long mmap_base(void)