WSL2-Linux-Kernel/arch
Andrey Konovalov 36c4a73bf8 kasan, arm64: don't tag executable vmalloc allocations
Besides asking vmalloc memory to be executable via the prot argument of
__vmalloc_node_range() (see the previous patch), the kernel can skip that
bit and instead mark memory as executable via set_memory_x().

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.

Generic kernel code typically allocates memory via module_alloc() if it
intends to mark memory as executable.  (On arm64 module_alloc() uses
__vmalloc_node_range() without setting the executable bit).

Thus, reset pointer tags of pointers returned from module_alloc().

However, on arm64 there's an exception: the eBPF subsystem.  Instead of
using module_alloc(), it uses vmalloc() (via bpf_jit_alloc_exec()) to
allocate its JIT region.

Thus, reset pointer tags of pointers returned from bpf_jit_alloc_exec().

Resetting tags for these pointers results in untagged pointers being
passed to set_memory_x().  This causes conflicts in arithmetic checks in
change_memory_common(), as vm_struct->addr pointer returned by
find_vm_area() is tagged.

Reset pointer tag of find_vm_area(addr)->addr in change_memory_common().

Link: https://lkml.kernel.org/r/b7b2595423340cd7d76b770e5d519acf3b72f0ab.1643047180.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Marco Elver <elver@google.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.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: Linus Torvalds <torvalds@linux-foundation.org>
2022-03-24 19:06:48 -07:00
..
alpha Networking changes for 5.18. 2022-03-24 13:13:26 -07:00
arc
arm Networking changes for 5.18. 2022-03-24 13:13:26 -07:00
arm64 kasan, arm64: don't tag executable vmalloc allocations 2022-03-24 19:06:48 -07:00
csky
h8300
hexagon
ia64 flexible-array transformations for 5.18-rc1 2022-03-24 11:39:32 -07:00
m68k
microblaze
mips Networking changes for 5.18. 2022-03-24 13:13:26 -07:00
nios2
openrisc
parisc Networking changes for 5.18. 2022-03-24 13:13:26 -07:00
powerpc mm/migration: add trace events for THP migrations 2022-03-24 19:06:45 -07:00
riscv Merge branch 'akpm' (patches from Andrew) 2022-03-24 14:14:07 -07:00
s390 kasan, x86, arm64, s390: rename functions for modules shadow 2022-03-24 19:06:47 -07:00
sh flexible-array transformations for 5.18-rc1 2022-03-24 11:39:32 -07:00
sparc Networking changes for 5.18. 2022-03-24 13:13:26 -07:00
um flexible-array transformations for 5.18-rc1 2022-03-24 11:39:32 -07:00
x86 kasan, x86, arm64, s390: rename functions for modules shadow 2022-03-24 19:06:47 -07:00
xtensa Networking changes for 5.18. 2022-03-24 13:13:26 -07:00
.gitignore
Kconfig