diff options
author | Michael Ellerman <mpe@ellerman.id.au> | 2017-04-25 20:49:24 +1000 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2017-04-26 15:35:01 +1000 |
commit | b409946b2a3c1ddcde75e5f35a77e03f4d354be0 (patch) | |
tree | 16420ac23dca9335e6ee935ad85b0484cdb622a3 /arch/powerpc/mm | |
parent | 9765ad134a00a01cbcc69c78ff6defbfad209bc5 (diff) | |
download | linux-b409946b2a3c1ddcde75e5f35a77e03f4d354be0.tar.bz2 |
powerpc/mm: Fix possible out-of-bounds shift in arch_mmap_rnd()
The recent patch to add runtime configuration of the ASLR limits added a bug in
arch_mmap_rnd() where we may shift an integer (32-bits) by up to 33 bits,
leading to undefined behaviour.
In practice it exhibits as every process seg faulting instantly, presumably
because the rnd value hasn't been restricited by the modulus at all. We didn't
notice because it only happens under certain kernel configurations and if the
number of bits is actually set to a large value.
Fix it by switching to unsigned long.
Fixes: 9fea59bd7ca5 ("powerpc/mm: Add support for runtime configuration of ASLR limits")
Reported-by: Balbir Singh <bsingharora@gmail.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'arch/powerpc/mm')
-rw-r--r-- | arch/powerpc/mm/mmap.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c index 005aa8a44915..9dbd2a733d6b 100644 --- a/arch/powerpc/mm/mmap.c +++ b/arch/powerpc/mm/mmap.c @@ -66,7 +66,7 @@ unsigned long arch_mmap_rnd(void) if (is_32bit_task()) shift = mmap_rnd_compat_bits; #endif - rnd = get_random_long() % (1 << shift); + rnd = get_random_long() % (1ul << shift); return rnd << PAGE_SHIFT; } |