Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3002428ybi; Mon, 17 Jun 2019 14:26:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqwN1kIvMx5P5MLPRG4f+4poUsKnV39DOcO0I/hi1FQTAWAUnOcWtmiGczgkG11aLyp+Josr X-Received: by 2002:a17:90b:8d6:: with SMTP id ds22mr1121039pjb.143.1560806798512; Mon, 17 Jun 2019 14:26:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560806798; cv=none; d=google.com; s=arc-20160816; b=WeY1pSuQxa6D8xlItGsXHPSYFp6vjI4b+wbfFCOVbui/QGbbHBXqINx7gzSD2B2krB bll/sekgTXpjwTYgI5CS4OrL4I1zJWcRmtAYG5BKNEPvfqFPEfGkSS8x96CAHKCXnpuS f7xhteu8aP+XgyMdRNaTJ2ANDWacrqFDew2q8phy9tMjM1+6w5du3itOI/WOpi2zBpfi Oxdc7PMBjk140Q7W7XXAIGTDuBChla3zPwDh9Dq4Kj3zy22loVVPlplhTTyDuiKxpxF3 9jWksJHYQ87wktat1xNkL2+17UH5I1Iy0pB6ZJdr/Ke1343t6tC3J2qkCDfI6ife3y08 F8/w== 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=hr/6aU4sDzoq7sCFvbPtuya1hLxGtHf5SKme94Q1B6Y=; b=fKZjr4IkiacnFpk7Dgg5KpUDeQBEKVzW2OIqlvORWu/Q2ig10JDeqGIS9SFIJ9A7nl BVa//6UvgEC0cQbilBOvqNDFQfH5YcyHeUMrwk8YUE13Vk+so4hxThvab0kEAS0tjiWO A+on5bipXEOfYris+DadSff6QV54DcA4gVznT48HIsZG+WfgOI957yEkX6ywGVpwdizD ZUQbeZCpocaoDw21XdR/lSIK0aTtYZDg277fHo9zPraXN7e488aH+xyYr7PrFphQkxFL /HGjqncI5t9x7z0dYCyj29ilf732FY4Ol9jzat7UaBf//7mbSFWxBliI9s8tjGV7oQum olNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rABUamYi; 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 l1si11683455pgm.391.2019.06.17.14.26.23; Mon, 17 Jun 2019 14:26:38 -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=rABUamYi; 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 S1730084AbfFQVZc (ORCPT + 99 others); Mon, 17 Jun 2019 17:25:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:51666 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729704AbfFQVZa (ORCPT ); Mon, 17 Jun 2019 17:25:30 -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 9C58520657; Mon, 17 Jun 2019 21:25:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560806730; bh=fAdnBziSJffBYuKkdBsMDxs4Ewy2DtT/7aKScd6MlMg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rABUamYi/fgyR8G6nFxht1hSa7VewI/iA4uHG6CDrFJAh88t4ZyvpdaCWjUNyd8vc dDtSXLhAWXiTOCHvMgt2rEP/FSF4TvBEUU5MvAW8jTie7oKLquTju1go4LA7NKXLgB 32tJF5GMqZDOpqwLzZaUvU6fxyMB2VZGgqWLlOXc= 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.19 38/75] arm64/mm: Inhibit huge-vmap with ptdump Date: Mon, 17 Jun 2019 23:09:49 +0200 Message-Id: <20190617210754.255442955@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190617210752.799453599@linuxfoundation.org> References: <20190617210752.799453599@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 8080c9f489c3..0fa558176fb1 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -921,13 +921,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 *pudp, phys_addr_t phys, pgprot_t prot) -- 2.20.1