Skip to content

Commit b02faed

Browse files
mrutland-armctmarinas
authored andcommitted
arm64: Use larger stacks when KASAN is selected
AddressSanitizer instrumentation can significantly bloat the stack, and with GCC 7 this can result in stack overflows at boot time in some configurations. We can avoid this by doubling our stack size when KASAN is in use, as is already done on x86 (and has been since KASAN was introduced). Regardless of other patches to decrease KASAN's stack utilization, kernels built with KASAN will always require more stack space than those built without, and we should take this into account. Signed-off-by: Mark Rutland <mark.rutland@arm.com> Cc: Will Deacon <will.deacon@arm.com> Cc: Suzuki K Poulose <suzuki.poulose@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent 37f6b42 commit b02faed

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

arch/arm64/include/asm/memory.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,19 @@
9595
#define KERNEL_END _end
9696

9797
/*
98-
* The size of the KASAN shadow region. This should be 1/8th of the
99-
* size of the entire kernel virtual address space.
98+
* KASAN requires 1/8th of the kernel virtual address space for the shadow
99+
* region. KASAN can bloat the stack significantly, so double the (minimum)
100+
* stack size when KASAN is in use.
100101
*/
101102
#ifdef CONFIG_KASAN
102103
#define KASAN_SHADOW_SIZE (UL(1) << (VA_BITS - 3))
104+
#define KASAN_THREAD_SHIFT 1
103105
#else
104106
#define KASAN_SHADOW_SIZE (0)
107+
#define KASAN_THREAD_SHIFT 0
105108
#endif
106109

107-
#define MIN_THREAD_SHIFT 14
110+
#define MIN_THREAD_SHIFT (14 + KASAN_THREAD_SHIFT)
108111

109112
/*
110113
* VMAP'd stacks are allocated at page granularity, so we must ensure that such

0 commit comments

Comments
 (0)