Skip to content

Commit

Permalink
arm64: Use larger stacks when KASAN is selected
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Mark Rutland authored and Catalin Marinas committed Oct 4, 2017
1 parent 37f6b42 commit b02faed
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions arch/arm64/include/asm/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,19 @@
#define KERNEL_END _end

/*
* The size of the KASAN shadow region. This should be 1/8th of the
* size of the entire kernel virtual address space.
* KASAN requires 1/8th of the kernel virtual address space for the shadow
* region. KASAN can bloat the stack significantly, so double the (minimum)
* stack size when KASAN is in use.
*/
#ifdef CONFIG_KASAN
#define KASAN_SHADOW_SIZE (UL(1) << (VA_BITS - 3))
#define KASAN_THREAD_SHIFT 1
#else
#define KASAN_SHADOW_SIZE (0)
#define KASAN_THREAD_SHIFT 0
#endif

#define MIN_THREAD_SHIFT 14
#define MIN_THREAD_SHIFT (14 + KASAN_THREAD_SHIFT)

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

0 comments on commit b02faed

Please sign in to comment.