Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3005491ybi; Mon, 17 Jun 2019 14:30:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqxqUU08CmmjEWRZF/S/XjRFD5l2tHFcIg8ZMmV0vi10mjm/uySZPBM48EjhGM27zmOWzE7i X-Received: by 2002:a17:902:b495:: with SMTP id y21mr108585073plr.243.1560807052095; Mon, 17 Jun 2019 14:30:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560807052; cv=none; d=google.com; s=arc-20160816; b=N36fkXOXeDZLclzTKQBfPe30qkPg0fpD5F8CV0wY/plVVJb1VNAe2KH5y3V72A2Eqt pE2XYVpL6aut5jlTCChcpspWRtUYA+v0w4W6iICU3cFalYkgOj4+a02xALQZGmbSNLfF zL8j5OADNlRshb4Bo9gPhr/WDOmQDgtg2/4qldZvYaglnj//P0zMrd2Zj7spZj5zhXgJ 4poAlRyREcakmn8WFNBup57Az0CCR5mHsz+4zQjEyTSnRu9Xuz6rnH1Ed2iBkT88aiSV g6Fu5RiW4J+jDVfvvcOJlLEF+PMfIXQZmNNewKyxzEMUVQszXRD3JoCPqzlPUgTFXqA4 YA5A== 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=xUi0PcP+BVUStUm+vnesM2pMW7VJDPiiVzMuUiE3f8o=; b=aboK1otdLjv4HO5xpYwwJonBtVNS5SLXc8uq2Gud1FF7cZSj+Kla+d+EOA27xb+y4E eHlGm+kkRs9+1F1+jYn1Aai6i59CiHwbckpNTzsUCucDV1f3kUJCqhrOleaqcaWN7hpJ qyEoMqnjyVpHqyq+35ZjlNNZ7pVrbD84kusnmtXVn/tNYvL4s+JVkHh8ZtGYQtrBETNc vllWAxm0t8F4C/sZLG+AVFONmVdwarA+n4SWu3zEmGYxAPTolcsBV8VENfYzCBdBZy9V zOVmLM7kK1TiZW5eMV3TZXQbx2EBg3vcnH8wko2oDifxtyS48C53K7JFBoP1Nm503/zz 7rhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HL7HDJJo; 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 d67si10110057pgc.62.2019.06.17.14.30.37; Mon, 17 Jun 2019 14:30:52 -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=HL7HDJJo; 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 S1729669AbfFQVaR (ORCPT + 99 others); Mon, 17 Jun 2019 17:30:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:57526 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730333AbfFQVaP (ORCPT ); Mon, 17 Jun 2019 17:30:15 -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 98352204FD; Mon, 17 Jun 2019 21:30:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560807015; bh=ZJEh321ZjSB2kRnIHaSQrvNPnNFl8ZTzTjIEDmcabaI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HL7HDJJoa0X5//PZtaY881fU4Em8vJd6WIhO5WZPlsiUPy1jnoqJ3anCp7cf8n5oz GMvLJ5+WgK03k4rtfkifcJ7LUoGCSgAn3+kOcuMJEvNjUbn2sfNhZvxYZOuvSIBdI8 rbE5nmYndPXBWzJ+D47m1OJ6jGWna1yY24DWX4C8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Catalin Marinas , Ard Biesheuvel , Mark Rutland , Anshuman Khandual , Will Deacon , Sasha Levin Subject: [PATCH 4.14 31/53] arm64/mm: Inhibit huge-vmap with ptdump Date: Mon, 17 Jun 2019 23:10:14 +0200 Message-Id: <20190617210750.941334533@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190617210745.104187490@linuxfoundation.org> References: <20190617210745.104187490@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 [ Upstream commit 7ba36eccb3f83983a651efd570b4f933ecad1b5c ] The arm64 ptdump code can race with concurrent modification of the kernel page tables. At the time this was added, this was sound as: * Modifications to leaf entries could result in stale information being logged, but would not result in a functional problem. * Boot time modifications to non-leaf entries (e.g. freeing of initmem) were performed when the ptdump code cannot be invoked. * At runtime, modifications to non-leaf entries only occurred in the vmalloc region, and these were strictly additive, as intermediate entries were never freed. However, since commit: commit 324420bf91f6 ("arm64: add support for ioremap() block mappings") ... it has been possible to create huge mappings in the vmalloc area at runtime, and as part of this existing intermediate levels of table my be removed and freed. It's possible for the ptdump code to race with this, and continue to walk tables which have been freed (and potentially poisoned or reallocated). As a result of this, the ptdump code may dereference bogus addresses, which could be fatal. Since huge-vmap is a TLB and memory optimization, we can disable it when the runtime ptdump code is in use to avoid this problem. Cc: Catalin Marinas Fixes: 324420bf91f60582 ("arm64: add support for ioremap() block mappings") Acked-by: Ard Biesheuvel Signed-off-by: Mark Rutland Signed-off-by: Anshuman Khandual Signed-off-by: Will Deacon Signed-off-by: Sasha Levin --- arch/arm64/mm/mmu.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 6ac0d32d60a5..abb9d2ecc675 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -899,13 +899,18 @@ void *__init fixmap_remap_fdt(phys_addr_t dt_phys) int __init arch_ioremap_pud_supported(void) { - /* only 4k granule supports level 1 block mappings */ - return IS_ENABLED(CONFIG_ARM64_4K_PAGES); + /* + * Only 4k granule supports level 1 block mappings. + * SW table walks can't handle removal of intermediate entries. + */ + return IS_ENABLED(CONFIG_ARM64_4K_PAGES) && + !IS_ENABLED(CONFIG_ARM64_PTDUMP_DEBUGFS); } int __init arch_ioremap_pmd_supported(void) { - return 1; + /* See arch_ioremap_pud_supported() */ + return !IS_ENABLED(CONFIG_ARM64_PTDUMP_DEBUGFS); } int pud_set_huge(pud_t *pud, phys_addr_t phys, pgprot_t prot) -- 2.20.1