aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm64/kernel/setup.c
diff options
context:
space:
mode:
authorArd Biesheuvel <ard.biesheuvel@linaro.org>2016-01-26 08:12:01 -0500
committerCatalin Marinas <catalin.marinas@arm.com>2016-02-24 09:57:27 -0500
commitf80fb3a3d50843a401dac4b566b3b131da8077a2 (patch)
tree1861584ef7bbae384b12bfc70dc5974328995506 /arch/arm64/kernel/setup.c
parent1e48ef7fcc374051730381a2a05da77eb4eafdb0 (diff)
arm64: add support for kernel ASLR
This adds support for KASLR is implemented, based on entropy provided by the bootloader in the /chosen/kaslr-seed DT property. Depending on the size of the address space (VA_BITS) and the page size, the entropy in the virtual displacement is up to 13 bits (16k/2 levels) and up to 25 bits (all 4 levels), with the sidenote that displacements that result in the kernel image straddling a 1GB/32MB/512MB alignment boundary (for 4KB/16KB/64KB granule kernels, respectively) are not allowed, and will be rounded up to an acceptable value. If CONFIG_RANDOMIZE_MODULE_REGION_FULL is enabled, the module region is randomized independently from the core kernel. This makes it less likely that the location of core kernel data structures can be determined by an adversary, but causes all function calls from modules into the core kernel to be resolved via entries in the module PLTs. If CONFIG_RANDOMIZE_MODULE_REGION_FULL is not enabled, the module region is randomized by choosing a page aligned 128 MB region inside the interval [_etext - 128 MB, _stext + 128 MB). This gives between 10 and 14 bits of entropy (depending on page size), independently of the kernel randomization, but still guarantees that modules are within the range of relative branch and jump instructions (with the caveat that, since the module region is shared with other uses of the vmalloc area, modules may need to be loaded further away if the module region is exhausted) Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Diffstat (limited to 'arch/arm64/kernel/setup.c')
-rw-r--r--arch/arm64/kernel/setup.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index cfed56f0ad26..42371f69def3 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -388,3 +388,32 @@ static int __init topology_init(void)
388 return 0; 388 return 0;
389} 389}
390subsys_initcall(topology_init); 390subsys_initcall(topology_init);
391
392/*
393 * Dump out kernel offset information on panic.
394 */
395static int dump_kernel_offset(struct notifier_block *self, unsigned long v,
396 void *p)
397{
398 u64 const kaslr_offset = kimage_vaddr - KIMAGE_VADDR;
399
400 if (IS_ENABLED(CONFIG_RANDOMIZE_BASE) && kaslr_offset > 0) {
401 pr_emerg("Kernel Offset: 0x%llx from 0x%lx\n",
402 kaslr_offset, KIMAGE_VADDR);
403 } else {
404 pr_emerg("Kernel Offset: disabled\n");
405 }
406 return 0;
407}
408
409static struct notifier_block kernel_offset_notifier = {
410 .notifier_call = dump_kernel_offset
411};
412
413static int __init register_kernel_offset_dumper(void)
414{
415 atomic_notifier_chain_register(&panic_notifier_list,
416 &kernel_offset_notifier);
417 return 0;
418}
419__initcall(register_kernel_offset_dumper);