]> git.baikalelectronics.ru Git - kernel.git/commit
arm64: kaslr: keep modules inside module region when KASAN is enabled
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Tue, 25 Jun 2019 17:08:54 +0000 (19:08 +0200)
committerWill Deacon <will@kernel.org>
Wed, 26 Jun 2019 10:34:10 +0000 (11:34 +0100)
commit51a4994ad0e523d3fbbe21e2fac06ab12e46bc9f
tree36fc4be44f0f094b0c3255a3081f936b2db21492
parentcb1786dbe275b9964b52d9a19121be56391a57a9
arm64: kaslr: keep modules inside module region when KASAN is enabled

When KASLR and KASAN are both enabled, we keep the modules where they
are, and randomize the placement of the kernel so it is within 2 GB
of the module region. The reason for this is that putting modules in
the vmalloc region (like we normally do when KASLR is enabled) is not
possible in this case, given that the entire vmalloc region is already
backed by KASAN zero shadow pages, and so allocating dedicated KASAN
shadow space as required by loaded modules is not possible.

The default module allocation window is set to [_etext - 128MB, _etext]
in kaslr.c, which is appropriate for KASLR kernels booted without a
seed or with 'nokaslr' on the command line. However, as it turns out,
it is not quite correct for the KASAN case, since it still intersects
the vmalloc region at the top, where attempts to allocate shadow pages
will collide with the KASAN zero shadow pages, causing a WARN() and all
kinds of other trouble. So cap the top end to MODULES_END explicitly
when running with KASAN.

Cc: <stable@vger.kernel.org> # 4.9+
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Tested-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Will Deacon <will@kernel.org>
arch/arm64/kernel/module.c