Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3820057ybi; Mon, 29 Jul 2019 13:15:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqw++1eQkIl1XEHwgISvFX1AcFzd5bkffDJ+J29OC+V46Q91t9uPJBr6TVY6Dr6Kf2KHIZVV X-Received: by 2002:a17:90a:360b:: with SMTP id s11mr112275266pjb.51.1564431330050; Mon, 29 Jul 2019 13:15:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564431330; cv=none; d=google.com; s=arc-20160816; b=RH/6sFDSXZlkbohwFpls4Z6MjyhJasVma216hrXEG8qHkxOuAKGq9F9drD05X+ZqtX APnRq94+OHggCMBccj2VTEy8uXegHrFSut7Fjqs95IOTUbuWh3lR0WcirSUlenq6nYPE 36Ssxe2RKITNkAfTaI96REdZ/OuSnzcBM/SzbmvCWrzsL8piVi4X5FT+jh6PPWXkxsLf 9Wt+8VX4sqCoaFa/CUD1b8gOOHC5JWWo04xnBcriRbdUXmd7+RScfItu9NzxbZe+KkHq rhpB6Pxs//GUMmHTzZy6ciuOSmHGIQ1bxN9dEjUVOb8kN6sg7VIezJSlmIi/dlSDQkhq 3Mag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=elaH0uRqc+wPBD7NGVWtAYGhXk/RgoblQXHaglM2AH0=; b=GvRT1KypGthivmjWNtF29eX2M6BnrzfZRZ5y22KmhJF/8MC42+hAakSDU4SkjAt9L1 nmSrF7CiJGmxPRkpfgzUadvYV/edPs3d4+Y4CNw/FZ9jNkKVnwiySbMepCWiPg0xPDW3 2YQRclydPLx7oXbrVLZbKeP6FCXqapKKYTnzvhg5M9bMLiqEGNP6xpnU/Yj0QiR4qR7t gAffKTmou38Deu8whIt2nHczXHyyiIzdlzjkJxreuz+ijQQ3C9IT/nJVvBSqHcZUCtOY MQbrQc7npWzNhxhkgXzDN+AiibK3sT32z98rfPtbUDxn8r6rC7F9OMnq9eItuNwG7gbK F+1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jj8kcp4u; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t70si31621709pgd.573.2019.07.29.13.15.14; Mon, 29 Jul 2019 13:15:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jj8kcp4u; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730520AbfG2UMx (ORCPT + 99 others); Mon, 29 Jul 2019 16:12:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:44058 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728726AbfG2TbQ (ORCPT ); Mon, 29 Jul 2019 15:31:16 -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 B71DB2171F; Mon, 29 Jul 2019 19:31:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428676; bh=2grPPtpcN7ie7lKnPNiZEOWkC3Pu+Pw4pycW230f21Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jj8kcp4u+1raxyLEO6elfDqRMYQofR9Fa3p1Dx4efyFCQdqPc8/BBfh3ccW5fRZT8 el4SbIMh4LsJboQI6geCHQcgJJVR2RGZscZm6lue5lsSMgOwmXhCPPaeqNf6Lm8XyW TEx8y78WABZ9ULW9COV4tKAd1mFJgolpSXKbX7TA= 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 4.14 152/293] x86/boot: Fix memory leak in default_get_smp_config() Date: Mon, 29 Jul 2019 21:20:43 +0200 Message-Id: <20190729190836.225075240@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 @@ -544,17 +544,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(); @@ -563,7 +561,7 @@ void __init default_get_smp_config(unsig /* * Only use the first configuration found. */ - +out: early_memunmap(mpf, sizeof(*mpf)); }