[PATCH mm v3 30/38] kasan, vmalloc: don't tag executable vmalloc allocations

Andrey Konovalov andreyknvl at gmail.com
Tue Dec 14 11:42:00 PST 2021


On Mon, Dec 13, 2021 at 10:54 PM <andrey.konovalov at linux.dev> wrote:
>

[...]

> @@ -3133,10 +3133,14 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
>          * (except for the should_skip_init() check) to make sure that memory
>          * is initialized under the same conditions regardless of the enabled
>          * KASAN mode.
> +        * Tag-based KASAN modes only assign tags to non-executable
> +        * allocations, see __kasan_unpoison_vmalloc().
>          */
>         kasan_flags = KASAN_VMALLOC_VM_ALLOC;
>         if (!want_init_on_free() && want_init_on_alloc(gfp_mask))
>                 kasan_flags |= KASAN_VMALLOC_INIT;
> +       if (pgprot_val(prot) == pgprot_val(pgprot_nx(prot)))

Can simply compare with PAGE_KERNEL here to match the check in
arch_vmalloc_pgprot_modify(). Will do in v4.

> +               kasan_flags |= KASAN_VMALLOC_NOEXEC;
>         addr = kasan_unpoison_vmalloc(addr, real_size, kasan_flags);
>
>         /*
> @@ -3844,7 +3848,7 @@ struct vm_struct **pcpu_get_vm_areas(const unsigned long *offsets,
>         for (area = 0; area < nr_vms; area++)
>                 vms[area]->addr = kasan_unpoison_vmalloc(vms[area]->addr,
>                                                          vms[area]->size,
> -                                                        KASAN_VMALLOC_NONE);
> +                                                        KASAN_VMALLOC_NOEXEC);
>
>         kfree(vas);
>         return vms;
> --
> 2.25.1
>



More information about the linux-arm-kernel mailing list