Skip to content

Commit

Permalink
kasan: add kasan mode messages when kasan init
Browse files Browse the repository at this point in the history
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://bugzilla.kernel.org/show_bug.cgi?id=212195 [1]
Link: https://lkml.kernel.org/r/20211020094850.4113-1-Kuan-Ying.Lee@mediatek.com
Signed-off-by: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com>
Reviewed-by: Marco Elver <elver@google.com>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Konovalov <andreyknvl@gmail.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: Chinwen Chang <chinwen.chang@mediatek.com>
Cc: Yee Lee <yee.lee@mediatek.com>
Cc: Nicholas Tang <nicholas.tang@mediatek.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
  • Loading branch information
Kuan-Ying Lee authored and Stephen Rothwell committed Oct 25, 2021
1 parent 8dfec87 commit c34b221
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion arch/arm64/mm/kasan_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
14 changes: 13 additions & 1 deletion mm/kasan/hw_tags.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@ static int __init early_kasan_flag_stacktrace(char *arg)
}
early_param("kasan.stacktrace", early_kasan_flag_stacktrace);

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";
}

/* kasan_init_hw_tags_cpu() is called for each CPU. */
void kasan_init_hw_tags_cpu(void)
{
Expand Down Expand Up @@ -177,7 +187,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)
Expand Down
2 changes: 1 addition & 1 deletion mm/kasan/sw_tags.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

/*
Expand Down

0 comments on commit c34b221

Please sign in to comment.