diff options
| author | Kees Cook <keescook@chromium.org> | 2013-10-10 20:18:17 -0400 |
|---|---|---|
| committer | H. Peter Anvin <hpa@linux.intel.com> | 2013-10-13 06:12:24 -0400 |
| commit | f32360ef6608434a032dc7ad262d45e9693c27f3 (patch) | |
| tree | cc7d11225d447c325842e52b1314501afe1518c1 | |
| parent | 82fa9637a2ba285bcc7c5050c73010b2c1b3d803 (diff) | |
x86, kaslr: Report kernel offset on panic
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>
| -rw-r--r-- | arch/x86/kernel/setup.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index f0de6294b955..1708862fc40d 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c | |||
| @@ -824,6 +824,20 @@ static void __init trim_low_memory_range(void) | |||
| 824 | } | 824 | } |
| 825 | 825 | ||
| 826 | /* | 826 | /* |
| 827 | * Dump out kernel offset information on panic. | ||
| 828 | */ | ||
| 829 | static int | ||
| 830 | dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p) | ||
| 831 | { | ||
| 832 | pr_emerg("Kernel Offset: 0x%lx from 0x%lx " | ||
| 833 | "(relocation range: 0x%lx-0x%lx)\n", | ||
| 834 | (unsigned long)&_text - __START_KERNEL, __START_KERNEL, | ||
| 835 | __START_KERNEL_map, MODULES_VADDR-1); | ||
| 836 | |||
| 837 | return 0; | ||
| 838 | } | ||
| 839 | |||
| 840 | /* | ||
| 827 | * Determine if we were loaded by an EFI loader. If so, then we have also been | 841 | * Determine if we were loaded by an EFI loader. If so, then we have also been |
| 828 | * passed the efi memmap, systab, etc., so we should use these data structures | 842 | * passed the efi memmap, systab, etc., so we should use these data structures |
| 829 | * for initialization. Note, the efi init code path is determined by the | 843 | * for initialization. Note, the efi init code path is determined by the |
| @@ -1242,3 +1256,15 @@ void __init i386_reserve_resources(void) | |||
| 1242 | } | 1256 | } |
| 1243 | 1257 | ||
| 1244 | #endif /* CONFIG_X86_32 */ | 1258 | #endif /* CONFIG_X86_32 */ |
| 1259 | |||
| 1260 | static struct notifier_block kernel_offset_notifier = { | ||
| 1261 | .notifier_call = dump_kernel_offset | ||
| 1262 | }; | ||
| 1263 | |||
| 1264 | static int __init register_kernel_offset_dumper(void) | ||
| 1265 | { | ||
| 1266 | atomic_notifier_chain_register(&panic_notifier_list, | ||
| 1267 | &kernel_offset_notifier); | ||
| 1268 | return 0; | ||
| 1269 | } | ||
| 1270 | __initcall(register_kernel_offset_dumper); | ||
