Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752037AbaDVE6k (ORCPT ); Tue, 22 Apr 2014 00:58:40 -0400 Received: from mail-ig0-f182.google.com ([209.85.213.182]:45065 "EHLO mail-ig0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751244AbaDVE6g (ORCPT ); Tue, 22 Apr 2014 00:58:36 -0400 MIME-Version: 1.0 In-Reply-To: <20140422031610.GC4564@dhcp-17-89.nay.redhat.com> References: <20140421105232.GB4564@dhcp-17-89.nay.redhat.com> <20140422031610.GC4564@dhcp-17-89.nay.redhat.com> Date: Mon, 21 Apr 2014 21:58:35 -0700 X-Google-Sender-Auth: JI_Sf522fQuG_XJyqr80-PafdaY Message-ID: Subject: Re: kaslr relocation incompitable with kernel loaded high From: Yinghai Lu To: WANG Chao Cc: Kees Cook , "H. Peter Anvin" , Zhang Yanfei , Vivek Goyal , Linux Kernel Mailing List Content-Type: multipart/mixed; boundary=001a11c1e914e8c14f04f79a77e1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --001a11c1e914e8c14f04f79a77e1 Content-Type: text/plain; charset=UTF-8 On Mon, Apr 21, 2014 at 8:16 PM, WANG Chao wrote: > On 04/21/14 at 11:01am, Kees Cook wrote: >> On Mon, Apr 21, 2014 at 10:56 AM, Yinghai Lu wrote: >> > On Mon, Apr 21, 2014 at 3:52 AM, WANG Chao wrote: >> >> Hi, Kees >> >> >> >> When I'm testing kaslr with kdump, I find that when 2nd kernel is loaded >> >> high, it doesn't boot. >> >> >> >> I reserved 128M memory at high with kernel cmdline >> >> "crashkernel=128M,high crashkernel=0,low", and for which I got: >> >> >> >> [ 0.000000] Reserving 128MB of memory at 6896MB for crashkernel (System RAM: 6013MB) >> >> >> >> Then I load kdump kernel into the reserved memory region, using a local >> >> modified kexec-tools which is passing e820 in boot_params. >> >> >> >> The e820 map of system RAM passed to 2nd kernel: >> >> >> >> E820 memmap (of RAM): >> >> 0000000000001000-000000000009e3ff (1) >> >> 00000001af000000-00000001b6f5dfff (1) >> >> 00000001b6fff400-00000001b6ffffff (1) >> >> >> >> In which, 2nd kernel is loaded at 0x1b5000000. >> >> >> >> After triggerred a system crash, 2nd kernel doesn't boot even with >> >> "nokaslr" cmdline: >> >> >> >> # echo c > /proc/sysrq-trigger >> >> [..] >> >> >> >> I'm in purgatory >> >> early console in decompress_kernel >> >> KASLR disabled... >> >> >> >> Decompressing Linux... Parsing ELF... Performing relocations... >> >> >> >> 32-bit relocation outside of kernel! >> > >> > Interesting, when kernel get at "early console in decompress_kernel" >> > kernel already in 64 bit... >> > >> > what does it mean "32-bit relocation outside of kernel" ? >> > >> > why 32-bit is involved ? >> >> The 64-bit kernel has both 64 and 32 bit relocations (there are two >> tables at the end of the kernel image). The error means that the >> resulting relocation is believed to be outside the kernel image: >> >> http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/arch/x86/boot/compressed/misc.c#n283 >> >> Which means there is likely something wrong with this calculation in >> your situation: >> >> /* >> * Calculate the delta between where vmlinux was linked to load >> * and where it was actually loaded. >> */ >> delta = min_addr - LOAD_PHYSICAL_ADDR; >> > > Probably. Please check attached that patch that will solve nokaslr. Somehow I got "KASLR could not find suitable E820 region..." so i only have "No relocation needed" will check that later. --001a11c1e914e8c14f04f79a77e1 Content-Type: text/x-patch; charset=US-ASCII; name="aslr_1.patch" Content-Disposition: attachment; filename="aslr_1.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_huaq2gnp0 LS0tCiBhcmNoL3g4Ni9ib290L2NvbXByZXNzZWQvbWlzYy5jIHwgICAxNCArKysrKysrKystLS0t LQogMSBmaWxlIGNoYW5nZWQsIDkgaW5zZXJ0aW9ucygrKSwgNSBkZWxldGlvbnMoLSkKCkluZGV4 OiBsaW51eC0yLjYvYXJjaC94ODYvYm9vdC9jb21wcmVzc2VkL21pc2MuYwo9PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09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uQm9vdGluZyB0aGUga2Vy bmVsLlxuIik7CiAJcmV0dXJuIG91dHB1dDsKIH0K --001a11c1e914e8c14f04f79a77e1-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/