All of lore.kernel.org
 help / color / mirror / Atom feed
From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Dmitry Vyukov <dvyukov@google.com>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Len Brown <len.brown@intel.com>, Pavel Machek <pavel@ucw.cz>,
	linux-pm@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@kernel.org>,
	Andy Lutomirski <luto@amacapital.net>,
	Scott Bauer <scott.bauer@intel.com>,
	"x86@kernel.org" <x86@kernel.org>,
	Alexander Potapenko <glider@google.com>,
	kasan-dev <kasan-dev@googlegroups.com>
Subject: Re: [PATCH v2] x86/suspend: fix false positive KASAN warning on suspend/resume
Date: Fri, 2 Dec 2016 08:01:47 -0600	[thread overview]
Message-ID: <20161202140147.gvj452hmlbxnstrg@treble> (raw)
In-Reply-To: <5144d695-7ac4-f992-5239-91c772b0c121@virtuozzo.com>

On Fri, Dec 02, 2016 at 04:41:09PM +0300, Andrey Ryabinin wrote:
> 
> 
> On 12/01/2016 11:31 PM, Josh Poimboeuf wrote:
> 
> >  arch/x86/kernel/acpi/wakeup_64.S | 16 ++++++++++++++++
> >  1 file changed, 16 insertions(+)
> > 
> > diff --git a/arch/x86/kernel/acpi/wakeup_64.S b/arch/x86/kernel/acpi/wakeup_64.S
> > index 169963f..1df9b75 100644
> > --- a/arch/x86/kernel/acpi/wakeup_64.S
> > +++ b/arch/x86/kernel/acpi/wakeup_64.S
> > @@ -109,6 +109,22 @@ ENTRY(do_suspend_lowlevel)
> >  	movq	pt_regs_r14(%rax), %r14
> >  	movq	pt_regs_r15(%rax), %r15
> >  
> > +#ifdef CONFIG_KASAN
> > +	/*
> > +	 * The suspend path may have poisoned some areas deeper in the stack,
> > +	 * which we now need to unpoison.
> > +	 *
> > +	 * We can't call kasan_unpoison_task_stack_below() because it uses %gs
> > +	 * for 'current', which hasn't been set up yet.  Instead, calculate the
> > +	 * stack range manually and call kasan_unpoison_shadow().
> > +	 */
> > +	movq	%rsp, %rdi
> > +	andq	$CURRENT_MASK, %rdi
> > +	movq	%rsp, %rsi
> > +	xorq	%rdi, %rsi
> > +	call	kasan_unpoison_shadow
> > +#endif
> > +
> 
> Looks good, but in fact we can use kasan_unpoison_task_stack_below(). We just need to change it a little:
> 
> diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c
> index 70c0097..e779236 100644
> --- a/mm/kasan/kasan.c
> +++ b/mm/kasan/kasan.c
> @@ -80,7 +80,9 @@ void kasan_unpoison_task_stack(struct task_struct *task)
>  /* Unpoison the stack for the current task beyond a watermark sp value. */
>  asmlinkage void kasan_unpoison_task_stack_below(const void *watermark)
>  {
> -       __kasan_unpoison_stack(current, watermark);
> +       void *base = (void *)((unsigned long)watermark & ~(THREAD_SIZE - 1));
> +
> +       kasan_unpoison_shadow(base, watermark - base);
>  }
> 
> 
> With this we don't have to calculate stack range in assembly.

That is better indeed, will do a v3.

-- 
Josh

  reply	other threads:[~2016-12-02 14:01 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-29 18:13 BUG: KASAN: stack-out-of-bounds in unwind_get_return_address Scott Bauer
2016-11-30 18:35 ` Josh Poimboeuf
2016-11-30 19:02   ` Scott Bauer
2016-11-30 23:10     ` [PATCH] x86/suspend: fix false positive KASAN warning on suspend/resume Josh Poimboeuf
2016-12-01  9:05       ` Andrey Ryabinin
2016-12-01  9:05         ` Andrey Ryabinin
2016-12-01 14:58         ` Josh Poimboeuf
2016-12-01 16:45           ` Josh Poimboeuf
2016-12-01 16:51             ` Dmitry Vyukov
2016-12-01 17:13               ` Josh Poimboeuf
2016-12-01 17:27                 ` Dmitry Vyukov
2016-12-01 17:34                   ` Josh Poimboeuf
2016-12-01 17:47                     ` Dmitry Vyukov
2016-12-01 17:56                       ` Josh Poimboeuf
2016-12-01 20:31                         ` [PATCH v2] " Josh Poimboeuf
2016-12-02  9:44                           ` Dmitry Vyukov
2016-12-02 12:54                           ` Pavel Machek
2016-12-02 13:41                           ` Andrey Ryabinin
2016-12-02 13:41                             ` Andrey Ryabinin
2016-12-02 14:01                             ` Josh Poimboeuf [this message]
2016-12-02 14:02                               ` Dmitry Vyukov
2016-12-02 14:42                               ` [PATCH v3] " Josh Poimboeuf
2016-12-02 14:45                                 ` Andrey Ryabinin
2016-12-02 14:45                                   ` Andrey Ryabinin
2016-12-02 15:08                                   ` Josh Poimboeuf
2016-12-02 17:42                                     ` [PATCH v4] " Josh Poimboeuf
2016-12-02 20:55                                       ` Andrey Ryabinin
2016-12-02 20:55                                         ` Andrey Ryabinin
2016-12-02 21:09                                       ` Pavel Machek
2016-12-02 21:57                                         ` Josh Poimboeuf
2016-12-08  0:10                                       ` Rafael J. Wysocki
2016-12-01 14:04       ` [PATCH] " Rafael J. Wysocki
2016-12-01 16:53         ` Josh Poimboeuf
2016-12-01 17:05           ` Rafael J. Wysocki
2016-12-02 10:15             ` Ingo Molnar

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=20161202140147.gvj452hmlbxnstrg@treble \
    --to=jpoimboe@redhat.com \
    --cc=aryabinin@virtuozzo.com \
    --cc=dvyukov@google.com \
    --cc=glider@google.com \
    --cc=kasan-dev@googlegroups.com \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=mingo@kernel.org \
    --cc=pavel@ucw.cz \
    --cc=peterz@infradead.org \
    --cc=rjw@rjwysocki.net \
    --cc=scott.bauer@intel.com \
    --cc=x86@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.