Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp8613287ybi; Tue, 9 Jul 2019 19:46:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqw4fN0Us4QhJ6546+ZpxIc2sNWioYc14KBDJt/RSpKVlU8hA/yqVtXN7L8gY3bZREr1Qx/0 X-Received: by 2002:a17:90a:2706:: with SMTP id o6mr3976221pje.62.1562726762614; Tue, 09 Jul 2019 19:46:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562726762; cv=none; d=google.com; s=arc-20160816; b=M+u0Tq/ScCpYyy7i3e3OFsZ59XN1LpoetRKZNe1qryivfOkAkMw6L7Mxr98a13hH9Z o8L4qjzt//kADrYV85adehFFuFuCpahT1qt71fkzAsGfQcyHUshSQWqQsbzqSr466qYH ipkbwNsgNISaHcQz9zNToct9a4LSxqeco56r+HZDV/bhejdGwUY1eE4+z5Oo6s3PfDfO XC5UXQltGbC8KBifl7ZB6+EurUrzn3zAYM1W/DV5AtUO8zBxJzVJjteShP+9zr3lU948 AlzumOMZhpotIykGkilycwDAD/8EY66MJh1yPKX1clGrdpzDFepXxqDhsSwMcb8LxRdP kCUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :subject:cc:to:from:date:dkim-signature; bh=6+LJGvw+qjKoO8SZDZ3CnbeCqyYBeV92bc9prl1ddmQ=; b=XYh803QOgtOtti4J6e5DNkTT/ub5Xv1JQWRxNpc2VxMUdwf3M4wax1C1KkZfvY3xEt vLsOSNAJcCHtOKoG9nfcQl2NMfJtJxDJFThGWYrIZWulCmnjztmMZDX93Ut8sBP/VOH2 b0RnIHrmUWfh1qraFVxb9uSST2puBkqz8T8wYU4XRyHJmRKgbjRym6Gj15tzHh1xzD+L whZOdnULga18/s9E9XWp9FoY6hr+bvbjP8t0RExcy9iCFm4KAadWFMYG8mdf0tstEC4q 9IFnR9t31M/W4UbYw81Jde8HAgl+hM/WPr6uE00HzstM0+rPq1obcAOYgjiltXU8n7Fa PTGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Hzt+iDud; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v13si753997pgr.282.2019.07.09.19.45.46; Tue, 09 Jul 2019 19:46:02 -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=@google.com header.s=20161025 header.b=Hzt+iDud; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725993AbfGJCoG (ORCPT + 99 others); Tue, 9 Jul 2019 22:44:06 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:42749 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725866AbfGJCoG (ORCPT ); Tue, 9 Jul 2019 22:44:06 -0400 Received: by mail-pl1-f193.google.com with SMTP id ay6so396269plb.9 for ; Tue, 09 Jul 2019 19:44:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:user-agent:mime-version; bh=6+LJGvw+qjKoO8SZDZ3CnbeCqyYBeV92bc9prl1ddmQ=; b=Hzt+iDudzrsOkLAbFzQPF4ucXk+e+dS1MtkefrhpjARbtkPySZkO4PjJ7X3K7n/IER 34d0otLaIpDweuSre9qtRGsTKofIMhe7/neLDAE+Uas0A5V6pbK3jXaPX4K2Pjo67Uj4 wU1NifVOAgDX3xJYBlCIE9psPsRdF7IFzc4+COT5iDph1XtFkFhNvPKOUoPI+IK19q0E ivRkw7BrYOe/uUCpgWKtHcVzZFbAUl/wlErOctpAreBNdXzAyVcMFcEPmr1SuWteS2kQ NkPvfb3d2WUcxttWq6JQzdUc+jJQLMMMVhI58SZaOk1h8x5JyDnPuidFd2KGjKLdNnve 4N5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:user-agent :mime-version; bh=6+LJGvw+qjKoO8SZDZ3CnbeCqyYBeV92bc9prl1ddmQ=; b=dmzYB8TL2Mw4NkTJfXvJCV3fJ77izNH/o9PZu1jP8o+mbQGKSc6e2pc63SeX27PoOg WxYgne6VLKoHA/Tj1i8D/P8DsxJIpvUDtv6F+75+/314zE5R3QNJDvU4aGAprSSVmTZc sBUBnFivta7qviksdoxto/UPWYEEl+EAkDkcatFhQUKYiU0jPAlP/q5gZwPPXuGGP4AK 5CaOTtw3HC79u3MdpWx7pB8/6UQf0FhlJ9HAIftYim/msC0pb8CN1ew7wlL6Qi7Z5VkP 5R1O1Yi9F92K2InLAiqaXdsx+7kolzQ62Y6dgwRbu8x9DKGrKujeibmHmxWfFG6TNIJG Za1A== X-Gm-Message-State: APjAAAVdGMSd98Gj4UzX8B1U/MqSWLQvK5iSpoxqkEOBh6Fd+LhV1zpp REzyW8kumjNCnDichIeHPuw5Zw== X-Received: by 2002:a17:902:e613:: with SMTP id cm19mr33894730plb.299.1562726644795; Tue, 09 Jul 2019 19:44:04 -0700 (PDT) Received: from [2620:15c:17:3:3a5:23a7:5e32:4598] ([2620:15c:17:3:3a5:23a7:5e32:4598]) by smtp.gmail.com with ESMTPSA id o2sm349868pgp.74.2019.07.09.19.44.04 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 09 Jul 2019 19:44:04 -0700 (PDT) Date: Tue, 9 Jul 2019 19:44:03 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Ingo Molnar , Thomas Gleixner cc: Tom Lendacky , linux-kernel@vger.kernel.org, x86@kernel.org Subject: [patch] x86/boot: Fix memory leak in default_get_smp_config() Message-ID: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- arch/x86/kernel/mpparse.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/mpparse.c b/arch/x86/kernel/mpparse.c index f1c5eb99d445..7a7055056b0d 100644 --- a/arch/x86/kernel/mpparse.c +++ b/arch/x86/kernel/mpparse.c @@ -547,17 +547,15 @@ void __init default_get_smp_config(unsigned int early) * 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(unsigned int early) /* * Only use the first configuration found. */ - +out: early_memunmap(mpf, sizeof(*mpf)); }