Re: [PATCH] LoongArch: Add kernel address sanitizer support

From: Qing Zhang
Date: Thu Mar 30 2023 - 00:33:04 EST




On 2023/3/30 上午10:55, Andrey Konovalov wrote:
On Thu, Mar 30, 2023 at 4:06 AM Qing Zhang <zhangqing@xxxxxxxxxxx> wrote:

But I don't think you need this check here at all: addr_has_metadata
already checks that shadow exists.

On LongArch, there's a lot of holes between different segments, so kasan
shadow area is some different type of memory that we concatenate, we
can't use if (unlikely((void *)addr <
kasan_shadow_to_mem((void *)KASAN_SHADOW_START))) to determine the
validity, and in arch/loongarch/include/asm/kasan.h I construct invalid
NULL.

I get that, but you already added a special case for
__HAVE_ARCH_SHADOW_MAP to addr_has_metadata, so you can just call it?

ok, all the changes are going to be in v2.

Thanks,
-Qing
This is because in pagetable_init on loongarch/mips, we populate pmd/pud
with invalid_pmd_table/invalid_pud_table,

I see. Please add this into the patch description for v2.

So pmd_init/pud_init(p) is required, perhaps we define them as __weak in
mm/kasan/init.c, like mm/sparse-vmemmap.c.

Yes, this makes sense to do, so that KASAN doesn't depend on
definitions from sparse-vmemmap.c.

Thank you!