mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
To: Kees Cook <keescook@chromium.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	"x86@kernel.org" <x86@kernel.org>,
	"kernel-hardening@lists.openwall.com" 
	<kernel-hardening@lists.openwall.com>,
	Aaron Durbin <adurbin@google.com>,
	Eric Northup <digitaleric@google.com>,
	Julien Tinnes <jln@google.com>, Will Drewry <wad@google.com>,
	Mathias Krause <minipli@googlemail.com>,
	Zhang Yanfei <zhangyanfei@cn.fujitsu.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Dave Anderson <anderson@redhat.com>
Subject: Re: [PATCH 6/7] x86, kaslr: report kernel offset on panic
Date: Thu, 03 Oct 2013 09:33:52 +0900	[thread overview]
Message-ID: <524CBB70.2060809@jp.fujitsu.com> (raw)
In-Reply-To: <524BE3C5.2070302@jp.fujitsu.com>

(2013/10/02 18:13), HATAYAMA Daisuke wrote:
> (2013/10/02 16:48), Kees Cook wrote:
<cut>
>>>> +
>>>> +     return 0;
>>>> +}
>>>> +
>>>> +/*
>>>>     * Determine if we were loaded by an EFI loader.  If so, then we have also been
>>>>     * passed the efi memmap, systab, etc., so we should use these data structures
>>>>     * for initialization.  Note, the efi init code path is determined by the
>>>> @@ -1242,3 +1256,15 @@ void __init i386_reserve_resources(void)
>>>>    }
>>>>
>>>>    #endif /* CONFIG_X86_32 */
>>>> +
>>>> +static struct notifier_block kernel_offset_notifier = {
>>>> +     .notifier_call = dump_kernel_offset
>>>> +};
>>>> +
>>>> +static int __init register_kernel_offset_dumper(void)
>>>> +{
>>>> +     atomic_notifier_chain_register(&panic_notifier_list,
>>>> +                                     &kernel_offset_notifier);
>>>> +     return 0;
>>>> +}
>>>> +__initcall(register_kernel_offset_dumper);
>>>>
>>>
>>> Panic notifier is not executed if kdump is enabled. Maybe, Chrome OS doesn't use
>>> kdump? Anyway, kdump related tools now calculate phys_base from memory map
>>> information passed as ELF PT_LOAD entries like below.
>>
>> Correct, we are not currently using kdump.
>>
>>> $ LANG=C readelf -l vmcore-rhel6up4
>>>
>>> Elf file type is CORE (Core file)
>>> Entry point 0x0
>>> There are 5 program headers, starting at offset 64
>>>
>>> Program Headers:
>>>    Type           Offset             VirtAddr           PhysAddr
>>>                   FileSiz            MemSiz              Flags  Align
>>>    NOTE           0x0000000000000158 0x0000000000000000 0x0000000000000000
>>>                   0x0000000000000b08 0x0000000000000b08         0
>>>    LOAD           0x0000000000000c60 0xffffffff81000000 0x0000000001000000
>>>                   0x000000000103b000 0x000000000103b000  RWE    0
>>>    LOAD           0x000000000103bc60 0xffff880000001000 0x0000000000001000
>>>                   0x000000000009cc00 0x000000000009cc00  RWE    0
>>>    LOAD           0x00000000010d8860 0xffff880000100000 0x0000000000100000
>>>                   0x0000000002f00000 0x0000000002f00000  RWE    0
>>>    LOAD           0x0000000003fd8860 0xffff880013000000 0x0000000013000000
>>>                   0x000000002cffd000 0x000000002cffd000  RWE    0
>>>
>>> Each PT_LOAD entry is assigned to virtual and physical address. In this case,
>>> 1st PT_LOAD entry belongs to kernel text mapping region, from which we can
>>> calculate phys_base value.
>>
>> It seems like all the information you need would still be available?
>> The virtual address is there, so it should be trivial to see the
>> offset, IIUC.
>>
>
> Partially yes. I think OK to analyze crash dump by crash utility, a gdb-based
> symbolic debugger for kernel, since phys_base absorbs kernel offset caused by
> relocation and phys_base is available in the way I explained above.
>
> However, the gained phys_base is not correct one, exactly
> phys_base + offset_by_relocation.
> When analyzing crash dump by crash utility, we use debug information generated
> during kernel build, which we install as kernel-debuginfo on RHEL for example.
> Symbols in debuginfo have statically assigned addresses at build so we see
> the statically assigned addresses during debugging and we see
> phys_base + offset_by_relocation as phys_base. This would be problematic
> if failure on crash dump is relevant to the relocated addresses, though I don't
> immediately come up with crash senario where relocated symbol is defitely
> necessary.
>
> Still we can get relocated addresses if kallsyms is enabled on the kernel,
> but kallsyms and relocatable kernels are authogonal. I don't think it natural
> to rely on kallsyms. It seems natural to export relocation information newly
> as debugging information.
>

I was confused yesterday. As I said above, kdump related tools now don't support
relocation on x86_64, phys_base only. kdump related tools think of present kernel
offset as phys_base. Then, they reflect kernel offset caused by relocation in
physical addresses only, not in virtual addresses. This obviously affects the tools.

BTW, relocation looks more sophisticated than phys_base one. Is it possible to
switch from phys_base one to relocation on x86_64? On x86, relocation is used so
I guess x86_64 can work in the same way. Is there something missing?
Is there what phys_base can but relocation cannot on x86_64?

And, Dave, is there feature for crash utility to treat relocation now?

-- 
Thanks.
HATAYAMA, Daisuke


  reply	other threads:[~2013-10-03  0:36 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-01 19:37 [PATCH v6 0/7] Kernel base address randomization Kees Cook
2013-10-01 19:37 ` [PATCH 1/7] x86, kaslr: move CPU flags out of cpucheck Kees Cook
2013-10-01 20:48   ` H. Peter Anvin
2013-10-01 21:09     ` Kees Cook
2013-10-01 19:37 ` [PATCH 2/7] x86, kaslr: return location from decompress_kernel Kees Cook
2013-10-01 19:37 ` [PATCH 3/7] x86, kaslr: find minimum safe relocation position Kees Cook
2013-10-01 19:37 ` [PATCH 4/7] x86, kaslr: select random base offset Kees Cook
2013-10-01 20:46   ` H. Peter Anvin
2013-10-01 21:18     ` Kees Cook
2013-10-01 19:37 ` [PATCH 5/7] x86, kaslr: select memory region from e820 maps Kees Cook
2013-10-01 19:37 ` [PATCH 6/7] x86, kaslr: report kernel offset on panic Kees Cook
2013-10-02  0:38   ` HATAYAMA Daisuke
2013-10-02  1:06     ` HATAYAMA Daisuke
2013-10-02  7:51       ` Kees Cook
2013-10-02  7:48     ` Kees Cook
2013-10-02  9:13       ` HATAYAMA Daisuke
2013-10-03  0:33         ` HATAYAMA Daisuke [this message]
2013-10-03 13:47           ` Dave Anderson
2013-10-07  1:59             ` HATAYAMA Daisuke
2013-10-07 13:21               ` Dave Anderson
2013-10-08  9:52                 ` HATAYAMA Daisuke
2013-10-08 13:38                   ` Dave Anderson
2013-10-09 10:04                     ` HATAYAMA Daisuke
2013-10-09 14:13                       ` H. Peter Anvin
2013-10-09 18:06                       ` Kees Cook
2013-10-01 19:37 ` [PATCH 7/7] x86, kaslr: raise max positions to 1GiB on x86_64 Kees Cook
2013-10-02  5:07 ` [PATCH v6 0/7] Kernel base address randomization Ingo Molnar
2013-10-02  5:11   ` H. Peter Anvin
2013-10-02  5:25     ` Ingo Molnar
2013-10-02  5:30       ` H. Peter Anvin
2013-10-02  5:36         ` Kees Cook
2013-10-03 20:53 [PATCH v7 0/7] Kernel base address randomization on x86 Kees Cook
2013-10-03 20:53 ` [PATCH 6/7] x86, kaslr: report kernel offset on panic Kees Cook

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=524CBB70.2060809@jp.fujitsu.com \
    --to=d.hatayama@jp.fujitsu.com \
    --cc=adurbin@google.com \
    --cc=anderson@redhat.com \
    --cc=digitaleric@google.com \
    --cc=hpa@zytor.com \
    --cc=jln@google.com \
    --cc=keescook@chromium.org \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=minipli@googlemail.com \
    --cc=wad@google.com \
    --cc=x86@kernel.org \
    --cc=zhangyanfei@cn.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome