[PATCH v2 1/2] arm: kasan: support CONFIG_KASAN_VMALLOC

Lecopzer Chen lecopzer.chen at mediatek.com
Sun Feb 13 08:06:56 PST 2022


Hi Linus
 
Thanks for your review.
 
> > -       kasan_populate_early_shadow(kasan_mem_to_shadow((void *)VMALLOC_START),
> > +       if (!IS_ENABLED(CONFIG_KASAN_VMALLOC))
> > +               kasan_populate_early_shadow(kasan_mem_to_shadow((void *)VMALLOC_START),
> > +                                           kasan_mem_to_shadow((void *)VMALLOC_END));
> > +
> > +       kasan_populate_early_shadow(kasan_mem_to_shadow((void *)VMALLOC_END),
> >                                     kasan_mem_to_shadow((void *)-1UL) + 1);
> 
> Where is this actually mapped?
> 
> Can you print out where
> kasan_mem_to_shadow((void *)VMALLOC_START)
> kasan_mem_to_shadow((void *)VMALLOC_END)
> as well as KASAN_SHADOW_START and KASAN_SHADOW_END
> points?
> 
> When I looked into this getting the shadow memory between
> KASAN_SHADOW_START and KASAN_SHADOW_END
> seemed like the big problem since this is static, so how is Kasan
> solving this now?

For quick answer:
As I knwon, the definition of KASAN_SHADOW_START and END

(@arch/arm/include/asm/kasan_def.h)
* 1) KASAN_SHADOW_START
 *   This value begins with the MODULE_VADDR's shadow address. It is the
 *   start of kernel virtual space....
 *
 * 2) KASAN_SHADOW_END
 *   This value is the 0x100000000's shadow address: the mapping that would
 *   be after the end of the kernel memory at 0xffffffff....

and the virt address of vmalloc for ARM32 is also between MODULE_VADDR and
0x100000000 (ZONE_HIGHMEM), so nothing needs to do.

If there is any cases may break this assumption, please correct me, thanks.

> 
> Please patch the picture in
> include/asm/kasan_def.h
> and the info in
> Documentation/arm/memory.rst
> so it clearly reflects where VMALLOC is shadowed.

Thanks for suggestion, Yes, we really do need to update doc for memory layout.
I'll study how to add it and provide in v3.







More information about the linux-arm-kernel mailing list