From: Catalin Marinas <catalin.marinas@arm.com>
To: Marco Elver <elver@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>,
Andrey Konovalov <andreyknvl@google.com>,
Will Deacon <will.deacon@arm.com>,
Vincenzo Frascino <vincenzo.frascino@arm.com>,
Alexander Potapenko <glider@google.com>,
Evgenii Stepanov <eugenis@google.com>,
Kostya Serebryany <kcc@google.com>,
Peter Collingbourne <pcc@google.com>,
Serban Constantinescu <serbanc@google.com>,
Andrey Ryabinin <aryabinin@virtuozzo.com>,
Elena Petrova <lenaptr@google.com>,
Branislav Rankov <Branislav.Rankov@arm.com>,
Kevin Brodsky <kevin.brodsky@arm.com>,
Andrew Morton <akpm@linux-foundation.org>,
kasan-dev <kasan-dev@googlegroups.com>,
Linux ARM <linux-arm-kernel@lists.infradead.org>,
Linux-MM <linux-mm@kvack.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH RFC v2 04/21] kasan: unpoison stack only with CONFIG_KASAN_STACK
Date: Mon, 16 Nov 2020 12:16:05 +0000 [thread overview]
Message-ID: <X7Jthb9D5Ekq93sS@trantor> (raw)
In-Reply-To: <CANpmjNPNqHsOfcw7Wh+XQ_pPT1610-+B9By171t7KMS3aB2sBg@mail.gmail.com>
On Mon, Nov 16, 2020 at 12:50:00PM +0100, Marco Elver wrote:
> On Mon, 16 Nov 2020 at 11:59, Dmitry Vyukov <dvyukov@google.com> wrote:
> > On Thu, Oct 29, 2020 at 8:57 PM 'Andrey Konovalov' via kasan-dev
> > <kasan-dev@googlegroups.com> wrote:
> > > 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.
> >
> > Not sure why we did this instead of the following, but okay.
> >
> > config KASAN_STACK
> > - int
> > - default 1 if KASAN_STACK_ENABLE || CC_IS_GCC
> > - default 0
> > + bool
> > + default y if KASAN_STACK_ENABLE || CC_IS_GCC
> > + default n
>
> I wondered the same, but then looking at scripts/Makefile.kasan I
> think it's because we directly pass it to the compiler:
> ...
> $(call cc-param,asan-stack=$(CONFIG_KASAN_STACK)) \
> ...
Try this instead:
$(call cc-param,asan-stack=$(if $(CONFIG_KASAN_STACK),1,0)) \
--
Catalin
next prev parent reply other threads:[~2020-11-16 12:16 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
2020-11-16 10:59 ` Dmitry Vyukov
2020-11-16 11:50 ` Marco Elver
2020-11-16 12:16 ` Catalin Marinas [this message]
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=X7Jthb9D5Ekq93sS@trantor \
--to=catalin.marinas@arm.com \
--cc=Branislav.Rankov@arm.com \
--cc=akpm@linux-foundation.org \
--cc=andreyknvl@google.com \
--cc=aryabinin@virtuozzo.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).