linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] arm64, kaslr: export offset in VMCOREINFO ELF notes
@ 2018-07-30  6:24 Bhupesh Sharma
  2018-07-31  9:19 ` James Morse
  0 siblings, 1 reply; 4+ messages in thread
From: Bhupesh Sharma @ 2018-07-30  6:24 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: linux-kernel, kexec, bhupesh.linux, takahiro.akashi,
	catalin.marinas, Bhupesh Sharma, Ard Biesheuvel, Will Deacon,
	Mark Rutland, James Morse

Include KASLR offset in arm64 VMCOREINFO ELF notes to assist in
debugging. vmcore parsing in user-space already expects this value in
the notes and we are providing it for portability of those existing
tools with x86.

Ideally we would like core code to do this (so that way this
information won't be missed when an architecture adds KASLR support),
but mips has CONFIG_RANDOMIZE_BASE, and doesn't provide kaslr_offset(),
so I am not sure if this is needed for mips (and other such similar arch
cases in future). So, lets keep this architecture specific for now.

As an example of a user-space use-case, consider the
makedumpfile user-space utility which will need fixup to use this
KASLR offset to work with cases where we need to find a way to
translate symbol address from vmlinux to kernel run time address
in case of KASLR boot on arm64.

I have already submitted the makedumpfile user-space patch upstream
and the maintainer has suggested to wait for the kernel changes to be
included (see [0]).

I tested this on my qualcomm amberwing board both for KASLR and
non-KASLR boot cases:

Without this patch:
   # cat > scrub.conf << EOF
   [vmlinux]
   erase jiffies
   erase init_task.utime
   for tsk in init_task.tasks.next within task_struct:tasks
       erase tsk.utime
   endfor
   EOF

  # makedumpfile --split -d 31 -x vmlinux --config scrub.conf vmcore dumpfile_{1,2,3}
  readpage_elf: Attempt to read non-existent page at 0xffffa8a5bf180000.
  readmem: type_addr: 1, addr:ffffa8a5bf180000, size:8
  vaddr_to_paddr_arm64: Can't read pgd
  readmem: Can't convert a virtual address(ffff0000092a542c) to physical
  address.
  readmem: type_addr: 0, addr:ffff0000092a542c, size:390
  check_release: Can't get the address of system_utsname

After this patch check_release() is ok, and also we are able to erase
symbol from vmcore (I checked this with kernel 4.18.0-rc4+):

  # makedumpfile --split -d 31 -x vmlinux --config scrub.conf vmcore dumpfile_{1,2,3}
  The kernel version is not supported.
  The makedumpfile operation may be incomplete.
  Checking for memory holes                         : [100.0 %] \
  Checking for memory holes                         : [100.0 %] |
  Checking foExcluding unnecessary pages                       : [100.0 %]
  \
  Excluding unnecessary pages                       : [100.0 %] \

  The dumpfiles are saved to dumpfile_1, dumpfile_2, and dumpfile_3.

  makedumpfile Completed.

[0] https://www.spinics.net/lists/kexec/msg21195.html

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: James Morse <james.morse@arm.com>
Signed-off-by: Bhupesh Sharma <bhsharma@redhat.com>
---
Changes since v1:
 - Addressed review comments from James regarding commit log
 - v1 can be viewed here: https://lkml.org/lkml/2018/7/18/951
 - v2 is rebased against linux-next/master

 arch/arm64/kernel/machine_kexec.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/kernel/machine_kexec.c b/arch/arm64/kernel/machine_kexec.c
index f62effc6e064..028df356a5fd 100644
--- a/arch/arm64/kernel/machine_kexec.c
+++ b/arch/arm64/kernel/machine_kexec.c
@@ -360,4 +360,5 @@ void arch_crash_save_vmcoreinfo(void)
 						kimage_voffset);
 	vmcoreinfo_append_str("NUMBER(PHYS_OFFSET)=0x%llx\n",
 						PHYS_OFFSET);
+	vmcoreinfo_append_str("KERNELOFFSET=%lx\n", kaslr_offset());
 }
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] arm64, kaslr: export offset in VMCOREINFO ELF notes
  2018-07-30  6:24 [PATCH v2] arm64, kaslr: export offset in VMCOREINFO ELF notes Bhupesh Sharma
@ 2018-07-31  9:19 ` James Morse
  2018-07-31  9:26   ` Will Deacon
  0 siblings, 1 reply; 4+ messages in thread
From: James Morse @ 2018-07-31  9:19 UTC (permalink / raw)
  To: Bhupesh Sharma
  Cc: linux-arm-kernel, linux-kernel, kexec, bhupesh.linux,
	takahiro.akashi, catalin.marinas, Ard Biesheuvel, Will Deacon,
	Mark Rutland

Hi Bhupesh,

On 30/07/18 07:24, Bhupesh Sharma wrote:
> Include KASLR offset in arm64 VMCOREINFO ELF notes to assist in
> debugging. vmcore parsing in user-space already expects this value in
> the notes and we are providing it for portability of those existing
> tools with x86.
> 
> Ideally we would like core code to do this (so that way this
> information won't be missed when an architecture adds KASLR support),
> but mips has CONFIG_RANDOMIZE_BASE, and doesn't provide kaslr_offset(),
> so I am not sure if this is needed for mips (and other such similar arch
> cases in future). So, lets keep this architecture specific for now.

(heh, I assumed you would rewrite my train-of-thought, but I guess this works!)


> As an example of a user-space use-case, consider the
> makedumpfile user-space utility which will need fixup to use this
> KASLR offset to work with cases where we need to find a way to
> translate symbol address from vmlinux to kernel run time address
> in case of KASLR boot on arm64.

Acked-by: James Morse <james.morse@arm.com>

If we want to send this to stable, it looks like it should have been part of the
KASLR series, f80fb3a3d5084 ("arm64: add support for kernel ASLR") was merged
for v4.6.
CC: <stable@vger.kernel.org> # 4.6.x


Thanks,

James


> diff --git a/arch/arm64/kernel/machine_kexec.c b/arch/arm64/kernel/machine_kexec.c
> index f62effc6e064..028df356a5fd 100644
> --- a/arch/arm64/kernel/machine_kexec.c
> +++ b/arch/arm64/kernel/machine_kexec.c
> @@ -360,4 +360,5 @@ void arch_crash_save_vmcoreinfo(void)
>  						kimage_voffset);
>  	vmcoreinfo_append_str("NUMBER(PHYS_OFFSET)=0x%llx\n",
>  						PHYS_OFFSET);
> +	vmcoreinfo_append_str("KERNELOFFSET=%lx\n", kaslr_offset());
>  }
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] arm64, kaslr: export offset in VMCOREINFO ELF notes
  2018-07-31  9:19 ` James Morse
@ 2018-07-31  9:26   ` Will Deacon
  2018-07-31 10:15     ` Bhupesh Sharma
  0 siblings, 1 reply; 4+ messages in thread
From: Will Deacon @ 2018-07-31  9:26 UTC (permalink / raw)
  To: James Morse
  Cc: Bhupesh Sharma, linux-arm-kernel, linux-kernel, kexec,
	bhupesh.linux, takahiro.akashi, catalin.marinas, Ard Biesheuvel,
	Mark Rutland

On Tue, Jul 31, 2018 at 10:19:35AM +0100, James Morse wrote:
> Hi Bhupesh,
> 
> On 30/07/18 07:24, Bhupesh Sharma wrote:
> > Include KASLR offset in arm64 VMCOREINFO ELF notes to assist in
> > debugging. vmcore parsing in user-space already expects this value in
> > the notes and we are providing it for portability of those existing
> > tools with x86.
> > 
> > Ideally we would like core code to do this (so that way this
> > information won't be missed when an architecture adds KASLR support),
> > but mips has CONFIG_RANDOMIZE_BASE, and doesn't provide kaslr_offset(),
> > so I am not sure if this is needed for mips (and other such similar arch
> > cases in future). So, lets keep this architecture specific for now.
> 
> (heh, I assumed you would rewrite my train-of-thought, but I guess this works!)
> 
> 
> > As an example of a user-space use-case, consider the
> > makedumpfile user-space utility which will need fixup to use this
> > KASLR offset to work with cases where we need to find a way to
> > translate symbol address from vmlinux to kernel run time address
> > in case of KASLR boot on arm64.
> 
> Acked-by: James Morse <james.morse@arm.com>
> 
> If we want to send this to stable, it looks like it should have been part of the
> KASLR series, f80fb3a3d5084 ("arm64: add support for kernel ASLR") was merged
> for v4.6.
> CC: <stable@vger.kernel.org> # 4.6.x

Hmm, does this warrant a stable backport? This hasn't ever worked, right?

Will

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] arm64, kaslr: export offset in VMCOREINFO ELF notes
  2018-07-31  9:26   ` Will Deacon
@ 2018-07-31 10:15     ` Bhupesh Sharma
  0 siblings, 0 replies; 4+ messages in thread
From: Bhupesh Sharma @ 2018-07-31 10:15 UTC (permalink / raw)
  To: Will Deacon
  Cc: James Morse, linux-arm-kernel, Linux Kernel Mailing List,
	kexec mailing list, Bhupesh SHARMA, AKASHI Takahiro,
	Catalin Marinas, Ard Biesheuvel, Mark Rutland

Hi Will, James,

On Tue, Jul 31, 2018 at 2:56 PM, Will Deacon <will.deacon@arm.com> wrote:
> On Tue, Jul 31, 2018 at 10:19:35AM +0100, James Morse wrote:
>> Hi Bhupesh,
>>
>> On 30/07/18 07:24, Bhupesh Sharma wrote:
>> > Include KASLR offset in arm64 VMCOREINFO ELF notes to assist in
>> > debugging. vmcore parsing in user-space already expects this value in
>> > the notes and we are providing it for portability of those existing
>> > tools with x86.
>> >
>> > Ideally we would like core code to do this (so that way this
>> > information won't be missed when an architecture adds KASLR support),
>> > but mips has CONFIG_RANDOMIZE_BASE, and doesn't provide kaslr_offset(),
>> > so I am not sure if this is needed for mips (and other such similar arch
>> > cases in future). So, lets keep this architecture specific for now.
>>
>> (heh, I assumed you would rewrite my train-of-thought, but I guess this works!)
>>
>>
>> > As an example of a user-space use-case, consider the
>> > makedumpfile user-space utility which will need fixup to use this
>> > KASLR offset to work with cases where we need to find a way to
>> > translate symbol address from vmlinux to kernel run time address
>> > in case of KASLR boot on arm64.
>>
>> Acked-by: James Morse <james.morse@arm.com>

Thanks James.

>> If we want to send this to stable, it looks like it should have been part of the
>> KASLR series, f80fb3a3d5084 ("arm64: add support for kernel ASLR") was merged
>> for v4.6.
>> CC: <stable@vger.kernel.org> # 4.6.x
>
> Hmm, does this warrant a stable backport? This hasn't ever worked, right?

Yes, it is a new feature being enabled/tested in user-space utilities
now for arm64 (although it's being used for x86_64 since some time).

I would like the user-space utilities to do away with the arch
specific code (as much as possible) for KASLR features, but we are
still kind of stabilizing the same on various archs, so the user-space
cleanup is one of items on my to-do list.

However, since kernel and user-space features are frequently
backported to older versions (e.g. RHEL and OpenSuse), so it would
help to send this patch to stable as well, so that stable kernels >=
4.6.x can work well with such backported user-space utilities and
utilize KASLR features on arm64 well.

As such, I see no side-effect of adding this information to the
vmcoreinfo in the stable kernels as well.

Thanks,
Bhupesh

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-07-31 10:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-30  6:24 [PATCH v2] arm64, kaslr: export offset in VMCOREINFO ELF notes Bhupesh Sharma
2018-07-31  9:19 ` James Morse
2018-07-31  9:26   ` Will Deacon
2018-07-31 10:15     ` Bhupesh Sharma

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).