Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10427206ybi; Wed, 24 Jul 2019 23:02:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqwTZKFyo3cb40Xw1D29tBr+Y9IiryXkftAeljhN7aSoM4Kqt52c9i2ZqF3YRIouUpvJgJ3f X-Received: by 2002:a63:eb06:: with SMTP id t6mr79430828pgh.107.1564034528199; Wed, 24 Jul 2019 23:02:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564034528; cv=none; d=google.com; s=arc-20160816; b=s+0mpsntjQE5DlC2w2o2BTzpJsxXtDcQl+5Yi9G5TWzmpznhGb5P6puOvPtbspXD6N c0NdrptdoUqF1lhe+d1Wo0R4uvaHGPq2qo6l5xkDTmXZ62A37swcpfppsslL5l0IysBd d6XBMUFADmxaBsuklCVZ7RQHz8/nrAmb7oeKAtctKWlPGH2L0bTWKjjSPnyhpVLURoMo nsL4T9aGmUcB0FNSYulauzQZ/5pY9qteOss5IfPn2+kGBDMDtsI7mhEnrXHxe4l76W/8 fwwNoOsgM6q2qJUJt5uJuWgAuEXtdNo+XOKNM8CCFxRNFy6MXDPOAF7pRM3zAeBMcUM3 /HKA== 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=4+AM4e0oayrEaKfrcT8kX26qTzktOdBOiHmUyE76WRY=; b=cnszuPLnMC0WrOXljl2I2WwVFHmwOFLqZTeZWWEf/DqtfAYtbU34RdncfWprUG7k/K 7k+JhQZrUNqb6dkG0eFrYYz8o8Wdams6E+xv7an2ScbtFIFhM0UGpBT94SitJtgQuU19 9nowbFgWHCrkD8OC1fETc1RDuPE3wKI1MM4n1wgniwF0Lu+oEZ0GA46gW/qyLeciun8y qU3vQA4SKSLrfq3tkjUdo0KvGh8d2yL/LfsQMt7TzOKY9q+M5yo48ev8EnyqqDDor4kD 2+Vcdy557etffpp3hWxUP+e1anFcTKc5b2bAmF2s+/ZiKiZ8RmdIzXN44Jti+BJ91vWX pMIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zBXDW8F+; 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 n11si13978108plg.315.2019.07.24.23.01.52; Wed, 24 Jul 2019 23:02:08 -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=zBXDW8F+; 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 S2405025AbfGYFop (ORCPT + 99 others); Thu, 25 Jul 2019 01:44:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:59818 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404985AbfGYFoj (ORCPT ); Thu, 25 Jul 2019 01:44:39 -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 62BA622BF3; Thu, 25 Jul 2019 05:44:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564033478; bh=F9ZjiBCqBkwRaHVBjKe2gIK8f+nr1wpwN/rqDxjjbuM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zBXDW8F+zxcronV4RzhBHU3knWPfWIFQmLCglCsxj8TbLwcAADYzPl/rFYpqUagji xADsZHTddE8ZFGRtS2uAkNZUmvvDpc32S8IQsUY4fmKn7mX/XQBLWQRGhXyWwliNKY RgFOkWkBrMgU2hoqan6perXD/bsjXmCVLUugiVkQ= 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.19 223/271] x86/boot: Fix memory leak in default_get_smp_config() Date: Wed, 24 Jul 2019 21:21:32 +0200 Message-Id: <20190724191714.257895655@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191655.268628197@linuxfoundation.org> References: <20190724191655.268628197@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 @@ -547,17 +547,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(); @@ -566,7 +564,7 @@ void __init default_get_smp_config(unsig /* * Only use the first configuration found. */ - +out: early_memunmap(mpf, sizeof(*mpf)); }