From: mingo@kernel.org (Ingo Molnar)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 0/3] KASAN: clean stale poison upon cold re-entry to kernel
Date: Thu, 3 Mar 2016 13:02:27 +0100 [thread overview]
Message-ID: <20160303120227.GA2484@gmail.com> (raw)
In-Reply-To: <1456928778-22491-1-git-send-email-mark.rutland@arm.com>
* Mark Rutland <mark.rutland@arm.com> wrote:
> Functions which the compiler has instrumented for ASAN place poison on
> the stack shadow upon entry and remove this poison prior to returning.
>
> In some cases (e.g. hotplug and idle), CPUs may exit the kernel a number
> of levels deep in C code. If there are any instrumented functions on
> this critical path, these will leave portions of the idle thread stack
> shadow poisoned.
>
> If a CPU returns to the kernel via a different path (e.g. a cold entry),
> then depending on stack frame layout subsequent calls to instrumented
> functions may use regions of the stack with stale poison, resulting in
> (spurious) KASAN splats to the console.
>
> Contemporary GCCs always add stack shadow poisoning when ASAN is
> enabled, even when asked to not instrument a function [1], so we can't
> simply annotate functions on the critical path to avoid poisoning.
>
> Instead, this series explicitly removes any stale poison before it can
> be hit. In the common hotplug case we clear the entire stack shadow in
> common code, before a CPU is brought online.
>
> On architectures which perform a cold return as part of cpu idle may
> retain an architecture-specific amount of stack contents. To retain the
> poison for this retained context, the arch code must call the core KASAN
> code, passing a "watermark" stack pointer value beyond which shadow will
> be cleared. Architectures which don't perform a cold return as part of
> idle do not need any additional code.
>
> This is a combination of previous approaches [2,3], attempting to keep
> as much as possible generic.
>
> Thanks,
> Mark.
>
> [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69863
> [2] http://lists.infradead.org/pipermail/linux-arm-kernel/2016-February/409466.html
> [3] http://lists.infradead.org/pipermail/linux-arm-kernel/2016-February/411850.html
>
> Mark Rutland (3):
> kasan: add functions to clear stack poison
> sched/kasan: remove stale KASAN poison after hotplug
> arm64: kasan: clear stale stack poison
>
> arch/arm64/kernel/sleep.S | 4 ++++
> include/linux/kasan.h | 6 +++++-
> kernel/sched/core.c | 3 +++
> mm/kasan/kasan.c | 20 ++++++++++++++++++++
> 4 files changed, 32 insertions(+), 1 deletion(-)
Looks good to me - via which tree would you like to see this merged upstream?
Thanks,
Ingo
next prev parent reply other threads:[~2016-03-03 12:02 UTC|newest]
Thread overview: 13+ 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 ` [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-03 14:14 ` Mark Rutland
2016-03-03 14:32 ` Lorenzo Pieralisi
2016-03-03 12:02 ` Ingo Molnar [this message]
2016-03-03 12:38 ` [PATCH 0/3] KASAN: clean stale poison upon cold re-entry to kernel Mark Rutland
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: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=20160303120227.GA2484@gmail.com \
--to=mingo@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
/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).