linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
To: Mark Rutland <mark.rutland@arm.com>
Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, akpm@linux-foundation.org,
	aryabinin@virtuozzo.com, catalin.marinas@arm.com,
	glider@google.com, mingo@redhat.com, peterz@infradead.org,
	will.deacon@arm.com
Subject: Re: [PATCH 3/3] arm64: kasan: clear stale stack poison
Date: Thu, 3 Mar 2016 14:32:46 +0000	[thread overview]
Message-ID: <20160303143237.GA29015@red-moon> (raw)
In-Reply-To: <20160303141429.GB19139@leverpostej>

On Thu, Mar 03, 2016 at 02:14:29PM +0000, Mark Rutland wrote:
> On Wed, Mar 02, 2016 at 02:26:18PM +0000, Mark Rutland 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 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
> 
> Lorenzo, as this was following your suggestion [1], I hope that this
> patch looks ok to you?
> 
> Are you happy to provide an Ack / Reviewed-by?

Yes sure, thanks for putting it together:

Reviewed-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>

  reply	other threads:[~2016-03-03 14:32 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 ` [PATCH 2/3] sched/kasan: remove stale KASAN poison after hotplug Mark Rutland
2016-03-02 14:26   ` 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 [this message]
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=20160303143237.GA29015@red-moon \
    --to=lorenzo.pieralisi@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=mark.rutland@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).