Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756614AbcCaJRg (ORCPT ); Thu, 31 Mar 2016 05:17:36 -0400 Received: from mailapp01.imgtec.com ([195.59.15.196]:1590 "EHLO mailapp01.imgtec.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756102AbcCaJGV (ORCPT ); Thu, 31 Mar 2016 05:06:21 -0400 From: Matt Redfearn To: Ralf Baechle CC: , , "Matt Redfearn" , Aaro Koskinen , Masahiro Yamada , Alexander Sverdlin , , Jaedon Shin , Jonas Gorski , Paul Burton Subject: [PATCH v2 11/11] MIPS: KASLR: Print relocation Information on boot Date: Thu, 31 Mar 2016 10:05:42 +0100 Message-ID: <1459415142-3412-12-git-send-email-matt.redfearn@imgtec.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1459415142-3412-1-git-send-email-matt.redfearn@imgtec.com> References: <1459415142-3412-1-git-send-email-matt.redfearn@imgtec.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [192.168.154.116] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1193 Lines: 38 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 notifer. Signed-off-by: Matt Redfearn --- Changes in v2: None arch/mips/kernel/setup.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c index d8376d7b3345..ae71f8d9b555 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 -- 2.5.0