linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kasan: add kasan mode messages when kasan init
@ 2021-10-19 12:04 Kuan-Ying Lee
  2021-10-19 14:14 ` Marco Elver
  0 siblings, 1 reply; 3+ messages in thread
From: Kuan-Ying Lee @ 2021-10-19 12:04 UTC (permalink / raw)
  To: Andrey Ryabinin, Alexander Potapenko, Andrey Konovalov,
	Dmitry Vyukov, Catalin Marinas, Will Deacon, Andrew Morton,
	Matthias Brugger
  Cc: chinwen.chang, yee.lee, nicholas.tang, kasan-dev,
	linux-arm-kernel, linux-kernel, linux-mm, linux-mediatek,
	Kuan-Ying Lee

There are multiple kasan modes. It make sense that we add some messages
to know which kasan mode is when booting up. see [1].

Link: https://bugzilla.kernel.org/show_bug.cgi?id=212195 [1]
Signed-off-by: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com>
---
 arch/arm64/mm/kasan_init.c | 2 +-
 mm/kasan/hw_tags.c         | 4 +++-
 mm/kasan/sw_tags.c         | 2 +-
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/arm64/mm/kasan_init.c b/arch/arm64/mm/kasan_init.c
index 61b52a92b8b6..b4e78beac285 100644
--- a/arch/arm64/mm/kasan_init.c
+++ b/arch/arm64/mm/kasan_init.c
@@ -293,7 +293,7 @@ void __init kasan_init(void)
 	kasan_init_depth();
 #if defined(CONFIG_KASAN_GENERIC)
 	/* CONFIG_KASAN_SW_TAGS also requires kasan_init_sw_tags(). */
-	pr_info("KernelAddressSanitizer initialized\n");
+	pr_info("KernelAddressSanitizer initialized (generic)\n");
 #endif
 }
 
diff --git a/mm/kasan/hw_tags.c b/mm/kasan/hw_tags.c
index 05d1e9460e2e..3e28ecbe1d8f 100644
--- a/mm/kasan/hw_tags.c
+++ b/mm/kasan/hw_tags.c
@@ -168,7 +168,9 @@ void __init kasan_init_hw_tags(void)
 		break;
 	}
 
-	pr_info("KernelAddressSanitizer initialized\n");
+	pr_info("KernelAddressSanitizer initialized (hw-tags, mode=%s, stacktrace=%s)\n",
+		kasan_flag_async ? "async" : "sync",
+		kasan_stack_collection_enabled() ? "on" : "off");
 }
 
 void kasan_alloc_pages(struct page *page, unsigned int order, gfp_t flags)
diff --git a/mm/kasan/sw_tags.c b/mm/kasan/sw_tags.c
index bd3f540feb47..77f13f391b57 100644
--- a/mm/kasan/sw_tags.c
+++ b/mm/kasan/sw_tags.c
@@ -42,7 +42,7 @@ void __init kasan_init_sw_tags(void)
 	for_each_possible_cpu(cpu)
 		per_cpu(prng_state, cpu) = (u32)get_cycles();
 
-	pr_info("KernelAddressSanitizer initialized\n");
+	pr_info("KernelAddressSanitizer initialized (sw-tags)\n");
 }
 
 /*
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] kasan: add kasan mode messages when kasan init
  2021-10-19 12:04 [PATCH] kasan: add kasan mode messages when kasan init Kuan-Ying Lee
@ 2021-10-19 14:14 ` Marco Elver
  2021-10-19 14:33   ` Kuan-Ying Lee
  0 siblings, 1 reply; 3+ messages in thread
From: Marco Elver @ 2021-10-19 14:14 UTC (permalink / raw)
  To: Kuan-Ying Lee
  Cc: Andrey Ryabinin, Alexander Potapenko, Andrey Konovalov,
	Dmitry Vyukov, Catalin Marinas, Will Deacon, Andrew Morton,
	Matthias Brugger, chinwen.chang, yee.lee, nicholas.tang,
	kasan-dev, linux-arm-kernel, linux-kernel, linux-mm,
	linux-mediatek

On Tue, 19 Oct 2021 at 14:04, Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com> wrote:
>
> There are multiple kasan modes. It make sense that we add some messages
> to know which kasan mode is when booting up. see [1].
>
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=212195 [1]
> Signed-off-by: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com>

Looks good, however, you need to rebase to -next because of "kasan:
Extend KASAN mode kernel parameter"...

> ---
>  arch/arm64/mm/kasan_init.c | 2 +-
>  mm/kasan/hw_tags.c         | 4 +++-
>  mm/kasan/sw_tags.c         | 2 +-
>  3 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm64/mm/kasan_init.c b/arch/arm64/mm/kasan_init.c
> index 61b52a92b8b6..b4e78beac285 100644
> --- a/arch/arm64/mm/kasan_init.c
> +++ b/arch/arm64/mm/kasan_init.c
> @@ -293,7 +293,7 @@ void __init kasan_init(void)
>         kasan_init_depth();
>  #if defined(CONFIG_KASAN_GENERIC)
>         /* CONFIG_KASAN_SW_TAGS also requires kasan_init_sw_tags(). */
> -       pr_info("KernelAddressSanitizer initialized\n");
> +       pr_info("KernelAddressSanitizer initialized (generic)\n");
>  #endif
>  }
>
> diff --git a/mm/kasan/hw_tags.c b/mm/kasan/hw_tags.c
> index 05d1e9460e2e..3e28ecbe1d8f 100644
> --- a/mm/kasan/hw_tags.c
> +++ b/mm/kasan/hw_tags.c
> @@ -168,7 +168,9 @@ void __init kasan_init_hw_tags(void)
>                 break;
>         }
>
> -       pr_info("KernelAddressSanitizer initialized\n");
> +       pr_info("KernelAddressSanitizer initialized (hw-tags, mode=%s, stacktrace=%s)\n",
> +               kasan_flag_async ? "async" : "sync",

... which means this will have a 3rd option "asymm".

> +               kasan_stack_collection_enabled() ? "on" : "off");
>  }
>
>  void kasan_alloc_pages(struct page *page, unsigned int order, gfp_t flags)
> diff --git a/mm/kasan/sw_tags.c b/mm/kasan/sw_tags.c
> index bd3f540feb47..77f13f391b57 100644
> --- a/mm/kasan/sw_tags.c
> +++ b/mm/kasan/sw_tags.c
> @@ -42,7 +42,7 @@ void __init kasan_init_sw_tags(void)
>         for_each_possible_cpu(cpu)
>                 per_cpu(prng_state, cpu) = (u32)get_cycles();
>
> -       pr_info("KernelAddressSanitizer initialized\n");
> +       pr_info("KernelAddressSanitizer initialized (sw-tags)\n");
>  }
>
>  /*
> --
> 2.18.0

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] kasan: add kasan mode messages when kasan init
  2021-10-19 14:14 ` Marco Elver
@ 2021-10-19 14:33   ` Kuan-Ying Lee
  0 siblings, 0 replies; 3+ messages in thread
From: Kuan-Ying Lee @ 2021-10-19 14:33 UTC (permalink / raw)
  To: Marco Elver
  Cc: Andrey Ryabinin, Alexander Potapenko, Andrey Konovalov,
	Dmitry Vyukov, Catalin Marinas, Will Deacon, Andrew Morton,
	Matthias Brugger, Chinwen Chang (張錦文),
	Yee Lee (李建誼),
	Nicholas Tang (鄭秦輝),
	kasan-dev, linux-arm-kernel, linux-kernel, linux-mm,
	linux-mediatek

On Tue, 2021-10-19 at 22:14 +0800, Marco Elver wrote:
> On Tue, 19 Oct 2021 at 14:04, Kuan-Ying Lee <
> Kuan-Ying.Lee@mediatek.com> wrote:
> > 
> > There are multiple kasan modes. It make sense that we add some
> > messages
> > to know which kasan mode is when booting up. see [1].
> > 
> > Link: 
> > https://urldefense.com/v3/__https://bugzilla.kernel.org/show_bug.cgi?id=212195__;!!CTRNKA9wMg0ARbw!374SjX0W47zTqp1xJyIg9CW0T7ggAT1rr981lIRBjQhUk2_495ltG_ZkiW6jmeVDBvu_UA$
> > $  [1]
> > Signed-off-by: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com>
> 
> Looks good, however, you need to rebase to -next because of "kasan:
> Extend KASAN mode kernel parameter"...

Thanks Marco.
I will send the v2.

> 
> > ---
> >  arch/arm64/mm/kasan_init.c | 2 +-
> >  mm/kasan/hw_tags.c         | 4 +++-
> >  mm/kasan/sw_tags.c         | 2 +-
> >  3 files changed, 5 insertions(+), 3 deletions(-)
> > 
> > diff --git a/arch/arm64/mm/kasan_init.c
> > b/arch/arm64/mm/kasan_init.c
> > index 61b52a92b8b6..b4e78beac285 100644
> > --- a/arch/arm64/mm/kasan_init.c
> > +++ b/arch/arm64/mm/kasan_init.c
> > @@ -293,7 +293,7 @@ void __init kasan_init(void)
> >         kasan_init_depth();
> >  #if defined(CONFIG_KASAN_GENERIC)
> >         /* CONFIG_KASAN_SW_TAGS also requires kasan_init_sw_tags().
> > */
> > -       pr_info("KernelAddressSanitizer initialized\n");
> > +       pr_info("KernelAddressSanitizer initialized (generic)\n");
> >  #endif
> >  }
> > 
> > diff --git a/mm/kasan/hw_tags.c b/mm/kasan/hw_tags.c
> > index 05d1e9460e2e..3e28ecbe1d8f 100644
> > --- a/mm/kasan/hw_tags.c
> > +++ b/mm/kasan/hw_tags.c
> > @@ -168,7 +168,9 @@ void __init kasan_init_hw_tags(void)
> >                 break;
> >         }
> > 
> > -       pr_info("KernelAddressSanitizer initialized\n");
> > +       pr_info("KernelAddressSanitizer initialized (hw-tags,
> > mode=%s, stacktrace=%s)\n",
> > +               kasan_flag_async ? "async" : "sync",
> 
> ... which means this will have a 3rd option "asymm".

Thanks for the reminder.

> 
> > +               kasan_stack_collection_enabled() ? "on" : "off");
> >  }
> > 
> >  void kasan_alloc_pages(struct page *page, unsigned int order,
> > gfp_t flags)
> > diff --git a/mm/kasan/sw_tags.c b/mm/kasan/sw_tags.c
> > index bd3f540feb47..77f13f391b57 100644
> > --- a/mm/kasan/sw_tags.c
> > +++ b/mm/kasan/sw_tags.c
> > @@ -42,7 +42,7 @@ void __init kasan_init_sw_tags(void)
> >         for_each_possible_cpu(cpu)
> >                 per_cpu(prng_state, cpu) = (u32)get_cycles();
> > 
> > -       pr_info("KernelAddressSanitizer initialized\n");
> > +       pr_info("KernelAddressSanitizer initialized (sw-tags)\n");
> >  }
> > 
> >  /*
> > --
> > 2.18.0
> 
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-10-19 14:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-19 12:04 [PATCH] kasan: add kasan mode messages when kasan init Kuan-Ying Lee
2021-10-19 14:14 ` Marco Elver
2021-10-19 14:33   ` Kuan-Ying Lee

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).