mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com>
To: Marco Elver <elver@google.com>
Cc: "Andrey Ryabinin" <ryabinin.a.a@gmail.com>,
	"Alexander Potapenko" <glider@google.com>,
	"Andrey Konovalov" <andreyknvl@gmail.com>,
	"Dmitry Vyukov" <dvyukov@google.com>,
	"Catalin Marinas" <catalin.marinas@arm.com>,
	"Will Deacon" <will@kernel.org>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Matthias Brugger" <matthias.bgg@gmail.com>,
	"Chinwen Chang (張錦文)" <chinwen.chang@mediatek.com>,
	"Yee Lee (李建誼)" <Yee.Lee@mediatek.com>,
	"Nicholas Tang (鄭秦輝)" <nicholas.tang@mediatek.com>,
	"kasan-dev@googlegroups.com" <kasan-dev@googlegroups.com>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>
Subject: Re: [PATCH v2] kasan: add kasan mode messages when kasan init
Date: Wed, 20 Oct 2021 15:46:40 +0800	[thread overview]
Message-ID: <c0d7c2aa14cc569d5ad95dc750bb6cc1727a042c.camel@mediatek.com> (raw)
In-Reply-To: <CANpmjNNxQRM5rSxcdxNOicpOvwQ=vsutQO3j1hUmGAfS9+pQDA@mail.gmail.com>

On Wed, 2021-10-20 at 15:23 +0800, Marco Elver wrote:
> On Wed, 20 Oct 2021 at 08:13, Kuan-Ying Lee <
> Kuan-Ying.Lee@mediatek.com> wrote:
> > 
> > There are multiple kasan modes. It makes 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!yylpqk8mnd0N8w6pn4Mn4sIeu-GGlKXcA4I4yXlmstFsuqmpkhaM2V_uu2c6oPMFpZRqoQ$
> > $  [1]
> > Signed-off-by: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com>
> > ---
> > change since v2:
> >  - Rebase to linux-next
> >  - HW-tags based mode need to consider asymm mode
> >  - Thanks for Marco's suggestion
> > 
> >  arch/arm64/mm/kasan_init.c |  2 +-
> >  mm/kasan/hw_tags.c         |  4 +++-
> >  mm/kasan/kasan.h           | 10 ++++++++++
> >  mm/kasan/sw_tags.c         |  2 +-
> >  4 files changed, 15 insertions(+), 3 deletions(-)
> > 
> > diff --git a/arch/arm64/mm/kasan_init.c
> > b/arch/arm64/mm/kasan_init.c
> > index 5b996ca4d996..6f5a6fe8edd7 100644
> > --- a/arch/arm64/mm/kasan_init.c
> > +++ b/arch/arm64/mm/kasan_init.c
> > @@ -309,7 +309,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 dc892119e88f..1d5c89c7cdfe 100644
> > --- a/mm/kasan/hw_tags.c
> > +++ b/mm/kasan/hw_tags.c
> > @@ -177,7 +177,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_mode_info(),
> > +               kasan_stack_collection_enabled() ? "on" : "off");
> >  }
> > 
> >  void kasan_alloc_pages(struct page *page, unsigned int order,
> > gfp_t flags)
> > diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h
> > index aebd8df86a1f..387ed7b6de37 100644
> > --- a/mm/kasan/kasan.h
> > +++ b/mm/kasan/kasan.h
> > @@ -36,6 +36,16 @@ static inline bool
> > kasan_sync_fault_possible(void)
> >  {
> >         return kasan_mode == KASAN_MODE_SYNC || kasan_mode ==
> > KASAN_MODE_ASYMM;
> >  }
> > +
> > +static inline const char *kasan_mode_info(void)
> > +{
> > +       if (kasan_mode == KASAN_MODE_ASYNC)
> > +               return "async";
> > +       else if (kasan_mode == KASAN_MODE_ASYMM)
> > +               return "asymm";
> > +       else
> > +               return "sync";
> > +}
> 
> This creates an inconsistency, because for
> kasan_stack_collection_enabled(), kasan_async_fault_possible(), and
> kasan_sync_fault_possible() there are !KASAN_HW_TAGS stubs.
> 
> A stub for kasan_mode_info() if !KASAN_HW_TAGS appears useless
> though,
> and I wouldn't know what its return value should be.
> 
> Do you expect this helper to be used outside hw_tags.c? If not,
> perhaps just move it into hw_tags.c.

The helper will be used only in hw_tags.c.
I will move it into hw_tags.c in v3.

Thanks.

> 
> Thanks,
> -- Marco


      reply	other threads:[~2021-10-20  7:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-20  6:12 Kuan-Ying Lee
2021-10-20  7:23 ` Marco Elver
2021-10-20  7:46   ` Kuan-Ying Lee [this message]

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=c0d7c2aa14cc569d5ad95dc750bb6cc1727a042c.camel@mediatek.com \
    --to=kuan-ying.lee@mediatek.com \
    --cc=Yee.Lee@mediatek.com \
    --cc=akpm@linux-foundation.org \
    --cc=andreyknvl@gmail.com \
    --cc=catalin.marinas@arm.com \
    --cc=chinwen.chang@mediatek.com \
    --cc=dvyukov@google.com \
    --cc=elver@google.com \
    --cc=glider@google.com \
    --cc=kasan-dev@googlegroups.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-mm@kvack.org \
    --cc=matthias.bgg@gmail.com \
    --cc=nicholas.tang@mediatek.com \
    --cc=ryabinin.a.a@gmail.com \
    --cc=will@kernel.org \
    /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

all inboxes | Powered by JetHome®