]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blobdiff - queue-5.1/x86-boot-fix-memory-leak-in-default_get_smp_config.patch
5.1-stable patches
[thirdparty/kernel/stable-queue.git] / queue-5.1 / x86-boot-fix-memory-leak-in-default_get_smp_config.patch
diff --git a/queue-5.1/x86-boot-fix-memory-leak-in-default_get_smp_config.patch b/queue-5.1/x86-boot-fix-memory-leak-in-default_get_smp_config.patch
new file mode 100644 (file)
index 0000000..a275f19
--- /dev/null
@@ -0,0 +1,59 @@
+From e74bd96989dd42a51a73eddb4a5510a6f5e42ac3 Mon Sep 17 00:00:00 2001
+From: David Rientjes <rientjes@google.com>
+Date: Tue, 9 Jul 2019 19:44:03 -0700
+Subject: x86/boot: Fix memory leak in default_get_smp_config()
+
+From: David Rientjes <rientjes@google.com>
+
+commit e74bd96989dd42a51a73eddb4a5510a6f5e42ac3 upstream.
+
+When default_get_smp_config() is called with early == 1 and mpf->feature1
+is non-zero, mpf is leaked because the return path does not do
+early_memunmap().
+
+Fix this and share a common exit routine.
+
+Fixes: 5997efb96756 ("x86/boot: Use memremap() to map the MPF and MPC data")
+Reported-by: Cfir Cohen <cfir@google.com>
+Signed-off-by: David Rientjes <rientjes@google.com>
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Cc: stable@vger.kernel.org
+Link: https://lkml.kernel.org/r/alpine.DEB.2.21.1907091942570.28240@chino.kir.corp.google.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/x86/kernel/mpparse.c |   10 ++++------
+ 1 file changed, 4 insertions(+), 6 deletions(-)
+
+--- a/arch/x86/kernel/mpparse.c
++++ b/arch/x86/kernel/mpparse.c
+@@ -546,17 +546,15 @@ void __init default_get_smp_config(unsig
+                        * local APIC has default address
+                        */
+                       mp_lapic_addr = APIC_DEFAULT_PHYS_BASE;
+-                      return;
++                      goto out;
+               }
+               pr_info("Default MP configuration #%d\n", mpf->feature1);
+               construct_default_ISA_mptable(mpf->feature1);
+       } else if (mpf->physptr) {
+-              if (check_physptr(mpf, early)) {
+-                      early_memunmap(mpf, sizeof(*mpf));
+-                      return;
+-              }
++              if (check_physptr(mpf, early))
++                      goto out;
+       } else
+               BUG();
+@@ -565,7 +563,7 @@ void __init default_get_smp_config(unsig
+       /*
+        * Only use the first configuration found.
+        */
+-
++out:
+       early_memunmap(mpf, sizeof(*mpf));
+ }