From: mark.rutland@arm.com (Mark Rutland)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/2] arm64: use larger stacks for KASAN
Date: Wed, 7 Jun 2017 16:35:13 +0100 [thread overview]
Message-ID: <1496849713-17078-3-git-send-email-mark.rutland@arm.com> (raw)
In-Reply-To: <1496849713-17078-1-git-send-email-mark.rutland@arm.com>
With recent toolchains (e.g. GCC 7.1.0), KASAN will instrument stack
accesses, significantly increasing stack pressure. This has been
observed to result in a boot-time stack overflow on Juno R1, and various
failures under Syzkaller-directed Qemu VMs.
On x86, this was addressed in commit:
c420f167db8c799d ("kasan: enable stack instrumentation")
... by doubling the stack size to 32K when the kernel is compiled with
KASAN.
This patch does the same for arm64, enabling us to make use of KASAN's
stack instrumentation. Kernels without KASAN are not affected and will
retain the current 16K stack size.
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Will Deacon <will.deacon@arm.com>
---
arch/arm64/include/asm/thread_info.h | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/thread_info.h
index 4f42275..1dec96e8 100644
--- a/arch/arm64/include/asm/thread_info.h
+++ b/arch/arm64/include/asm/thread_info.h
@@ -25,7 +25,17 @@
#include <asm/page.h>
-#define THREAD_SHIFT 14
+/*
+ * AddressSanitizer's stack instrumentation significantly increases stack
+ * usage. We double the stack size when KASAN is selected to avoid overflows.
+ */
+#ifdef CONFIG_KASAN
+#define KASAN_THREAD_SHIFT 1
+#else
+#define KASAN_THREAD_SHIFT 0
+#endif
+
+#define THREAD_SHIFT (14 + KASAN_THREAD_SHIFT)
#if THREAD_SHIFT >= PAGE_SHIFT
#define THREAD_SIZE_ORDER (THREAD_SHIFT - PAGE_SHIFT)
--
1.9.1
next prev parent reply other threads:[~2017-06-07 15:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-07 15:35 [PATCH 0/2] arm64: avoid KASAN stack overflows Mark Rutland
2017-06-07 15:35 ` [PATCH 1/2] arm64: avoid open-coding THREAD_SIZE{,_ORDER} Mark Rutland
2017-06-07 15:35 ` Mark Rutland [this message]
2017-06-07 16:12 ` [PATCH 0/2] arm64: avoid KASAN stack overflows Andrey Ryabinin
2017-06-07 16:18 ` Mark Rutland
2017-06-07 19:54 ` Arnd Bergmann
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=1496849713-17078-3-git-send-email-mark.rutland@arm.com \
--to=mark.rutland@arm.com \
--cc=linux-arm-kernel@lists.infradead.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).