]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
arm64/kernel: kaslr: reduce module randomization range to 4 GB
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Thu, 22 Aug 2019 21:15:52 +0000 (15:15 -0600)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Tue, 17 Sep 2019 16:02:18 +0000 (18:02 +0200)
commit444813992965377875cc986d3cbdbf50964a882d
treebafffef072bed10a52be0bae78c2388796382312
parenta4bb37c09cfca8812d092d39e9a75e48678bd066
arm64/kernel: kaslr: reduce module randomization range to 4 GB

BugLink: https://bugs.launchpad.net/bugs/1841109
We currently have to rely on the GCC large code model for KASLR for
two distinct but related reasons:
- if we enable full randomization, modules will be loaded very far away
  from the core kernel, where they are out of range for ADRP instructions,
- even without full randomization, the fact that the 128 MB module region
  is now no longer fully reserved for kernel modules means that there is
  a very low likelihood that the normal bottom-up allocation of other
  vmalloc regions may collide, and use up the range for other things.

Large model code is suboptimal, given that each symbol reference involves
a literal load that goes through the D-cache, reducing cache utilization.
But more importantly, literals are not instructions but part of .text
nonetheless, and hence mapped with executable permissions.

So let's get rid of our dependency on the large model for KASLR, by:
- reducing the full randomization range to 4 GB, thereby ensuring that
  ADRP references between modules and the kernel are always in range,
- reduce the spillover range to 4 GB as well, so that we fallback to a
  region that is still guaranteed to be in range
- move the randomization window of the core kernel to the middle of the
  VMALLOC space

Note that KASAN always uses the module region outside of the vmalloc space,
so keep the kernel close to that if KASAN is enabled.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
(cherry picked from commit f2b9ba871beb92fd6884b957acb14621b15fbe2b)
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Kleber Souza <kleber.souza@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
arch/arm64/Kconfig
arch/arm64/kernel/kaslr.c
arch/arm64/kernel/module.c
include/linux/sizes.h