From patchwork Sun Sep 24 18:41:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Levin, Alexander \(Sasha Levin\)" X-Patchwork-Id: 114140 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1806578qgf; Sun, 24 Sep 2017 11:43:57 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDAL3N3DYWcdwzUrR3/NYTwBq7p/MnJj8r2y2RptaXIl85Rt6TIkWhYcQRl5dM2yuURQdz0 X-Received: by 10.98.64.212 with SMTP id f81mr5235687pfd.321.1506278637106; Sun, 24 Sep 2017 11:43:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506278637; cv=none; d=google.com; s=arc-20160816; b=ceuGol0Y8g1Y38lbDxk7xHdzQk5POkD+17fU6yK9o97I0vBloWzTShwS7Sq5/NOEZP byDJKeLKL39sEylyiQIt/sK+wumBNXeJKAXwcMM0DX3OOMgS/LnQPbOqfa28sGaEvexZ 0HkIExqbPgpTKY2xzVeGXuiQ82QKHZ7IkYAuF7nuLdkXUo096aiR5wiBLdjyRXt1YoZG kvltGV2DO2qwpMtG/fJyQnmBdGEXUTzlKiwE4vf+oTMPk6AmhIBaf/Dz3LfB/UAPNU82 BMQ5HmA9VW2iv+JcyW1yn4f1ueXNvHpa9CEjwp8mvsO/Og27SCI+TAFbcaw8/DkeKme0 lKUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:dkim-signature :dkim-signature:from:dkim-signature:arc-authentication-results; bh=CDDXsDP3GLbvlD4Ti9gJTorvZFGS29IvkglT7FT9wZU=; b=f7Je1tka8iZNU0iWtER8ABu1T/EcbJsIBRWjTPpknL5vOOZ51azPuSf5e6+y0jWcmx Q6XZMV9XfkreGWpy+tOcz4R4cqlHvDLUhc+piAGkDkQQx0G/+5dXG0kO0zp067sbAt7Q wPxhdwOMnhR79ncESNn/nH2mhnOL5Zb+CBERuhu27/wQSpZvDn8QopM8FRFecihKvtT0 fSkqhu8gBoeiyBDf2Q0iEbb97fJQnAO6svtaxqacGg02TNOEDVrXJDtYqMgunMPz9peR MsZ4vcPqieSTEvQcZJ2QG02JS73ebQkSJZ/DQm5DFcdstMAmV0ZrqFWlMo0DhU5Ha7Al GM7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@verizon.com header.s=corp header.b=Db+q7WVe; dkim=fail header.i=@verizon.com header.s=corp header.b=RfFqGzlm; dkim=fail header.i=@verizon.com header.s=corp header.b=vGNQ6Fpi; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=verizon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h4si3003187pgs.34.2017.09.24.11.43.56; Sun, 24 Sep 2017 11:43:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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=@verizon.com header.s=corp header.b=Db+q7WVe; dkim=fail header.i=@verizon.com header.s=corp header.b=RfFqGzlm; dkim=fail header.i=@verizon.com header.s=corp header.b=vGNQ6Fpi; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=verizon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752938AbdIXSnz (ORCPT + 8 others); Sun, 24 Sep 2017 14:43:55 -0400 Received: from omzsmtpe01.verizonbusiness.com ([199.249.25.210]:19071 "EHLO omzsmtpe01.verizonbusiness.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752923AbdIXSns (ORCPT ); Sun, 24 Sep 2017 14:43:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1506278628; x=1537814628; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=QXhAbpnm9Uly5vQNNBMTDelBwnqfx8sK/+dNJ7MMEOc=; b=Db+q7WVe6HFb839eHyYZNb3T2YpDp8tKKepv9V8vi6bwkbD7YtdTnxeu 1DsfGVKeDm4WY0sU4xxDFkdkH02CGLueYjJaRRfRH3T97BD7YA2vRJUxY 11BTW4hWqZOtrZFLJUrt1eG2bJrLEhUPETJzOZmlayQNKt14lZlxqU2KG I=; Received: from unknown (HELO fldsmtpi03.verizon.com) ([166.68.71.145]) by omzsmtpe01.verizonbusiness.com with ESMTP; 24 Sep 2017 18:43:41 +0000 From: "Levin, Alexander (Sasha Levin)" Received: from rogue-10-255-192-101.rogue.vzwcorp.com (HELO apollo.verizonwireless.com) ([10.255.192.101]) by fldsmtpi03.verizon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 24 Sep 2017 18:43:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1506278620; x=1537814620; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=QXhAbpnm9Uly5vQNNBMTDelBwnqfx8sK/+dNJ7MMEOc=; b=RfFqGzlmL/84qiQtkKrb3bM1Gh/xw9DWlbsQsp574iwYzAvk8zYyfsa6 7ez0UbYRUCp9ZmHQe8RwWOqEJhmoCfiogJbDaTke4gA/pYF77NPVmT6iS qxPgFn+wQ9bdaXyNty3xhdEYOkO4BgfRJPv66fnDYSLARQqeZkjgTa5cG 8=; Received: from discovery.odc.vzwcorp.com (HELO mercury.verizonwireless.com) ([10.255.240.25]) by apollo.verizonwireless.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 24 Sep 2017 14:43:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1506278621; x=1537814621; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=QXhAbpnm9Uly5vQNNBMTDelBwnqfx8sK/+dNJ7MMEOc=; b=vGNQ6FpiJxVT2L9TvUzBD81v/PbvB4JHhYAqogYn5Vy+JoJbYP8Wdv+q mn/NFA5KhY6PX/fGVRrAj9vkxTWhM0ke53GMi6Ma59Q4H7CXX8lh8Zrak 7W+A5gk4ijGCRoOvJYyAIxUkck7MlqWVCtp3Jzf+r41HL2OUaoZphERz0 8=; X-Host: discovery.odc.vzwcorp.com Received: from casac1exh002.uswin.ad.vzwcorp.com ([10.11.218.44]) by mercury.verizonwireless.com with ESMTP/TLS/AES128-SHA256; 24 Sep 2017 18:43:40 +0000 Received: from scwexch19apd.uswin.ad.vzwcorp.com (153.114.130.38) by CASAC1EXH002.uswin.ad.vzwcorp.com (10.11.218.44) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 24 Sep 2017 11:43:39 -0700 Received: from OMZP1LUMXCA18.uswin.ad.vzwcorp.com (144.8.22.196) by scwexch19apd.uswin.ad.vzwcorp.com (153.114.130.38) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Sun, 24 Sep 2017 11:43:38 -0700 Received: from OMZP1LUMXCA17.uswin.ad.vzwcorp.com (144.8.22.195) by OMZP1LUMXCA18.uswin.ad.vzwcorp.com (144.8.22.196) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Sun, 24 Sep 2017 13:43:31 -0500 Received: from OMZP1LUMXCA17.uswin.ad.vzwcorp.com ([144.8.22.195]) by OMZP1LUMXCA17.uswin.ad.vzwcorp.com ([144.8.22.195]) with mapi id 15.00.1263.000; Sun, 24 Sep 2017 13:43:31 -0500 To: "gregkh@linuxfoundation.org" CC: "stable@vger.kernel.org" Subject: [GIT PULL for-4.9 86/96] arm64: kasan: avoid bad virt_to_pfn() Thread-Topic: [GIT PULL for-4.9 86/96] arm64: kasan: avoid bad virt_to_pfn() Thread-Index: AQHTNWTNlJW/DzMyoUqZ7tdX6qwfrQ== Date: Sun, 24 Sep 2017 18:41:58 +0000 Message-ID: <20170924184130.29445-87-alexander.levin@verizon.com> References: <20170924184130.29445-1-alexander.levin@verizon.com> In-Reply-To: <20170924184130.29445-1-alexander.levin@verizon.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.144.60.250] MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Mark Rutland [ Upstream commit b0de0ccc8b9edd8846828e0ecdc35deacdf186b0 ] 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: Sasha Levin --- arch/arm64/mm/kasan_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.11.0 diff --git a/arch/arm64/mm/kasan_init.c b/arch/arm64/mm/kasan_init.c index 757009daa9ed..ff43da269fe8 100644 --- 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