From: Matt Redfearn Date: Thu, 31 Mar 2016 09:05:42 +0000 (+0100) Subject: MIPS: KASLR: Print relocation Information on boot X-Git-Tag: v4.9.8~1964^2~182 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=919beb4eedc587b70f8c1390fedac10cda783c36;p=platform%2Fkernel%2Flinux-rpi3.git MIPS: KASLR: Print relocation Information on boot When debugging a relocated kernel, the addresses of the relocated symbols and the offset applied is essential information. If the kernel is compiled with debugging information, then print this information during bootup using the same function as the panic notifier. [ralf@linux-mips.org: Fixed spelling mistake pointed out by Sergei Shtylyov .] Signed-off-by: Matt Redfearn Cc: Aaro Koskinen Cc: Masahiro Yamada Cc: Alexander Sverdlin Cc: Jaedon Shin Cc: Jonas Gorski Cc: Paul Burton Cc: linux-mips@linux-mips.org Cc: kernel-hardening@lists.openwall.com Cc: linux-kernel@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/12989/ Signed-off-by: Ralf Baechle --- diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c index 3378fda..9b20a0f 100644 --- a/arch/mips/kernel/setup.c +++ b/arch/mips/kernel/setup.c @@ -477,9 +477,18 @@ static void __init bootmem_init(void) */ if (__pa_symbol(_text) > __pa_symbol(VMLINUX_LOAD_ADDRESS)) { unsigned long offset; + extern void show_kernel_relocation(const char *level); offset = __pa_symbol(_text) - __pa_symbol(VMLINUX_LOAD_ADDRESS); free_bootmem(__pa_symbol(VMLINUX_LOAD_ADDRESS), offset); + +#if defined(CONFIG_DEBUG_KERNEL) && defined(CONFIG_DEBUG_INFO) + /* + * This information is necessary when debugging the kernel + * But is a security vulnerability otherwise! + */ + show_kernel_relocation(KERN_INFO); +#endif } #endif