diff options
author | Ludwig Nussel <ludwig.nussel@suse.de> | 2011-11-15 17:46:46 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2011-12-05 11:07:23 -0500 |
commit | 9af0c7a6fa860698d080481f24a342ba74b68982 (patch) | |
tree | 51d5b388fc86379193bcdbba16fa6cd44dcb16ec /arch/x86/mm/mmap.c | |
parent | 176239153049a023d060ce95b05f7ef31667e362 (diff) |
x86: Fix mmap random address range
On x86_32 casting the unsigned int result of get_random_int() to
long may result in a negative value. On x86_32 the range of
mmap_rnd() therefore was -255 to 255. The 32bit mode on x86_64
used 0 to 255 as intended.
The bug was introduced by 675a081 ("x86: unify mmap_{32|64}.c")
in January 2008.
Signed-off-by: Ludwig Nussel <ludwig.nussel@suse.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: harvey.harrison@gmail.com
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Link: http://lkml.kernel.org/r/201111152246.pAFMklOB028527@wpaz5.hot.corp.google.com
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/mm/mmap.c')
-rw-r--r-- | arch/x86/mm/mmap.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c index 4b5ba85eb5c9..845df6835f9f 100644 --- a/arch/x86/mm/mmap.c +++ b/arch/x86/mm/mmap.c | |||
@@ -75,9 +75,9 @@ static unsigned long mmap_rnd(void) | |||
75 | */ | 75 | */ |
76 | if (current->flags & PF_RANDOMIZE) { | 76 | if (current->flags & PF_RANDOMIZE) { |
77 | if (mmap_is_ia32()) | 77 | if (mmap_is_ia32()) |
78 | rnd = (long)get_random_int() % (1<<8); | 78 | rnd = get_random_int() % (1<<8); |
79 | else | 79 | else |
80 | rnd = (long)(get_random_int() % (1<<28)); | 80 | rnd = get_random_int() % (1<<28); |
81 | } | 81 | } |
82 | return rnd << PAGE_SHIFT; | 82 | return rnd << PAGE_SHIFT; |
83 | } | 83 | } |