From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9ABFCC76186 for ; Wed, 24 Jul 2019 20:25:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 63B372166E for ; Wed, 24 Jul 2019 20:25:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563999914; bh=umCl6dFR14+uVHcFjKurp7A+kE3J7+NoohuECceKeLg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=X+9cql/lM5ipkzi04JfOCiMB+f+e8CNAhWUxmVrmxSIZj9gTBHQXwwePuXq/vB0bi kPV6m94xva+m/49H8buLH29Zr9d3vkjC63IDy1y8XcDhx8D1Go6dlMB4Bbyn9j4fEa VancHwAVpubUEMEpoDrHesSwm90DLdPm4L8S59Y4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389176AbfGXUZH (ORCPT ); Wed, 24 Jul 2019 16:25:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:40944 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389695AbfGXTjv (ORCPT ); Wed, 24 Jul 2019 15:39:51 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 609A721873; Wed, 24 Jul 2019 19:39:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563997190; bh=umCl6dFR14+uVHcFjKurp7A+kE3J7+NoohuECceKeLg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wfCUX/8Fb4uh/bpedZ1uI7k73csc1HZiO6CgH4mG7tdu8S0tQMaNxPS/SPPrLbt5L h47rZQzVOv7FA46En2Gqj7Fn3uu2KnBzsRHHKJeKPlkB2earPOCdqOTw2yur5bMxGG Qa/eTLQD9GV1jHNGFJ1Tj5S7zv5Y4qrkpO10Zfn0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Cfir Cohen , David Rientjes , Thomas Gleixner Subject: [PATCH 5.2 353/413] x86/boot: Fix memory leak in default_get_smp_config() Date: Wed, 24 Jul 2019 21:20:44 +0200 Message-Id: <20190724191801.004339877@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: David Rientjes 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 Signed-off-by: David Rientjes Signed-off-by: Thomas Gleixner 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 --- 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)); }