From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com ([217.140.101.70]:38142 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751862AbdJFSO5 (ORCPT ); Fri, 6 Oct 2017 14:14:57 -0400 Date: Fri, 6 Oct 2017 19:13:22 +0100 From: Mark Rutland To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Catalin Marinas , Will Deacon , Laura Abbott , Sasha Levin Subject: Re: [PATCH 4.9 086/104] arm64: kasan: avoid bad virt_to_pfn() Message-ID: <20171006181322.GA19635@leverpostej> References: <20171006083840.743659740@linuxfoundation.org> <20171006083853.610785662@linuxfoundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171006083853.610785662@linuxfoundation.org> Sender: stable-owner@vger.kernel.org List-ID: Hi Greg, On Fri, Oct 06, 2017 at 10:52:04AM +0200, Greg Kroah-Hartman wrote: > 4.9-stable review patch. If anyone has any objections, please let me know. I'm a little confused as to why this is being backported, given it wasn't Cc'd stable or marked as a fix. The lm_alias() helper was only introduced in v4.10, and I don't recall seeing that backported. What's going on here? Thanks, Mark. > > ------------------ > > 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 > 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 > >