summaryrefslogtreecommitdiff
path: root/mm/vmalloc.c
diff options
context:
space:
mode:
authorAndrey Konovalov <andreyknvl@google.com>2022-03-25 04:11:16 +0300
committerLinus Torvalds <torvalds@linux-foundation.org>2022-03-25 05:06:47 +0300
commit01d92c7f358ce892279ca830cf6ccf2862a17d1c (patch)
tree4775cfc6f7efb01e8d9a876f46f7012949ae4b0a /mm/vmalloc.c
parent1d96320f8d5320423737da61e6e6937f6b475b5c (diff)
downloadlinux-01d92c7f358ce892279ca830cf6ccf2862a17d1c.tar.xz
kasan, vmalloc, arm64: mark vmalloc mappings as pgprot_tagged
HW_TAGS KASAN relies on ARM Memory Tagging Extension (MTE). With MTE, a memory region must be mapped as MT_NORMAL_TAGGED to allow setting memory tags via MTE-specific instructions. Add proper protection bits to vmalloc() allocations. These allocations are always backed by page_alloc pages, so the tags will actually be getting set on the corresponding physical memory. Link: https://lkml.kernel.org/r/983fc33542db2f6b1e77b34ca23448d4640bbb9e.1643047180.git.andreyknvl@google.com Signed-off-by: Andrey Konovalov <andreyknvl@google.com> Co-developed-by: Vincenzo Frascino <vincenzo.frascino@arm.com> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.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: Will Deacon <will@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/vmalloc.c')
-rw-r--r--mm/vmalloc.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 1ab1f1b2f5b7..8530d86c3e58 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -3128,6 +3128,15 @@ again:
goto fail;
}
+ /*
+ * Modify protection bits to allow tagging.
+ * This must be done before mapping by __vmalloc_area_node().
+ */
+ if (kasan_hw_tags_enabled() &&
+ pgprot_val(prot) == pgprot_val(PAGE_KERNEL))
+ prot = arch_vmap_pgprot_tagged(prot);
+
+ /* Allocate physical pages and map them into vmalloc space. */
addr = __vmalloc_area_node(area, gfp_mask, prot, shift, node);
if (!addr)
goto fail;