kasan, vmalloc: only tag normal vmalloc allocations
authorAndrey Konovalov <andreyknvl@google.com>
Mon, 28 Feb 2022 23:06:11 +0000 (10:06 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 1 Mar 2022 09:31:44 +0000 (20:31 +1100)
commitb49a902ba7ea46ba8fb4a80329c44a45aaabe3a2
treefeef2044b9cce0aab48a5df23e259edd6cb85d9e
parentfb568e9bfc85fbbb2b9c31640191c78b2e506dd0
kasan, vmalloc: only tag normal vmalloc allocations

The kernel can use to allocate executable memory.  The only supported way
to do that is via __vmalloc_node_range() with the executable bit set in
the prot argument.  (vmap() resets the bit via pgprot_nx()).

Once tag-based KASAN modes start tagging vmalloc allocations, executing
code from such allocations will lead to the PC register getting a tag,
which is not tolerated by the kernel.

Only tag the allocations for normal kernel pages.

Link: https://lkml.kernel.org/r/fbfd9939a4dc375923c9a5c6b9e7ab05c26b8c6b.1643047180.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Acked-by: Marco Elver <elver@google.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Evgenii Stepanov <eugenis@google.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Collingbourne <pcc@google.com>
Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
include/linux/kasan.h
mm/kasan/hw_tags.c
mm/kasan/shadow.c
mm/vmalloc.c