Similar to (user) ASLR – and, more recently, from the 3.14 kernel onward – even kernel VAS can be randomized (to some extent) by having KASLR enabled. Here, the base location of the kernel and module code within the kernel segment will be randomized by a page-aligned random offset from the base of RAM. This remains in effect for that session; that is, until a power cycle or reboot.
Several kernel configuration variables exist, enabling the platform developer to enable or disable these randomization options. As an example specific to the x86, the following is quoted directly from Documentation/x86/x86_64/mm.txt:
"Note that if CONFIG_RANDOMIZE_MEMORY is enabled, the direct mapping of all physical memory, vmalloc/ioremap space and virtual memory map are randomized. Their order is preserved but their base will be offset early at boot time."
KASLR can be controlled at boot time by passing a parameter to the kernel (via the bootloader):
- Explicitly turned off by...