Received: by 10.213.65.68 with SMTP id h4csp850778imn; Wed, 14 Mar 2018 01:50:29 -0700 (PDT) X-Google-Smtp-Source: AG47ELtZ0muJYD2Cn8pJ1Jn8B33Tmg9tcV3PajRToW1qd6YHjxXONWmHlRAZ7YV67npa2Vv5iGa1 X-Received: by 2002:a17:902:9a05:: with SMTP id v5-v6mr3325784plp.69.1521017429875; Wed, 14 Mar 2018 01:50:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521017429; cv=none; d=google.com; s=arc-20160816; b=cZgmNxMIC/Zz3SrxFipxx4yQ0Mh+gOUx7Q5E1ItmnOVhJeMHaxh9B/o9rrsOtKeLAZ kVj+d1J5RIonhv0jm2BJHWa2tCMRVK1Cl6P/uI8EF8O96eQZGFeaB4eZReJfkNig8KSR w6u5CyzGTs//WcXmx8uee2bHJspci+qJtzQzfxpkhqUw3EyBE8Y7PP6V/jcBpNk1Duud 5++tOXo5dp1NONRQxYPOQiuZMu1bjTv+wxonOeZI+Q8H8P6wjtONTVKUjcH4b3ckNfku 4kjrNTILEbkbPUmTfzSPC9iw3Y2IoYDdw5OpyTaJDuWCRHA+lFFLi/GeyZM52q/yS2ss jNjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=kCn93DkU5GpFy857IVyk2awTuNJhcmWJ1MtjYBOXoIc=; b=X6KB6zY6Qwnv4dusMcD0N6UM2HeMMKzdqP4GZJWpmnndLcCKgmYvFzC4Yr+QeF30DT qb+rPNiWmHpEFe+i92C6h9OZxjbI4RiDathM5wnu+vGUIIupBbR8Lvvkv7XmoCJbpZWH czK7U4n6x7GRXjjPsgQCKRouhhsOxV2DlibdlXTFhzX7Q4Ci04ErFJyCjK/ZeAZqHbro GZHSgO0wL7Ou87wkRdwkh6sXNpzWpwBgm/3S8gYR2kqvT2gkqIMX2LJtr1pN/0qWkddz hkmTjacFuooPblItpA2ectTO9tenEqOnpuLNg/EUnTwtrS9FhdOSWMWZrlLVHSDMAuJx cHWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=F2ga2Wxy; dkim=pass header.i=@codeaurora.org header.s=default header.b=TeJpI14P; 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 o15si1591409pgd.23.2018.03.14.01.50.15; Wed, 14 Mar 2018 01:50:29 -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=@codeaurora.org header.s=default header.b=F2ga2Wxy; dkim=pass header.i=@codeaurora.org header.s=default header.b=TeJpI14P; 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 S1753471AbeCNItF (ORCPT + 99 others); Wed, 14 Mar 2018 04:49:05 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:59008 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753418AbeCNIs7 (ORCPT ); Wed, 14 Mar 2018 04:48:59 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 17FEE60858; Wed, 14 Mar 2018 08:48:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521017339; bh=wTZVOxSLTNRRn1rwz2sMDTZVvRwAVp5H16e5T/d2FQc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F2ga2Wxyf8wXFXe2rsm83uPvXiwVIzDPJMZn09Srg+CNNAlEOFljRUlhbOQmVYlM2 1c7ywxIpbW+6OPnybIulZ94lulFOWNvDP5beDZM1h6a9dWQ4JyXuvLCZ/Ymoc0jFS4 cHqh0FtrW3hx1TfAqosl1pccbcFYre9mU4g9036k= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from cpandya-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: cpandya@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id E059A609F3; Wed, 14 Mar 2018 08:48:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521017338; bh=wTZVOxSLTNRRn1rwz2sMDTZVvRwAVp5H16e5T/d2FQc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TeJpI14Pi/A/pvILvuAbsU5S8EwUdud0xVMbk9daN7fgHi8HGCL9JAnqH5ABF4oxl /vMxuaxTyghFbBCesESeL87/UwFqpZDcHIg+DqGlMQdLBg3+kIZA8aP4B6DXPhy1gG kocl+XtW8g3GXe4dxFcCbesZnVJrVr0whnjYVIYU= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org E059A609F3 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=cpandya@codeaurora.org From: Chintan Pandya To: catalin.marinas@arm.com, will.deacon@arm.com, arnd@arndb.de Cc: mark.rutland@arm.com, ard.biesheuvel@linaro.org, marc.zyngier@arm.com, james.morse@arm.com, kristina.martsenko@arm.com, takahiro.akashi@linaro.org, gregkh@linuxfoundation.org, tglx@linutronix.de, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, akpm@linux-foundation.org, toshi.kani@hpe.com, Chintan Pandya Subject: [PATCH v1 3/4] arm64: Fix the page leak in pud/pmd_set_huge Date: Wed, 14 Mar 2018 14:18:24 +0530 Message-Id: <1521017305-28518-4-git-send-email-cpandya@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1521017305-28518-1-git-send-email-cpandya@codeaurora.org> References: <1521017305-28518-1-git-send-email-cpandya@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While setting huge page, we need to take care of previously existing next level mapping. Since, we are going to overrite previous mapping, the only reference to next level page table will get lost and the next level page table will be zombie, occupying space forever. So, free it before overriding. Signed-off-by: Chintan Pandya --- arch/arm64/mm/mmu.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 8c704f1..c0df264 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -32,7 +32,7 @@ #include #include #include - +#include #include #include #include @@ -45,6 +45,7 @@ #include #include #include +#include #define NO_BLOCK_MAPPINGS BIT(0) #define NO_CONT_MAPPINGS BIT(1) @@ -939,6 +940,9 @@ int pud_set_huge(pud_t *pudp, phys_addr_t phys, pgprot_t prot) return 0; BUG_ON(phys & ~PUD_MASK); + if (pud_val(*pud) && !pud_huge(*pud)) + free_page((unsigned long)__va(pud_val(*pud))); + set_pud(pudp, pfn_pud(__phys_to_pfn(phys), sect_prot)); return 1; } @@ -953,6 +957,9 @@ int pmd_set_huge(pmd_t *pmdp, phys_addr_t phys, pgprot_t prot) return 0; BUG_ON(phys & ~PMD_MASK); + if (pmd_val(*pmd) && !pmd_huge(*pmd)) + free_page((unsigned long)__va(pmd_val(*pmd))); + set_pmd(pmdp, pfn_pmd(__phys_to_pfn(phys), sect_prot)); return 1; } -- Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc., is a member of Code Aurora Forum, a Linux Foundation Collaborative Project