From patchwork Mon May 6 14:32:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 163412 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:81:0:0:0:0 with SMTP id l1csp64239ilm; Mon, 6 May 2019 07:47:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqxubZXpxDWS8JaWXF4O3Q3za8sIiVFVrdDZ1ZAmhw3/nHmGvSy8RpQDOJ9FOGm01WgGIjCk X-Received: by 2002:a17:902:9686:: with SMTP id n6mr33274103plp.282.1557154038775; Mon, 06 May 2019 07:47:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557154038; cv=none; d=google.com; s=arc-20160816; b=ZUMXH+SkPStvv0B4TrXg/RtHMqbR95OrtVil7TyaZH/KTWshG6WL4BWg6tGssATuVc TYjV0O8s7dqtQ8zSFACrdKWVwcsoGsUqrr23jiOMiBXPPPgb69HP21jBJQu0bA25mzyB n+6k3K9EjBmuskQHBEOh/6wxAMvNsDM6qSH4pFgi1x6XlmfnIx3GQTlngX9blDIoyqfQ p0/et1/UH2A2VNo4h1utH8dT9z1rzvQctKsqQhBrj2/53EQ0G+3RjoD4RLD4I6qw+PrV /9bm4MZsBINZIEWH4HWAJIdDMss+e+0rYwWzbOa4Hssj0RRj8SyGyUE9dR5xDA8Zg6Be TV0w== 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=Fcr/aSf/skuIpB8gJx1ZUjLdosGsDWh+qhK+ZzmZgfs=; b=b3MDdok1TpcK9VfINd/HUdomYxPie1q56Y8eWaXvAdxyGKrF/nZCORtfcdZoUfEHis zNC3FsoxI+15y0zr4AzfXtN5Jw+HkG5jeKaSHQEaHBLE5HTr4uFVyaqGviWNLnM3imRg W6Y2XgUfJqaOdGbSXDV0GuwDqe7zYCKTGuLpfpWG3LAJqAAW8Pr1+J8FgeJCld4+ao7V Hu9z8wkfj0YYKt2OqhAWU0GxAzLFuec4wh1acbtrR6d7OTXYEbwR7BnezH0diSiBdfXb +QrfXYsvqWRnGJX+t6Kum4QyruB2hysMyM82ZjhDKZuTBqCo0JswmVhD7fzaP1pxTf29 lrOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="obu/ygWj"; 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 23si14742307pfh.2.2019.05.06.07.47.17; Mon, 06 May 2019 07:47:18 -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="obu/ygWj"; 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 S1728771AbfEFOrQ (ORCPT + 30 others); Mon, 6 May 2019 10:47:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:46084 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729267AbfEFOrN (ORCPT ); Mon, 6 May 2019 10:47:13 -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 64F0720449; Mon, 6 May 2019 14:47:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557154032; bh=ZWme/I8XL5DLX6KM91dRGi4a4dE7wwzF7MHXMGfGN9E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=obu/ygWjkqXN3BWalGEjXQYSsY6ht/3WCtLYa2Yusn9fiejiAhcrZUPLqn54yzLMy f5dLd+u1/3P6WgsB5HFEXi2npGfQz1YyfT1Sk0LnHyfoNm2ozxt3yXHoNygd9UqWvT 7zV78hgU1N8P5ZyVAzq1ugt9N54uiqfnRbY0XgGU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Catalin Marinas , Will Deacon , Laura Abbott , Mark Rutland , Andrey Konovalov Subject: [PATCH 4.9 13/62] arm64: kasan: avoid bad virt_to_pfn() Date: Mon, 6 May 2019 16:32:44 +0200 Message-Id: <20190506143052.234114233@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190506143051.102535767@linuxfoundation.org> References: <20190506143051.102535767@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mark Rutland commit b0de0ccc8b9edd8846828e0ecdc35deacdf186b0 upstream. Booting a v4.11-rc1 kernel with DEBUG_VIRTUAL and KASAN enabled produces the following splat (trimmed for brevity): [ 0.000000] virt_to_phys used for non-linear address: ffff200008080000 (0xffff200008080000) [ 0.000000] WARNING: CPU: 0 PID: 0 at arch/arm64/mm/physaddr.c:14 __virt_to_phys+0x48/0x70 [ 0.000000] PC is at __virt_to_phys+0x48/0x70 [ 0.000000] LR is at __virt_to_phys+0x48/0x70 [ 0.000000] Call trace: [ 0.000000] [] __virt_to_phys+0x48/0x70 [ 0.000000] [] kasan_init+0x1c0/0x498 [ 0.000000] [] setup_arch+0x2fc/0x948 [ 0.000000] [] start_kernel+0xb8/0x570 [ 0.000000] [] __primary_switched+0x6c/0x74 This is because we use virt_to_pfn() on a kernel image address when trying to figure out its nid, so that we can allocate its shadow from the same node. As with other recent changes, this patch uses lm_alias() to solve this. We could instead use NUMA_NO_NODE, as x86 does for all shadow allocations, though we'll likely want the "real" memory shadow to be backed from its corresponding nid anyway, so we may as well be consistent and find the nid for the image shadow. Cc: Catalin Marinas Cc: Will Deacon Acked-by: Laura Abbott Signed-off-by: Mark Rutland Signed-off-by: Will Deacon Signed-off-by: Andrey Konovalov Signed-off-by: Greg Kroah-Hartman --- arch/arm64/mm/kasan_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/arm64/mm/kasan_init.c +++ b/arch/arm64/mm/kasan_init.c @@ -153,7 +153,7 @@ void __init kasan_init(void) clear_pgds(KASAN_SHADOW_START, KASAN_SHADOW_END); vmemmap_populate(kimg_shadow_start, kimg_shadow_end, - pfn_to_nid(virt_to_pfn(_text))); + pfn_to_nid(virt_to_pfn(lm_alias(_text)))); /* * vmemmap_populate() has populated the shadow region that covers the