mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Levin, Alexander (Sasha Levin)" <alexander.levin@verizon.com>
To: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will.deacon@arm.com>,
	"Levin, Alexander (Sasha Levin)" <alexander.levin@verizon.com>
Subject: [PATCH for 4.9 29/39] arm64: kasan: avoid bad virt_to_pfn()
Date: Mon, 18 Sep 2017 00:40:34 +0000	[thread overview]
Message-ID: <20170918004024.7247-12-alexander.levin@verizon.com> (raw)
In-Reply-To: <20170918004024.7247-1-alexander.levin@verizon.com>

From: Mark Rutland <mark.rutland@arm.com>

[ 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] [<ffff2000080b1ac0>] __virt_to_phys+0x48/0x70
[    0.000000] [<ffff20000a03b86c>] kasan_init+0x1c0/0x498
[    0.000000] [<ffff20000a034018>] setup_arch+0x2fc/0x948
[    0.000000] [<ffff20000a030c68>] start_kernel+0xb8/0x570
[    0.000000] [<ffff20000a0301e8>] __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 <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Acked-by: Laura Abbott <labbott@redhat.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 arch/arm64/mm/kasan_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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
-- 
2.11.0

  parent reply	other threads:[~2017-09-18  0:44 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-18  0:40 [PATCH for 4.9 18/39] iommu/exynos: Block SYSMMU while invalidating FLPD cache Levin, Alexander (Sasha Levin)
2017-09-18  0:40 ` [PATCH for 4.9 19/39] [media] exynos-gsc: Do not swap cb/cr for semi planar formats Levin, Alexander (Sasha Levin)
2017-09-18  0:40 ` [PATCH for 4.9 23/39] parisc: perf: Fix potential NULL pointer dereference Levin, Alexander (Sasha Levin)
2017-09-18  0:40 ` [PATCH for 4.9 20/39] MIPS: smp-cps: Fix retrieval of VPE mask on big endian CPUs Levin, Alexander (Sasha Levin)
2017-09-18  0:40 ` [PATCH for 4.9 22/39] netfilter: nfnl_cthelper: fix incorrect helper->expect_class_max Levin, Alexander (Sasha Levin)
2017-09-18  0:40 ` [PATCH for 4.9 21/39] nvme-rdma: handle cpu unplug when re-establishing the controller Levin, Alexander (Sasha Levin)
2017-09-18  0:40 ` [PATCH for 4.9 26/39] cpufreq: intel_pstate: Update pid_params.sample_rate_ns in pid_param_set() Levin, Alexander (Sasha Levin)
2017-09-18  0:40 ` [PATCH for 4.9 27/39] x86/acpi: Restore the order of CPU IDs Levin, Alexander (Sasha Levin)
2017-09-18  0:40 ` [PATCH for 4.9 25/39] ibmvnic: Free tx/rx scrq pointer array when releasing sub-crqs Levin, Alexander (Sasha Levin)
2017-09-18  0:40 ` [PATCH for 4.9 24/39] nfs: make nfs4_cb_sv_ops static Levin, Alexander (Sasha Levin)
2017-09-18  0:40 ` Levin, Alexander (Sasha Levin) [this message]
2017-09-18  0:40 ` [PATCH for 4.9 31/39] rds: ib: add error handle Levin, Alexander (Sasha Levin)
2017-09-18  0:40 ` [PATCH for 4.9 28/39] iommu/io-pgtable-arm: Check for leaf entry before dereferencing it Levin, Alexander (Sasha Levin)
2017-09-18  0:40 ` [PATCH for 4.9 30/39] mm/cgroup: avoid panic when init with low memory Levin, Alexander (Sasha Levin)
2017-09-18  0:40 ` [PATCH for 4.9 33/39] netfilter: nf_tables: set pktinfo->thoff at AH header if found Levin, Alexander (Sasha Levin)
2017-09-18  0:40 ` [PATCH for 4.9 35/39] xfs: remove kmem_zalloc_greedy Levin, Alexander (Sasha Levin)
2017-09-18  0:40 ` [PATCH for 4.9 34/39] i2c: meson: fix wrong variable usage in meson_i2c_put_data Levin, Alexander (Sasha Levin)
2017-09-18  0:40 ` [PATCH for 4.9 32/39] md/raid10: submit bio directly to replacement disk Levin, Alexander (Sasha Levin)
2017-09-18  0:40 ` [PATCH for 4.9 36/39] ASoC: wm_adsp: Return an error on write to a disabled volatile control Levin, Alexander (Sasha Levin)
2017-09-18  0:40 ` [PATCH for 4.9 38/39] ARM: dts: BCM5301X: Fix memory start address Levin, Alexander (Sasha Levin)
2017-09-18  0:40 ` [PATCH for 4.9 39/39] tools/power turbostat: bugfix: GFXMHz column not changing Levin, Alexander (Sasha Levin)
2017-09-18  0:40 ` [PATCH for 4.9 37/39] libata: transport: Remove circular dependency at free time Levin, Alexander (Sasha Levin)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170918004024.7247-12-alexander.levin@verizon.com \
    --to=alexander.levin@verizon.com \
    --cc=catalin.marinas@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=stable@vger.kernel.org \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®