linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Nathan Lynch <nathanl@linux.ibm.com>
To: linuxppc-dev@lists.ozlabs.org
Subject: [PATCH] powerpc/kasan/book3s_64: warn when running with hash MMU
Date: Tue,  4 Oct 2022 17:37:24 -0500	[thread overview]
Message-ID: <20221004223724.38707-1-nathanl@linux.ibm.com> (raw)

kasan is known to crash at boot on book3s_64 with non-radix MMU. As
noted in commit 41b7a347bf14 ("powerpc: Book3S 64-bit outline-only
KASAN support"):

  A kernel with CONFIG_KASAN=y will crash during boot on a machine
  using HPT translation because not all the entry points to the
  generic KASAN code are protected with a call to kasan_arch_is_ready().

Such crashes look like this:

  BUG: Unable to handle kernel data access at 0xc00e00000308b100
  Faulting instruction address: 0xc0000000006d0fcc
  Oops: Kernel access of bad area, sig: 11 [#1]
  LE PAGE_SIZE=64K MMU=Hash SMP NR_CPUS=2048 NUMA pSeries
  CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.0.0-rc5-02183-g3ab165dea2a2 #13
  [...regs...]
  NIP [c0000000006d0fcc] kasan_byte_accessible+0xc/0x20
  LR [c0000000006cd9cc] __kasan_check_byte+0x2c/0xa0
  Call Trace:
  [c00000001688f930] [c00000001688f970] 0xc00000001688f970 (unreliable)
  [c00000001688f970] [c0000000005f6a74] ksize+0x34/0xa0
  [c00000001688f9a0] [c0000000024c03a8] __alloc_skb+0xd8/0x2d0
  [c00000001688fa00] [c0000000003c48c0] audit_log_start+0x260/0x660
  [c00000001688fb30] [c0000000003c50ec] audit_log+0x3c/0x70
  [c00000001688fb60] [c00000000404590c] audit_init+0x188/0x1ac
  [c00000001688fbe0] [c0000000000127e0] do_one_initcall+0xe0/0x610
  [c00000001688fcd0] [c00000000400a1f0] kernel_init_freeable+0x4c0/0x574
  [c00000001688fda0] [c000000000013450] kernel_init+0x30/0x1d0
  [c00000001688fe10] [c00000000000cd54] ret_from_kernel_thread+0x5c/0x64

If you look carefully enough at the full kernel output, you might
notice this message, much earlier:

  KASAN not enabled as it requires radix!

But the eventual oops does not carry any indication that the real
problem was detected early on and is a known limitation.

Change init_book3s_64.c::kasan_init() to emit a warning backtrace and
taint the kernel when not running on radix. When the kernel likely
oopses later, the 'W' taint flag in the report should help minimize
developer time spent trying to understand what's gone wrong.

Signed-off-by: Nathan Lynch <nathanl@linux.ibm.com>
---
 arch/powerpc/mm/kasan/init_book3s_64.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/powerpc/mm/kasan/init_book3s_64.c b/arch/powerpc/mm/kasan/init_book3s_64.c
index 9300d641cf9a..5d9894d7fb97 100644
--- a/arch/powerpc/mm/kasan/init_book3s_64.c
+++ b/arch/powerpc/mm/kasan/init_book3s_64.c
@@ -56,10 +56,8 @@ void __init kasan_init(void)
 	u64 i;
 	pte_t zero_pte = pfn_pte(virt_to_pfn(kasan_early_shadow_page), PAGE_KERNEL);
 
-	if (!early_radix_enabled()) {
-		pr_warn("KASAN not enabled as it requires radix!");
+	if (WARN(!early_radix_enabled(), "KASAN known broken on HPT"))
 		return;
-	}
 
 	for_each_mem_range(i, &start, &end)
 		kasan_init_phys_region((void *)start, (void *)end);
-- 
2.37.1


             reply	other threads:[~2022-10-04 22:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-04 22:37 Nathan Lynch [this message]
2022-10-06  4:10 ` [PATCH] powerpc/kasan/book3s_64: warn when running with hash MMU Michael Ellerman
2022-10-06  5:04   ` Christophe Leroy
2022-10-07 10:41     ` Michael Ellerman
2022-10-10 14:10       ` Nathan Lynch
2022-10-10 17:03         ` Christophe Leroy
2022-10-11 10:00         ` Michael Ellerman
2022-10-11 10:25           ` Christophe Leroy
2023-01-26  7:11             ` Christophe Leroy

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=20221004223724.38707-1-nathanl@linux.ibm.com \
    --to=nathanl@linux.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    /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;
as well as URLs for NNTP newsgroup(s).