summaryrefslogtreecommitdiff
path: root/arch/powerpc/include/asm/thread_info.h
diff options
context:
space:
mode:
authorMichael Ellerman <mpe@ellerman.id.au>2022-06-02 00:31:14 +1000
committerMichael Ellerman <mpe@ellerman.id.au>2022-06-02 22:56:47 +1000
commit3e8635fb2e072672cbc650989ffedf8300ad67fb (patch)
tree107baaf2dc0b2959aeaca60ca9d0bb6a50af255f /arch/powerpc/include/asm/thread_info.h
parent07bf9431b1590d1cd7a8d62075d0b50b073f0495 (diff)
powerpc/kasan: Force thread size increase with KASAN
KASAN causes increased stack usage, which can lead to stack overflows. The logic in Kconfig to suggest a larger default doesn't work if a user has CONFIG_EXPERT enabled and has an existing .config with a smaller value. Follow the lead of x86 and arm64, and force the thread size to be increased when KASAN is enabled. That also has the effect of enlarging the stack for 64-bit KASAN builds, which is also desirable. Fixes: edbadaf06710 ("powerpc/kasan: Fix stack overflow by increasing THREAD_SHIFT") Reported-by: Erhard Furtner <erhard_f@mailbox.org> Reported-by: Christophe Leroy <christophe.leroy@csgroup.eu> [mpe: Use MIN_THREAD_SHIFT as suggested by Christophe] Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20220601143114.133524-1-mpe@ellerman.id.au
Diffstat (limited to 'arch/powerpc/include/asm/thread_info.h')
-rw-r--r--arch/powerpc/include/asm/thread_info.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
index 125328d1b980..af58f1ed3952 100644
--- a/arch/powerpc/include/asm/thread_info.h
+++ b/arch/powerpc/include/asm/thread_info.h
@@ -14,10 +14,16 @@
#ifdef __KERNEL__
-#if defined(CONFIG_VMAP_STACK) && CONFIG_THREAD_SHIFT < PAGE_SHIFT
+#ifdef CONFIG_KASAN
+#define MIN_THREAD_SHIFT (CONFIG_THREAD_SHIFT + 1)
+#else
+#define MIN_THREAD_SHIFT CONFIG_THREAD_SHIFT
+#endif
+
+#if defined(CONFIG_VMAP_STACK) && MIN_THREAD_SHIFT < PAGE_SHIFT
#define THREAD_SHIFT PAGE_SHIFT
#else
-#define THREAD_SHIFT CONFIG_THREAD_SHIFT
+#define THREAD_SHIFT MIN_THREAD_SHIFT
#endif
#define THREAD_SIZE (1 << THREAD_SHIFT)