Re: [PATCH] kasan: Add explicit preconditions to kasan_report()

From: Andrey Konovalov
Date: Tue Jan 19 2021 - 15:58:45 EST


On Tue, Jan 19, 2021 at 9:32 PM Vincenzo Frascino
<vincenzo.frascino@xxxxxxx> wrote:
>
> This seems not working on arm64 because according to virt_addr_valid 0 is a
> valid virtual address, in fact:
>
> __is_lm_address(0) == true && pfn_valid(virt_to_pfn(0)) == true.
>
> An option could be to make an exception for virtual address 0 in
> addr_has_metadata() something like:
>
> static inline bool addr_has_metadata(const void *addr)
> {
> if ((u64)addr == 0)
> return false;

This sounds good to me, but we need to check for < PAGE_SIZE or
something like that, right? There's some limit below which accesses
are considered null-ptr-derefs.

> return (is_vmalloc_addr(addr) || virt_addr_valid(addr));

Do we need is_vmalloc_addr()? As we don't yet have vmalloc support for HW_TAGS.