Alexander Lobakin 69e976831c 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: 405bc8fd12f5 ("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>
2021-01-13 10:59:04 +01:00
..
2018-10-31 08:54:16 -07:00
2020-05-22 09:09:01 +02:00
2020-05-22 09:09:01 +02:00
2020-11-24 16:47:49 +01:00
2020-07-27 14:31:08 -04:00
2020-05-22 09:09:01 +02:00
2020-11-24 16:47:49 +01:00
2020-05-15 14:53:19 +02:00
2020-05-22 09:13:32 +02:00
2020-07-26 10:18:35 +02:00
2020-10-16 12:40:55 -07:00
2014-05-24 00:07:01 +02:00
2020-05-07 11:55:47 +02:00