]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.0.18/x86-fix-mmap-random-address-range.patch
5.1-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.0.18 / x86-fix-mmap-random-address-range.patch
1 From 9af0c7a6fa860698d080481f24a342ba74b68982 Mon Sep 17 00:00:00 2001
2 From: Ludwig Nussel <ludwig.nussel@suse.de>
3 Date: Tue, 15 Nov 2011 14:46:46 -0800
4 Subject: x86: Fix mmap random address range
5
6 From: Ludwig Nussel <ludwig.nussel@suse.de>
7
8 commit 9af0c7a6fa860698d080481f24a342ba74b68982 upstream.
9
10 On x86_32 casting the unsigned int result of get_random_int() to
11 long may result in a negative value. On x86_32 the range of
12 mmap_rnd() therefore was -255 to 255. The 32bit mode on x86_64
13 used 0 to 255 as intended.
14
15 The bug was introduced by 675a081 ("x86: unify mmap_{32|64}.c")
16 in January 2008.
17
18 Signed-off-by: Ludwig Nussel <ludwig.nussel@suse.de>
19 Cc: Linus Torvalds <torvalds@linux-foundation.org>
20 Cc: harvey.harrison@gmail.com
21 Cc: "H. Peter Anvin" <hpa@zytor.com>
22 Cc: Harvey Harrison <harvey.harrison@gmail.com>
23 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
24 Link: http://lkml.kernel.org/r/201111152246.pAFMklOB028527@wpaz5.hot.corp.google.com
25 Signed-off-by: Ingo Molnar <mingo@elte.hu>
26 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
27
28 ---
29 arch/x86/mm/mmap.c | 4 ++--
30 1 file changed, 2 insertions(+), 2 deletions(-)
31
32 --- a/arch/x86/mm/mmap.c
33 +++ b/arch/x86/mm/mmap.c
34 @@ -87,9 +87,9 @@ static unsigned long mmap_rnd(void)
35 */
36 if (current->flags & PF_RANDOMIZE) {
37 if (mmap_is_ia32())
38 - rnd = (long)get_random_int() % (1<<8);
39 + rnd = get_random_int() % (1<<8);
40 else
41 - rnd = (long)(get_random_int() % (1<<28));
42 + rnd = get_random_int() % (1<<28);
43 }
44 return rnd << PAGE_SHIFT;
45 }