Back to home page

OSCL-LXR

 
 

    


0001 .. SPDX-License-Identifier: GPL-2.0
0002 
0003 ===========================
0004 KASLR for Freescale BookE32
0005 ===========================
0006 
0007 The word KASLR stands for Kernel Address Space Layout Randomization.
0008 
0009 This document tries to explain the implementation of the KASLR for
0010 Freescale BookE32. KASLR is a security feature that deters exploit
0011 attempts relying on knowledge of the location of kernel internals.
0012 
0013 Since CONFIG_RELOCATABLE has already supported, what we need to do is
0014 map or copy kernel to a proper place and relocate. Freescale Book-E
0015 parts expect lowmem to be mapped by fixed TLB entries(TLB1). The TLB1
0016 entries are not suitable to map the kernel directly in a randomized
0017 region, so we chose to copy the kernel to a proper place and restart to
0018 relocate.
0019 
0020 Entropy is derived from the banner and timer base, which will change every
0021 build and boot. This not so much safe so additionally the bootloader may
0022 pass entropy via the /chosen/kaslr-seed node in device tree.
0023 
0024 We will use the first 512M of the low memory to randomize the kernel
0025 image. The memory will be split in 64M zones. We will use the lower 8
0026 bit of the entropy to decide the index of the 64M zone. Then we chose a
0027 16K aligned offset inside the 64M zone to put the kernel in::
0028 
0029     KERNELBASE
0030 
0031         |-->   64M   <--|
0032         |               |
0033         +---------------+    +----------------+---------------+
0034         |               |....|    |kernel|    |               |
0035         +---------------+    +----------------+---------------+
0036         |                         |
0037         |----->   offset    <-----|
0038 
0039                               kernstart_virt_addr
0040 
0041 To enable KASLR, set CONFIG_RANDOMIZE_BASE = y. If KASLR is enabled and you
0042 want to disable it at runtime, add "nokaslr" to the kernel cmdline.