Skip to content

Commit

Permalink
x86, kaslr: Report kernel offset on panic
Browse files Browse the repository at this point in the history
When the system panics, include the kernel offset in the report to assist
in debugging.

Signed-off-by: Kees Cook <keescook@chromium.org>
Link: http://lkml.kernel.org/r/1381450698-28710-6-git-send-email-keescook@chromium.org
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
  • Loading branch information
Kees Cook authored and H. Peter Anvin committed Oct 13, 2013
1 parent 82fa963 commit f32360e
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions arch/x86/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,20 @@ static void __init trim_low_memory_range(void)
memblock_reserve(0, ALIGN(reserve_low, PAGE_SIZE));
}

/*
* Dump out kernel offset information on panic.
*/
static int
dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p)
{
pr_emerg("Kernel Offset: 0x%lx from 0x%lx "
"(relocation range: 0x%lx-0x%lx)\n",
(unsigned long)&_text - __START_KERNEL, __START_KERNEL,
__START_KERNEL_map, MODULES_VADDR-1);

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
Expand Down Expand Up @@ -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);

0 comments on commit f32360e

Please sign in to comment.