diff mbox series

[v2,31/37] kasan, x86, s390: update undef CONFIG_KASAN

Message ID 0a35b29d161bf2559d6e16fbd903e49351c7f6b8.1600204505.git.andreyknvl@google.com (mailing list archive)
State New, archived
Headers show
Series kasan: add hardware tag-based mode for arm64 | expand

Commit Message

Andrey Konovalov Sept. 15, 2020, 9:16 p.m. UTC
With the intoduction of hardware tag-based KASAN some kernel checks of
this kind:

  ifdef CONFIG_KASAN

will be updated to:

  if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)

x86 and s390 use a trick to #undef CONFIG_KASAN for some of the code
that isn't linked with KASAN runtime and shouldn't have any KASAN
annotations.

Also #undef CONFIG_KASAN_GENERIC with CONFIG_KASAN.

Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
Change-Id: I2a622db0cb86a8feb60c30d8cb09190075be2a90
---
 arch/s390/boot/string.c         | 1 +
 arch/x86/boot/compressed/misc.h | 1 +
 2 files changed, 2 insertions(+)

Comments

Marco Elver Sept. 18, 2020, 10:52 a.m. UTC | #1
On Tue, Sep 15, 2020 at 11:16PM +0200, Andrey Konovalov wrote:
[...]
>  arch/s390/boot/string.c         | 1 +
>  arch/x86/boot/compressed/misc.h | 1 +
>  2 files changed, 2 insertions(+)
> 
> diff --git a/arch/s390/boot/string.c b/arch/s390/boot/string.c
> index b11e8108773a..faccb33b462c 100644
> --- a/arch/s390/boot/string.c
> +++ b/arch/s390/boot/string.c
> @@ -3,6 +3,7 @@
>  #include <linux/kernel.h>
>  #include <linux/errno.h>
>  #undef CONFIG_KASAN
> +#undef CONFIG_KASAN_GENERIC

Is CONFIG_KASAN still used to guard instrumented versions of functions?

It looks like #undef CONFIG_KASAN is no longer needed -- at least
<linux/string.h> no longer mentions it.

>  #include "../lib/string.c"
>  
>  int strncmp(const char *cs, const char *ct, size_t count)
> diff --git a/arch/x86/boot/compressed/misc.h b/arch/x86/boot/compressed/misc.h
> index 726e264410ff..2ac973983a8e 100644
> --- a/arch/x86/boot/compressed/misc.h
> +++ b/arch/x86/boot/compressed/misc.h
> @@ -12,6 +12,7 @@
>  #undef CONFIG_PARAVIRT_XXL
>  #undef CONFIG_PARAVIRT_SPINLOCKS
>  #undef CONFIG_KASAN
> +#undef CONFIG_KASAN_GENERIC

Similar here; although it seems a little harder to check if CONFIG_KASAN
is still needed. (Maybe could check the preprocessed output diffs?)

>  
>  /* cpu_feature_enabled() cannot be used this early */
>  #define USE_EARLY_PGTABLE_L5
> -- 
> 2.28.0.618.gf4bc123cb7-goog
>
Andrey Konovalov Sept. 18, 2020, 3:07 p.m. UTC | #2
On Fri, Sep 18, 2020 at 12:52 PM Marco Elver <elver@google.com> wrote:
>
> On Tue, Sep 15, 2020 at 11:16PM +0200, Andrey Konovalov wrote:
> [...]
> >  arch/s390/boot/string.c         | 1 +
> >  arch/x86/boot/compressed/misc.h | 1 +
> >  2 files changed, 2 insertions(+)
> >
> > diff --git a/arch/s390/boot/string.c b/arch/s390/boot/string.c
> > index b11e8108773a..faccb33b462c 100644
> > --- a/arch/s390/boot/string.c
> > +++ b/arch/s390/boot/string.c
> > @@ -3,6 +3,7 @@
> >  #include <linux/kernel.h>
> >  #include <linux/errno.h>
> >  #undef CONFIG_KASAN
> > +#undef CONFIG_KASAN_GENERIC
>
> Is CONFIG_KASAN still used to guard instrumented versions of functions?
>
> It looks like #undef CONFIG_KASAN is no longer needed -- at least
> <linux/string.h> no longer mentions it.

I'm pretty sure this is still necessary (something didn't work when I
forgot to make this change), but I'll check again.
Andrey Konovalov Sept. 24, 2020, 9:35 p.m. UTC | #3
On Fri, Sep 18, 2020 at 5:07 PM Andrey Konovalov <andreyknvl@google.com> wrote:
>
> On Fri, Sep 18, 2020 at 12:52 PM Marco Elver <elver@google.com> wrote:
> >
> > On Tue, Sep 15, 2020 at 11:16PM +0200, Andrey Konovalov wrote:
> > [...]
> > >  arch/s390/boot/string.c         | 1 +
> > >  arch/x86/boot/compressed/misc.h | 1 +
> > >  2 files changed, 2 insertions(+)
> > >
> > > diff --git a/arch/s390/boot/string.c b/arch/s390/boot/string.c
> > > index b11e8108773a..faccb33b462c 100644
> > > --- a/arch/s390/boot/string.c
> > > +++ b/arch/s390/boot/string.c
> > > @@ -3,6 +3,7 @@
> > >  #include <linux/kernel.h>
> > >  #include <linux/errno.h>
> > >  #undef CONFIG_KASAN
> > > +#undef CONFIG_KASAN_GENERIC
> >
> > Is CONFIG_KASAN still used to guard instrumented versions of functions?
> >
> > It looks like #undef CONFIG_KASAN is no longer needed -- at least
> > <linux/string.h> no longer mentions it.
>
> I'm pretty sure this is still necessary (something didn't work when I
> forgot to make this change), but I'll check again.

Yes, it still fails, as compressed code provides its own memmove.
diff mbox series

Patch

diff --git a/arch/s390/boot/string.c b/arch/s390/boot/string.c
index b11e8108773a..faccb33b462c 100644
--- a/arch/s390/boot/string.c
+++ b/arch/s390/boot/string.c
@@ -3,6 +3,7 @@ 
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #undef CONFIG_KASAN
+#undef CONFIG_KASAN_GENERIC
 #include "../lib/string.c"
 
 int strncmp(const char *cs, const char *ct, size_t count)
diff --git a/arch/x86/boot/compressed/misc.h b/arch/x86/boot/compressed/misc.h
index 726e264410ff..2ac973983a8e 100644
--- a/arch/x86/boot/compressed/misc.h
+++ b/arch/x86/boot/compressed/misc.h
@@ -12,6 +12,7 @@ 
 #undef CONFIG_PARAVIRT_XXL
 #undef CONFIG_PARAVIRT_SPINLOCKS
 #undef CONFIG_KASAN
+#undef CONFIG_KASAN_GENERIC
 
 /* cpu_feature_enabled() cannot be used this early */
 #define USE_EARLY_PGTABLE_L5