Re: [PATCH v2 04/20] kasan, arm64: unpoison stack only with CONFIG_KASAN_STACK

From: Andrey Konovalov
Date: Thu Nov 12 2020 - 14:39:04 EST


On Thu, Nov 12, 2020 at 10:51 AM Catalin Marinas
<catalin.marinas@xxxxxxx> wrote:
>
> On Tue, Nov 10, 2020 at 11:20:08PM +0100, Andrey Konovalov 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.
> >
> > Note, that CONFIG_KASAN_STACK is an option that is currently always
> > defined when CONFIG_KASAN is enabled, and therefore has to be tested
> > with #if instead of #ifdef.
> >
> > Signed-off-by: Andrey Konovalov <andreyknvl@xxxxxxxxxx>
> > 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
>
> I don't understand why CONFIG_KASAN_STACK is not a bool (do you plan to
> add more values to it?) but for arm64:

I don't remember if there's an actual reason. Perhaps this is
something that can be reworked later, but I don't want to get into
this in this series.

> Acked-by: Catalin Marinas <catalin.marinas@xxxxxxx>

Thanks!