Skip to contentSkip to conversation

riscv: Increase stack size under KASAN

PATCH In review Dmitry Vyukov 2 participants 3 messages Mar 14, 2022 – Mar 31, 2022 RISC-V

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 riscv: Increase stack size under KASAN

KASAN requires more stack space because of compiler instrumentation. Increase stack size as other arches do.

---
 arch/riscv/include/asm/thread_info.h | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
arch/riscv/include/asm/thread_info.h +8 -2
index 60da0dcacf145..74d888c8d631a 100644
@@ -11,11 +11,17 @@
 #include <asm/page.h>
 #include <linux/const.h>
 
+#ifdef CONFIG_KASAN
+#define KASAN_STACK_ORDER 1
+#else
+#define KASAN_STACK_ORDER 0
+#endif
+
 /* thread information allocation */
 #ifdef CONFIG_64BIT
-#define THREAD_SIZE_ORDER	(2)
+#define THREAD_SIZE_ORDER	(2 + KASAN_STACK_ORDER)
 #else
-#define THREAD_SIZE_ORDER	(1)
+#define THREAD_SIZE_ORDER	(1 + KASAN_STACK_ORDER)
 #endif
 #define THREAD_SIZE		(PAGE_SIZE << THREAD_SIZE_ORDER)
 

base-commit: 0966d385830de3470b7131db8e86c0c5bc9c52dc

Signature · 7 lines
2.35.1.723.g4982287a31-goog


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
#1 lore raw
Quoted 8 lines · Dmitry Vyukov

KASAN requires more stack space because of compiler instrumentation. Increase stack size as other arches do.

ping

Quoted 29 lines
---
 arch/riscv/include/asm/thread_info.h | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
arch/riscv/include/asm/thread_info.h +8 -2
index 60da0dcacf145..74d888c8d631a 100644
@@ -11,11 +11,17 @@
 #include <asm/page.h>
 #include <linux/const.h>
 
+#ifdef CONFIG_KASAN
+#define KASAN_STACK_ORDER 1
+#else
+#define KASAN_STACK_ORDER 0
+#endif
+
 /* thread information allocation */
 #ifdef CONFIG_64BIT
-#define THREAD_SIZE_ORDER      (2)
+#define THREAD_SIZE_ORDER      (2 + KASAN_STACK_ORDER)
 #else
-#define THREAD_SIZE_ORDER      (1)
+#define THREAD_SIZE_ORDER      (1 + KASAN_STACK_ORDER)
 #endif
 #define THREAD_SIZE            (PAGE_SIZE << THREAD_SIZE_ORDER)
 
Quoted 4 lines

base-commit: 0966d385830de3470b7131db8e86c0c5bc9c52dc --
2.35.1.723.g4982287a31-goog

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

maintainer
#2 lore raw
In reply to Dmitry Vyukov
Quoted 36 lines · On Mon, 14 Mar 2022 02:06:52 PDT (-0700), [email protected] wrote:

KASAN requires more stack space because of compiler instrumentation. Increase stack size as other arches do.

---
 arch/riscv/include/asm/thread_info.h | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
arch/riscv/include/asm/thread_info.h +8 -2
index 60da0dcacf145..74d888c8d631a 100644
@@ -11,11 +11,17 @@
 #include <asm/page.h>
 #include <linux/const.h>
 
+#ifdef CONFIG_KASAN
+#define KASAN_STACK_ORDER 1
+#else
+#define KASAN_STACK_ORDER 0
+#endif
+
 /* thread information allocation */
 #ifdef CONFIG_64BIT
-#define THREAD_SIZE_ORDER	(2)
+#define THREAD_SIZE_ORDER	(2 + KASAN_STACK_ORDER)
 #else
-#define THREAD_SIZE_ORDER	(1)
+#define THREAD_SIZE_ORDER	(1 + KASAN_STACK_ORDER)
 #endif
 #define THREAD_SIZE		(PAGE_SIZE << THREAD_SIZE_ORDER)
 
Quoted 1 line

base-commit: 0966d385830de3470b7131db8e86c0c5bc9c52dc

Thanks, this is on for-next (there's no fixes right now, I'm still collecting stuff for this merge window).

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv