]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.9-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 8 Jul 2019 13:58:13 +0000 (15:58 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 8 Jul 2019 13:58:13 +0000 (15:58 +0200)
added patches:
arm64-kaslr-keep-modules-inside-module-region-when-kasan-is-enabled.patch

queue-4.9/arm64-kaslr-keep-modules-inside-module-region-when-kasan-is-enabled.patch [new file with mode: 0644]
queue-4.9/series

diff --git a/queue-4.9/arm64-kaslr-keep-modules-inside-module-region-when-kasan-is-enabled.patch b/queue-4.9/arm64-kaslr-keep-modules-inside-module-region-when-kasan-is-enabled.patch
new file mode 100644 (file)
index 0000000..5767dbf
--- /dev/null
@@ -0,0 +1,56 @@
+From 6f496a555d93db7a11d4860b9220d904822f586a Mon Sep 17 00:00:00 2001
+From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
+Date: Tue, 25 Jun 2019 19:08:54 +0200
+Subject: arm64: kaslr: keep modules inside module region when KASAN is enabled
+
+From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
+
+commit 6f496a555d93db7a11d4860b9220d904822f586a upstream.
+
+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>
+[will: backport to 4.9.y]
+Signed-off-by: Will Deacon <will@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/arm64/kernel/module.c |    8 ++++++--
+ 1 file changed, 6 insertions(+), 2 deletions(-)
+
+--- a/arch/arm64/kernel/module.c
++++ b/arch/arm64/kernel/module.c
+@@ -33,10 +33,14 @@
+ void *module_alloc(unsigned long size)
+ {
+       void *p;
++      u64 module_alloc_end = module_alloc_base + MODULES_VSIZE;
++
++      if (IS_ENABLED(CONFIG_KASAN))
++              /* don't exceed the static module region - see below */
++              module_alloc_end = MODULES_END;
+       p = __vmalloc_node_range(size, MODULE_ALIGN, module_alloc_base,
+-                              module_alloc_base + MODULES_VSIZE,
+-                              GFP_KERNEL, PAGE_KERNEL_EXEC, 0,
++                              module_alloc_end, GFP_KERNEL, PAGE_KERNEL_EXEC, 0,
+                               NUMA_NO_NODE, __builtin_return_address(0));
+       if (!p && IS_ENABLED(CONFIG_ARM64_MODULE_PLTS) &&
index 824a8fa2876a8634a34592c834b65d9b129201bf..7fc9a78a76339375f012047c4290cc0457b6bf85 100644 (file)
@@ -99,3 +99,4 @@ kvm-lapic-fix-pending-interrupt-in-irr-blocked-by-software-disable-lapic.patch
 ib-hfi1-close-psm-sdma_progress-sleep-window.patch
 mips-add-missing-ehb-in-mtc0-mfc0-sequence.patch
 dmaengine-imx-sdma-remove-bd_intr-for-channel0.patch
+arm64-kaslr-keep-modules-inside-module-region-when-kasan-is-enabled.patch