diff options
authorMark Rutland <mark.rutland@arm.com>2016-03-09 14:08:21 -0800
committerAlex Shi <alex.shi@linaro.org>2016-05-25 13:59:52 +0800
commitcaf602f567932f384fbf7330822ed72f3567c8bb (patch)
parente8a7dd2dac431df753702697470ed5e6e035df11 (diff)
arm64: kasan: clear stale stack poison
Functions which the compiler has instrumented for KASAN place poison on the stack shadow upon entry and remove this poison prior to returning. In the case of cpuidle, CPUs exit the kernel a number of levels deep in C code. Any instrumented functions on this critical path will leave portions of the stack shadow poisoned. If CPUs lose context and return to the kernel via a cold path, we restore a prior context saved in __cpu_suspend_enter are forgotten, and we never remove the poison they placed in the stack shadow area by functions calls between this and the actual exit of the kernel. Thus, (depending on stackframe layout) subsequent calls to instrumented functions may hit this stale poison, resulting in (spurious) KASAN splats to the console. To avoid this, clear any stale poison from the idle thread for a CPU prior to bringing a CPU online. Signed-off-by: Mark Rutland <mark.rutland@arm.com> Acked-by: Catalin Marinas <catalin.marinas@arm.com> Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com> Reviewed-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Cc: Alexander Potapenko <glider@google.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Will Deacon <will.deacon@arm.com> Cc: Ingo Molnar <mingo@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> (cherry picked from commit 0d97e6d8024c71cc838b292c01d5bd951e080eba) Signed-off-by: Alex Shi <alex.shi@linaro.org>
1 files changed, 4 insertions, 0 deletions
diff --git a/arch/arm64/kernel/sleep.S b/arch/arm64/kernel/sleep.S
index 5714f939c19b..b7c4b682bfc8 100644
--- a/arch/arm64/kernel/sleep.S
+++ b/arch/arm64/kernel/sleep.S
@@ -115,6 +115,10 @@ ENTRY(cpu_resume_mmu)
+ mov x0, sp
+ bl kasan_unpoison_remaining_stack
mov x0, #0 // return zero on success