linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Andrey Konovalov <andreyknvl@google.com>
To: Dmitry Vyukov <dvyukov@google.com>
Cc: Marco Elver <elver@google.com>,
	Elena Petrova <lenaptr@google.com>, Linux-MM <linux-mm@kvack.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Kevin Brodsky <kevin.brodsky@arm.com>,
	Will Deacon <will.deacon@arm.com>,
	Branislav Rankov <Branislav.Rankov@arm.com>,
	kasan-dev <kasan-dev@googlegroups.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Kostya Serebryany <kcc@google.com>,
	Alexander Potapenko <glider@google.com>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	Serban Constantinescu <serbanc@google.com>,
	Andrey Ryabinin <aryabinin@virtuozzo.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Vincenzo Frascino <vincenzo.frascino@arm.com>,
	Peter Collingbourne <pcc@google.com>,
	Evgenii Stepanov <eugenis@google.com>
Subject: Re: [PATCH RFC v2 04/21] kasan: unpoison stack only with CONFIG_KASAN_STACK
Date: Thu, 29 Oct 2020 20:57:43 +0100	[thread overview]
Message-ID: <CAAeHK+xvGZNwTtvkzNnU7Hh7iUiPKFNDKDpKT8UPcqQk6Ah3yQ@mail.gmail.com> (raw)
In-Reply-To: <CACT4Y+Zys3+VUsO6GDWQEcjCS6Wx16W_+B6aNy-fyhPcir7eeA@mail.gmail.com>

On Tue, Oct 27, 2020 at 1:44 PM Dmitry Vyukov <dvyukov@google.com> wrote:
>
> On Thu, Oct 22, 2020 at 3:19 PM Andrey Konovalov <andreyknvl@google.com> wrote:
> >
> > There's a config option CONFIG_KASAN_STACK that has to be enabled for
> > KASAN to use stack instrumentation and perform validity checks for
> > stack variables.
> >
> > There's no need to unpoison stack when CONFIG_KASAN_STACK is not enabled.
> > Only call kasan_unpoison_task_stack[_below]() when CONFIG_KASAN_STACK is
> > enabled.
> >
> > Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
> > Link: https://linux-review.googlesource.com/id/If8a891e9fe01ea543e00b576852685afec0887e3
> > ---
> >  arch/arm64/kernel/sleep.S        |  2 +-
> >  arch/x86/kernel/acpi/wakeup_64.S |  2 +-
> >  include/linux/kasan.h            | 10 ++++++----
> >  mm/kasan/common.c                |  2 ++
> >  4 files changed, 10 insertions(+), 6 deletions(-)
> >
> > diff --git a/arch/arm64/kernel/sleep.S b/arch/arm64/kernel/sleep.S
> > index ba40d57757d6..bdadfa56b40e 100644
> > --- a/arch/arm64/kernel/sleep.S
> > +++ b/arch/arm64/kernel/sleep.S
> > @@ -133,7 +133,7 @@ SYM_FUNC_START(_cpu_resume)
> >          */
> >         bl      cpu_do_resume
> >
> > -#ifdef CONFIG_KASAN
> > +#if defined(CONFIG_KASAN) && CONFIG_KASAN_STACK
> >         mov     x0, sp
> >         bl      kasan_unpoison_task_stack_below
> >  #endif
> > diff --git a/arch/x86/kernel/acpi/wakeup_64.S b/arch/x86/kernel/acpi/wakeup_64.S
> > index c8daa92f38dc..5d3a0b8fd379 100644
> > --- a/arch/x86/kernel/acpi/wakeup_64.S
> > +++ b/arch/x86/kernel/acpi/wakeup_64.S
> > @@ -112,7 +112,7 @@ SYM_FUNC_START(do_suspend_lowlevel)
> >         movq    pt_regs_r14(%rax), %r14
> >         movq    pt_regs_r15(%rax), %r15
> >
> > -#ifdef CONFIG_KASAN
> > +#if defined(CONFIG_KASAN) && CONFIG_KASAN_STACK
> >         /*
> >          * The suspend path may have poisoned some areas deeper in the stack,
> >          * which we now need to unpoison.
> > diff --git a/include/linux/kasan.h b/include/linux/kasan.h
> > index 3f3f541e5d5f..7be9fb9146ac 100644
> > --- a/include/linux/kasan.h
> > +++ b/include/linux/kasan.h
> > @@ -68,8 +68,6 @@ static inline void kasan_disable_current(void) {}
> >
> >  void kasan_unpoison_memory(const void *address, size_t size);
> >
> > -void kasan_unpoison_task_stack(struct task_struct *task);
> > -
> >  void kasan_alloc_pages(struct page *page, unsigned int order);
> >  void kasan_free_pages(struct page *page, unsigned int order);
> >
> > @@ -114,8 +112,6 @@ void kasan_restore_multi_shot(bool enabled);
> >
> >  static inline void kasan_unpoison_memory(const void *address, size_t size) {}
> >
> > -static inline void kasan_unpoison_task_stack(struct task_struct *task) {}
> > -
> >  static inline void kasan_alloc_pages(struct page *page, unsigned int order) {}
> >  static inline void kasan_free_pages(struct page *page, unsigned int order) {}
> >
> > @@ -167,6 +163,12 @@ static inline size_t kasan_metadata_size(struct kmem_cache *cache) { return 0; }
> >
> >  #endif /* CONFIG_KASAN */
> >
> > +#if defined(CONFIG_KASAN) && CONFIG_KASAN_STACK
>
> && defined(CONFIG_KASAN_STACK) for consistency

CONFIG_KASAN_STACK is different from other KASAN configs. It's always
defined, and its value is what controls whether stack instrumentation
is enabled.

>
> > +void kasan_unpoison_task_stack(struct task_struct *task);
> > +#else
> > +static inline void kasan_unpoison_task_stack(struct task_struct *task) {}
> > +#endif
> > +
> >  #ifdef CONFIG_KASAN_GENERIC
> >
> >  void kasan_cache_shrink(struct kmem_cache *cache);
> > diff --git a/mm/kasan/common.c b/mm/kasan/common.c
> > index a880e5a547ed..a3e67d49b893 100644
> > --- a/mm/kasan/common.c
> > +++ b/mm/kasan/common.c
> > @@ -58,6 +58,7 @@ void kasan_disable_current(void)
> >  }
> >  #endif /* CONFIG_KASAN_GENERIC || CONFIG_KASAN_SW_TAGS */
> >
> > +#if CONFIG_KASAN_STACK
>
> #ifdef CONFIG_ is the form used toughout the kernel code
>
> >  static void __kasan_unpoison_stack(struct task_struct *task, const void *sp)
> >  {
> >         void *base = task_stack_page(task);
> > @@ -84,6 +85,7 @@ asmlinkage void kasan_unpoison_task_stack_below(const void *watermark)
> >
> >         kasan_unpoison_memory(base, watermark - base);
> >  }
> > +#endif /* CONFIG_KASAN_STACK */
> >
> >  void kasan_alloc_pages(struct page *page, unsigned int order)
> >  {
> > --
> > 2.29.0.rc1.297.gfa9743e501-goog
> >

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2020-10-29 19:58 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-22 13:18 [PATCH RFC v2 00/21] kasan: hardware tag-based mode for production use on arm64 Andrey Konovalov
2020-10-22 13:18 ` [PATCH RFC v2 01/21] kasan: simplify quarantine_put call site Andrey Konovalov
2020-10-27 12:40   ` Dmitry Vyukov
2020-10-22 13:18 ` [PATCH RFC v2 02/21] kasan: rename get_alloc/free_info Andrey Konovalov
2020-10-27 12:40   ` Dmitry Vyukov
2020-10-22 13:18 ` [PATCH RFC v2 03/21] kasan: introduce set_alloc_info Andrey Konovalov
2020-10-27 12:41   ` Dmitry Vyukov
2020-10-22 13:18 ` [PATCH RFC v2 04/21] kasan: unpoison stack only with CONFIG_KASAN_STACK Andrey Konovalov
2020-10-27 12:44   ` Dmitry Vyukov
2020-10-27 12:45     ` Dmitry Vyukov
2020-10-29 19:57     ` Andrey Konovalov [this message]
2020-11-16 10:59       ` Dmitry Vyukov
2020-11-16 11:50         ` Marco Elver
2020-11-16 12:16           ` Catalin Marinas
2020-11-16 12:19             ` Dmitry Vyukov
2020-11-16 12:45               ` Vincenzo Frascino
2020-11-16 13:50                 ` Andrey Konovalov
2020-11-16 14:50                   ` Vincenzo Frascino
2020-10-22 13:18 ` [PATCH RFC v2 05/21] kasan: allow VMAP_STACK for HW_TAGS mode Andrey Konovalov
2020-10-27 12:49   ` Dmitry Vyukov
2020-10-29 20:00     ` Andrey Konovalov
2020-10-22 13:18 ` [PATCH RFC v2 06/21] kasan: mark kasan_init_tags as __init Andrey Konovalov
2020-10-28 10:08   ` Dmitry Vyukov
2020-10-29 20:08     ` Andrey Konovalov
2020-10-22 13:18 ` [PATCH RFC v2 07/21] kasan, arm64: move initialization message Andrey Konovalov
2020-10-28 10:55   ` Dmitry Vyukov
2020-10-29 20:14     ` Andrey Konovalov
2020-11-03 15:33       ` Andrey Konovalov
2020-10-22 13:19 ` [PATCH RFC v2 08/21] kasan: remove __kasan_unpoison_stack Andrey Konovalov
2020-10-28 10:57   ` Dmitry Vyukov
2020-10-22 13:19 ` [PATCH RFC v2 09/21] kasan: inline kasan_reset_tag for tag-based modes Andrey Konovalov
2020-10-28 11:05   ` Dmitry Vyukov
2020-10-30 16:19     ` Andrey Konovalov
2020-10-22 13:19 ` [PATCH RFC v2 10/21] kasan: inline random_tag for HW_TAGS Andrey Konovalov
2020-10-28 11:08   ` Dmitry Vyukov
2020-10-30 15:48     ` Andrey Konovalov
2020-10-30 16:07       ` Andrey Konovalov
2020-10-22 13:19 ` [PATCH RFC v2 11/21] kasan: inline kasan_poison_memory and check_invalid_free Andrey Konovalov
2020-10-28 11:29   ` Dmitry Vyukov
2020-10-22 13:19 ` [PATCH RFC v2 12/21] kasan: inline and rename kasan_unpoison_memory Andrey Konovalov
2020-10-28 11:36   ` Dmitry Vyukov
2020-10-30 16:34     ` Andrey Konovalov
2020-10-30 17:46       ` Dmitry Vyukov
2020-10-22 13:19 ` [PATCH RFC v2 13/21] arm64: kasan: Add cpu_supports_tags helper Andrey Konovalov
2020-10-28 11:38   ` Dmitry Vyukov
2020-10-22 13:19 ` [PATCH RFC v2 14/21] kasan: add and integrate kasan boot parameters Andrey Konovalov
2020-10-22 18:50   ` Marco Elver
2020-10-22 20:28     ` Andrey Konovalov
2020-10-28 12:27   ` Dmitry Vyukov
2020-10-30 19:30     ` Andrey Konovalov
2020-10-30 14:45   ` Marco Elver
2020-10-30 19:30     ` Andrey Konovalov
2020-10-22 13:19 ` [PATCH RFC v2 15/21] kasan: check kasan_enabled in annotations Andrey Konovalov
2020-10-28 16:47   ` Dmitry Vyukov
2020-10-30 19:47     ` Andrey Konovalov
2020-10-22 13:19 ` [PATCH RFC v2 16/21] kasan: optimize poisoning in kmalloc and krealloc Andrey Konovalov
2020-10-28 16:55   ` Dmitry Vyukov
2020-11-02 15:17     ` Andrey Konovalov
2020-10-22 13:19 ` [PATCH RFC v2 17/21] kasan: simplify kasan_poison_kfree Andrey Konovalov
2020-10-28 16:57   ` Dmitry Vyukov
2020-10-22 13:19 ` [PATCH RFC v2 18/21] kasan: rename kasan_poison_kfree Andrey Konovalov
2020-10-28 16:58   ` Dmitry Vyukov
2020-10-22 13:19 ` [PATCH RFC v2 19/21] kasan: don't round_up too much Andrey Konovalov
2020-10-28 17:01   ` Dmitry Vyukov
2020-10-22 13:19 ` [PATCH RFC v2 20/21] kasan: simplify assign_tag and set_tag calls Andrey Konovalov
2020-10-28 17:03   ` Dmitry Vyukov
2020-10-22 13:19 ` [PATCH RFC v2 21/21] kasan: clarify comment in __kasan_kfree_large Andrey Konovalov
2020-10-28 17:04   ` Dmitry Vyukov
2020-10-22 15:15 ` [PATCH RFC v2 00/21] kasan: hardware tag-based mode for production use on arm64 Dmitry Vyukov
2020-10-22 17:00   ` Andrey Konovalov
2020-10-22 18:29     ` Kostya Serebryany

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=CAAeHK+xvGZNwTtvkzNnU7Hh7iUiPKFNDKDpKT8UPcqQk6Ah3yQ@mail.gmail.com \
    --to=andreyknvl@google.com \
    --cc=Branislav.Rankov@arm.com \
    --cc=akpm@linux-foundation.org \
    --cc=aryabinin@virtuozzo.com \
    --cc=catalin.marinas@arm.com \
    --cc=dvyukov@google.com \
    --cc=elver@google.com \
    --cc=eugenis@google.com \
    --cc=glider@google.com \
    --cc=kasan-dev@googlegroups.com \
    --cc=kcc@google.com \
    --cc=kevin.brodsky@arm.com \
    --cc=lenaptr@google.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=pcc@google.com \
    --cc=serbanc@google.com \
    --cc=vincenzo.frascino@arm.com \
    --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).