summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Gortmaker <paul.gortmaker@windriver.com>2019-09-16 11:01:32 -0400
committerPaul Gortmaker <paul.gortmaker@windriver.com>2019-09-16 11:01:32 -0400
commit1afc14af96e09fda4661bdf090177c6743d7f6aa (patch)
treeccc804585591905af9e5639c33cee144662aa3f8
parent9e8f74087a32eb8c752e524875cd58df0a5a34a5 (diff)
downloadlongterm-queue-4.18-1afc14af96e09fda4661bdf090177c6743d7f6aa.tar.gz
initramfs: add fix for prev fix
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
-rw-r--r--queue/initramfs-don-t-free-a-non-existent-initrd.patch44
-rw-r--r--queue/series1
2 files changed, 45 insertions, 0 deletions
diff --git a/queue/initramfs-don-t-free-a-non-existent-initrd.patch b/queue/initramfs-don-t-free-a-non-existent-initrd.patch
new file mode 100644
index 0000000..d908b04
--- /dev/null
+++ b/queue/initramfs-don-t-free-a-non-existent-initrd.patch
@@ -0,0 +1,44 @@
+From 5d59aa8f9ce972b472201aed86e904bb75879ff0 Mon Sep 17 00:00:00 2001
+From: Steven Price <steven.price@arm.com>
+Date: Fri, 17 May 2019 14:31:47 -0700
+Subject: [PATCH] initramfs: don't free a non-existent initrd
+
+commit 5d59aa8f9ce972b472201aed86e904bb75879ff0 upstream.
+
+Since commit 54c7a8916a88 ("initramfs: free initrd memory if opening
+/initrd.image fails"), the kernel has unconditionally attempted to free
+the initrd even if it doesn't exist.
+
+In the non-existent case this causes a boot-time splat if
+CONFIG_DEBUG_VIRTUAL is enabled due to a call to virt_to_phys() with a
+NULL address.
+
+Instead we should check that the initrd actually exists and only attempt
+to free it if it does.
+
+Link: http://lkml.kernel.org/r/20190516143125.48948-1-steven.price@arm.com
+Fixes: 54c7a8916a88 ("initramfs: free initrd memory if opening /initrd.image fails")
+Signed-off-by: Steven Price <steven.price@arm.com>
+Reported-by: Mark Rutland <mark.rutland@arm.com>
+Tested-by: Mark Rutland <mark.rutland@arm.com>
+Reviewed-by: Mike Rapoport <rppt@linux.ibm.com>
+Cc: Christoph Hellwig <hch@lst.de>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+
+diff --git a/init/initramfs.c b/init/initramfs.c
+index 435a428c2af1..178130fd61c2 100644
+--- a/init/initramfs.c
++++ b/init/initramfs.c
+@@ -669,7 +669,7 @@ static int __init populate_rootfs(void)
+ * If the initrd region is overlapped with crashkernel reserved region,
+ * free only memory that is not part of crashkernel region.
+ */
+- if (!do_retain_initrd && !kexec_free_initrd())
++ if (!do_retain_initrd && initrd_start && !kexec_free_initrd())
+ free_initrd_mem(initrd_start, initrd_end);
+ initrd_start = 0;
+ initrd_end = 0;
+--
+2.7.4
+
diff --git a/queue/series b/queue/series
index e9eb677..5ed20ea 100644
--- a/queue/series
+++ b/queue/series
@@ -228,3 +228,4 @@ drm-nouveau-i2c-Enable-i2c-pads-busses-during-preini.patch
MIPS-Fix-bounds-check-virt_addr_valid.patch
x86-ftrace-Fix-warning-and-considate-ftrace_jmp_repl.patch
blk-mq-move-cancel-of-requeue_work-to-the-front-of-b.patch
+initramfs-don-t-free-a-non-existent-initrd.patch