From patchwork Tue Jul 20 07:37:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Liang Wang X-Patchwork-Id: 12387653 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.0 required=3.0 tests=BAYES_00, CHARSET_FARAWAY_HEADER,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6EF3C636C8 for ; Tue, 20 Jul 2021 07:39:24 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9340961165 for ; Tue, 20 Jul 2021 07:39:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9340961165 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=BJpjTriQcnZ6sC1kOVAf8S5hLfh2P5IsV8E2wB6cBac=; b=w1WEj324YAV+PB cUDupdI7L63ITVUvuU7H7ZSVGDLQRwJVACYXlgjBwcE0r1IfLrP6P6sX98a58h2h8u7Ka8FCDVf7a E4QaeQrRhdwaW0EtMwIXoloT5kIaev00kFZbfvG+oVlv2GLcuK7ob2jj5yyzyxf+iejgNRVeNXNrt /ZJ1/VjM9k7PDzS9+rM39qTokRuYdiR4y38MubjXaaW9ul+a7ykzIBbFnSNnc++uQCXCt3KKICCTx TIPIMLh/q+hIWqAa4w/naad46KCdmXpzgIAMsEClbWs5ajkzbgl8K3/dPD60io6Rt/p3ArmChBV8a Qp+l5WitqM7ZHvZwkeNQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m5kJk-00C6wT-Ju; Tue, 20 Jul 2021 07:37:28 +0000 Received: from szxga01-in.huawei.com ([45.249.212.187]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m5kJg-00C6ur-27 for linux-arm-kernel@lists.infradead.org; Tue, 20 Jul 2021 07:37:26 +0000 Received: from dggeme752-chm.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4GTVnt4YJNzZqrn; Tue, 20 Jul 2021 15:33:54 +0800 (CST) Received: from dggeme756-chm.china.huawei.com (10.3.19.102) by dggeme752-chm.china.huawei.com (10.3.19.98) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Tue, 20 Jul 2021 15:37:16 +0800 Received: from dggeme756-chm.china.huawei.com ([10.6.80.68]) by dggeme756-chm.china.huawei.com ([10.6.80.68]) with mapi id 15.01.2176.012; Tue, 20 Jul 2021 15:37:16 +0800 From: "wangliang (C)" To: "palmerdabbelt@google.com" , "mcgrof@kernel.org" , "linux-kernel@vger.kernel.org" , "gregkh@linuxfoundation.org" , "linux@armlinux.org.uk" , "linux-arm-kernel@lists.infradead.org" CC: "stable@vger.kernel.org" , "Wangle (RTOS FAE)" , "Chenxin (RTOS)" , Nixiaoming , "Wangkefeng (OS Kernel Lab)" Subject: =?eucgb2312_cn?b?tPC4tDogW1BBVENIXSBhcm06bW1hcDogZml4IHBoeXNpY2FsIGFkZHJl?= =?eucgb2312_cn?b?c3Mgb3ZlcmZsb3cgd2hlbiBDT05GSUdfQVJNX0xQQUU9eQ==?= Thread-Topic: [PATCH] arm:mmap: fix physical address overflow when CONFIG_ARM_LPAE=y Thread-Index: AQHXeXUt7ahQu+mGnUGYPTbmKJayAqtLgAsA Date: Tue, 20 Jul 2021 07:37:16 +0000 Message-ID: <133369ed88a54e40a3ebbc667763f5b1@huawei.com> References: <20210715123012.61215-1-wangliang101@huawei.com> In-Reply-To: <20210715123012.61215-1-wangliang101@huawei.com> Accept-Language: en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.67.101.54] MIME-Version: 1.0 X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210720_003724_624565_815F2F71 X-CRM114-Status: GOOD ( 12.80 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org add arm list -----邮件原件----- 发件人: wangliang (C) 发送时间: 2021年7月15日 20:30 收件人: palmerdabbelt@google.com; mcgrof@kernel.org; linux-kernel@vger.kernel.org; gregkh@linuxfoundation.org; linux@armlinux.org.uk 抄送: stable@vger.kernel.org; wangliang (C) ; Wangle (RTOS FAE) ; Chenxin (RTOS) ; Nixiaoming 主题: [PATCH] arm:mmap: fix physical address overflow when CONFIG_ARM_LPAE=y When the CONFIG_ARM_LPAE is enabled on arm32, the physical address may exceed 32 bits. In the devmem_is_allowed function, the physical address is obtained through displacement of the physical page number.Without explicit translation, the physical address may overflow and be truncated. Use the PFN_PHYS macro to fix this bug. This bug was initially introduced in v2.6.37 with commit:087aaffcdf9c91. In v5.10, this code has been modified by commit:527701eda5f196. Fixes: 527701eda5f196 ("lib: Add a generic version of devmem_is_allowed") Fixes: 087aaffcdf9c91 ("ARM: implement CONFIG_STRICT_DEVMEM by disabling access to RAM via /dev/mem") Cc: stable@vger.kernel.org # v2.6.37 Signed-off-by: Liang Wang --- lib/devmem_is_allowed.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/devmem_is_allowed.c b/lib/devmem_is_allowed.c index c0d67c541849..60be9e24bd57 100644 --- a/lib/devmem_is_allowed.c +++ b/lib/devmem_is_allowed.c @@ -19,7 +19,7 @@ */ int devmem_is_allowed(unsigned long pfn) { - if (iomem_is_exclusive(pfn << PAGE_SHIFT)) + if (iomem_is_exclusive(PFN_PHYS(pfn))) return 0; if (!page_is_ram(pfn)) return 1; -- 2.32.0