Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1348084

[PATCH 3/3] arm64: kasan: clear stale stack poison

From Mark Rutland <mark.rutland@arm.com>
Newsgroups linux.kernel
Subject [PATCH 3/3] arm64: kasan: clear stale stack poison
Date 2016-03-02 15:30 +0100
Message-ID <r8fWP-pB-45@gated-at.bofh.it> (permalink)
References <r8fWO-pB-19@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Functions which the compiler has instrumented for ASAN 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>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
---
 arch/arm64/kernel/sleep.S | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm64/kernel/sleep.S b/arch/arm64/kernel/sleep.S
index e33fe33..fd10eb6 100644
--- a/arch/arm64/kernel/sleep.S
+++ b/arch/arm64/kernel/sleep.S
@@ -145,6 +145,10 @@ ENTRY(cpu_resume_mmu)
 ENDPROC(cpu_resume_mmu)
 	.popsection
 cpu_resume_after_mmu:
+#ifdef CONFIG_KASAN
+	mov	x0, sp
+	bl	kasan_unpoison_remaining_stack
+#endif
 	mov	x0, #0			// return zero on success
 	ldp	x19, x20, [sp, #16]
 	ldp	x21, x22, [sp, #32]
-- 
1.9.1

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/3] KASAN: clean stale poison upon cold re-entry to kernel Mark Rutland <mark.rutland@arm.com> - 2016-03-02 15:30 +0100
  [PATCH 3/3] arm64: kasan: clear stale stack poison Mark Rutland <mark.rutland@arm.com> - 2016-03-02 15:30 +0100
    Re: [PATCH 3/3] arm64: kasan: clear stale stack poison Mark Rutland <mark.rutland@arm.com> - 2016-03-03 15:20 +0100
      Re: [PATCH 3/3] arm64: kasan: clear stale stack poison Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2016-03-03 15:40 +0100
  Re: [PATCH 0/3] KASAN: clean stale poison upon cold re-entry to  kernel Ingo Molnar <mingo@kernel.org> - 2016-03-03 13:10 +0100
    Re: [PATCH 0/3] KASAN: clean stale poison upon cold re-entry to  kernel Mark Rutland <mark.rutland@arm.com> - 2016-03-03 13:40 +0100
      Re: [PATCH 0/3] KASAN: clean stale poison upon cold re-entry to  kernel Ingo Molnar <mingo@kernel.org> - 2016-03-03 13:50 +0100
      Re: [PATCH 0/3] KASAN: clean stale poison upon cold re-entry to  kernel Andrey Ryabinin <aryabinin@virtuozzo.com> - 2016-03-03 15:40 +0100
        Re: [PATCH 0/3] KASAN: clean stale poison upon cold re-entry to  kernel Mark Rutland <mark.rutland@arm.com> - 2016-03-03 15:50 +0100
          Re: [PATCH 0/3] KASAN: clean stale poison upon cold re-entry to  kernel Andrey Ryabinin <aryabinin@virtuozzo.com> - 2016-03-03 16:00 +0100
      Re: [PATCH 0/3] KASAN: clean stale poison upon cold re-entry to  kernel Catalin Marinas <catalin.marinas@arm.com> - 2016-03-03 17:20 +0100

csiph-web