]> git.baikalelectronics.ru Git - kernel.git/commit
MIPS: relocatable: fix possible boot hangup with KASLR enabled
authorAlexander Lobakin <alobakin@pm.me>
Sun, 10 Jan 2021 14:21:05 +0000 (14:21 +0000)
committerThomas Bogendoerfer <tsbogend@alpha.franken.de>
Wed, 13 Jan 2021 09:59:04 +0000 (10:59 +0100)
commitcdbbc713b12bd3b6d3f55a8a3f0aa9258b9fd6f1
treef7c79532e16b1f1dc788db4bc6b357aec781cb2c
parent222d4f4aea11bcf8a2aca9bae3bbdfe02c82768b
MIPS: relocatable: fix possible boot hangup with KASLR enabled

LLVM-built Linux triggered a boot hangup with KASLR enabled.

arch/mips/kernel/relocate.c:get_random_boot() uses linux_banner,
which is a string constant, as a random seed, but accesses it
as an array of unsigned long (in rotate_xor()).
When the address of linux_banner is not aligned to sizeof(long),
such access emits unaligned access exception and hangs the kernel.

Use PTR_ALIGN() to align input address to sizeof(long) and also
align down the input length to prevent possible access-beyond-end.

Fixes: 1e5124315a94 ("MIPS: Kernel: Implement KASLR using CONFIG_RELOCATABLE")
Cc: stable@vger.kernel.org # 4.7+
Signed-off-by: Alexander Lobakin <alobakin@pm.me>
Tested-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
arch/mips/kernel/relocate.c