From: Mark Rutland <mark.rutland@arm.com>
To: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Cc: akpm@linux-foundation.org, aryabinin@virtuozzo.com,
catalin.marinas@arm.com, glider@google.com,
lorenzo.pieralisi@arm.com, mark.rutland@arm.com,
mingo@redhat.com, peterz@infradead.org, will.deacon@arm.com
Subject: [PATCH 2/3] sched/kasan: remove stale KASAN poison after hotplug
Date: Wed, 2 Mar 2016 14:26:17 +0000 [thread overview]
Message-ID: <1456928778-22491-3-git-send-email-mark.rutland@arm.com> (raw)
In-Reply-To: <1456928778-22491-1-git-send-email-mark.rutland@arm.com>
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 CPU hotplug, 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.
When a CPU is subsequently brought back into the kernel via a different
path, depending on stackframe, layout 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: Ingo Molnar <mingo@redhat.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Will Deacon <will.deacon@arm.com>
---
kernel/sched/core.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 9503d59..41f6b22 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -26,6 +26,7 @@
* Thomas Gleixner, Mike Kravetz
*/
+#include <linux/kasan.h>
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/nmi.h>
@@ -5096,6 +5097,8 @@ void init_idle(struct task_struct *idle, int cpu)
idle->state = TASK_RUNNING;
idle->se.exec_start = sched_clock();
+ kasan_unpoison_task_stack(idle);
+
#ifdef CONFIG_SMP
/*
* Its possible that init_idle() gets called multiple times on a task,
--
1.9.1
next prev parent reply other threads:[~2016-03-02 14:26 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-02 14:26 [PATCH 0/3] KASAN: clean stale poison upon cold re-entry to kernel Mark Rutland
2016-03-02 14:26 ` [PATCH 1/3] kasan: add functions to clear stack poison Mark Rutland
2016-03-02 14:26 ` Mark Rutland
2016-03-02 14:26 ` Mark Rutland [this message]
2016-03-02 14:26 ` [PATCH 2/3] sched/kasan: remove stale KASAN poison after hotplug Mark Rutland
2016-03-02 14:26 ` [PATCH 3/3] arm64: kasan: clear stale stack poison Mark Rutland
2016-03-02 14:26 ` Mark Rutland
2016-03-03 14:14 ` Mark Rutland
2016-03-03 14:32 ` Lorenzo Pieralisi
2016-03-03 14:32 ` Lorenzo Pieralisi
2016-03-03 12:02 ` [PATCH 0/3] KASAN: clean stale poison upon cold re-entry to kernel Ingo Molnar
2016-03-03 12:02 ` Ingo Molnar
2016-03-03 12:38 ` Mark Rutland
2016-03-03 12:44 ` Ingo Molnar
2016-03-03 12:44 ` Ingo Molnar
2016-03-03 14:30 ` Andrey Ryabinin
2016-03-03 14:49 ` Mark Rutland
2016-03-03 14:49 ` Mark Rutland
2016-03-03 14:53 ` Andrey Ryabinin
2016-03-03 14:53 ` Andrey Ryabinin
2016-03-03 16:11 ` Catalin Marinas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1456928778-22491-3-git-send-email-mark.rutland@arm.com \
--to=mark.rutland@arm.com \
--cc=akpm@linux-foundation.org \
--cc=aryabinin@virtuozzo.com \
--cc=catalin.marinas@arm.com \
--cc=glider@google.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=will.deacon@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).