Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp3643779ioa; Tue, 26 Apr 2022 07:26:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxD7rHjENvBvQ1Qn038pPnqO5z1hpfh6QMd71aSulcVVRXL/tyKL4Z0p4Og6jmsaYoyYEen X-Received: by 2002:a05:6402:27cb:b0:423:d386:42be with SMTP id c11-20020a05640227cb00b00423d38642bemr25104786ede.227.1650983176751; Tue, 26 Apr 2022 07:26:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650983176; cv=none; d=google.com; s=arc-20160816; b=CBSKzYNzLtdYEoi0BDYgiVR8Oj/OtVnphN66rYCJ5MnyJ+GIWlX/6aO1Eoo32N6v6h xnfYL19kvHNTAGgGq+M3FycoSiREl9pEJoKQELswOcccyIKWyQY3ucaOFOmr8w8MYHeb 1SWd8tiOAUR7vMBMjR8Gg8RVqkIIy1+54LlFgnEbC5SihmIXpsYgkejpTWvkZMEfmn3A /l+bLHN3HYF6BSCUnUtEUnKK0LlxNCgtnzSTr46QERbc/cF65NJ2cEPYak1VTNhKCBp4 xgfXQku8jMnpM6x++iGiKBCnkaw5SWawFniDyCAMGiMCJz5smGZxqq7z5PqrHrsJK4Uk wgEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=o7uuD0NF72gXhaLxnfB0Ehoi7UGvRjVqZIZ6gKu96Gg=; b=zt0ukwVgTeVIpkfT9OqhqEL/YjMX3f3F6AJKx5rL1f+KV/8hcSdHFFKIlFaenfKcNL +xKQNZQ+VyyAqsb1OLfG8tDk3MBnmNDaqpTCOHlWB+F0E0FO80mXrZtxor4UTN/7S9Rk C6TLR5S9iFvcI2kzrmF0Bk/dAhigIg9Npw5tuthh5HJ33rmQG5Y0ecvCwZr0SmZl/H2i Me+h8J4AixG0PIPage1QTLmDzkc+cll+T3vqYikvwp7lLcMh9fMMM21a5FMtNZE9NbBv fHqDC/0F8i2eAIUEQQGa+YCvd5IbOWlzBPv9xNVxloFJn7arU2upqOq3QjQT/1rAriAx qaow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RSejPBqG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f13-20020a0564021e8d00b0042600135621si882448edf.546.2022.04.26.07.25.52; Tue, 26 Apr 2022 07:26:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RSejPBqG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347110AbiDZJJ6 (ORCPT + 99 others); Tue, 26 Apr 2022 05:09:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346533AbiDZIuJ (ORCPT ); Tue, 26 Apr 2022 04:50:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 720D514C3F0; Tue, 26 Apr 2022 01:38:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9AA3160C4A; Tue, 26 Apr 2022 08:38:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A023AC385A4; Tue, 26 Apr 2022 08:38:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650962303; bh=FJrOSWDpdzwdtuPtPjQ59biReYwoyVznx2mr8ink2CE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RSejPBqGC5hcrnzIYv/vrzlOXnZdREzYEzC2EUuCUSbBr75XoIPlX9714qBV/JSKp oiSZj4JddVEAlqi3VKu8kszrukCx6DPbbjAMaQb6Bf7yLGwVh8AQtUbFLiC2P5q30I a5WCPkF8K2q7Vpb+jrirh7wc0PL5DZTptGu+2KZ0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Qian Cai , Muchun Song , Will Deacon , Sasha Levin Subject: [PATCH 5.15 052/124] arm64: mm: fix p?d_leaf() Date: Tue, 26 Apr 2022 10:20:53 +0200 Message-Id: <20220426081748.781082477@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220426081747.286685339@linuxfoundation.org> References: <20220426081747.286685339@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Muchun Song [ Upstream commit 23bc8f69f0eceecbb87c3801d2e48827d2dca92b ] The pmd_leaf() is used to test a leaf mapped PMD, however, it misses the PROT_NONE mapped PMD on arm64. Fix it. A real world issue [1] caused by this was reported by Qian Cai. Also fix pud_leaf(). Link: https://patchwork.kernel.org/comment/24798260/ [1] Fixes: 8aa82df3c123 ("arm64: mm: add p?d_leaf() definitions") Reported-by: Qian Cai Signed-off-by: Muchun Song Link: https://lore.kernel.org/r/20220422060033.48711-1-songmuchun@bytedance.com Signed-off-by: Will Deacon Signed-off-by: Sasha Levin --- arch/arm64/include/asm/pgtable.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 08363d3cc1da..ed57717cd004 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -535,7 +535,7 @@ extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, PMD_TYPE_TABLE) #define pmd_sect(pmd) ((pmd_val(pmd) & PMD_TYPE_MASK) == \ PMD_TYPE_SECT) -#define pmd_leaf(pmd) pmd_sect(pmd) +#define pmd_leaf(pmd) (pmd_present(pmd) && !pmd_table(pmd)) #define pmd_bad(pmd) (!pmd_table(pmd)) #define pmd_leaf_size(pmd) (pmd_cont(pmd) ? CONT_PMD_SIZE : PMD_SIZE) @@ -625,7 +625,7 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd) #define pud_none(pud) (!pud_val(pud)) #define pud_bad(pud) (!pud_table(pud)) #define pud_present(pud) pte_present(pud_pte(pud)) -#define pud_leaf(pud) pud_sect(pud) +#define pud_leaf(pud) (pud_present(pud) && !pud_table(pud)) #define pud_valid(pud) pte_valid(pud_pte(pud)) static inline void set_pud(pud_t *pudp, pud_t pud) -- 2.35.1