[RFC PATCH 6/7] kasan: allow arches to hook into global registration
Daniel Axtens
dja at axtens.net
Thu May 23 15:21:19 AEST 2019
Not all arches have a specific space carved out for modules -
some, such as powerpc, just use regular vmalloc space. Therefore,
globals in these modules cannot be backed by real shadow memory.
In order to allow arches to perform this check, add a hook.
Signed-off-by: Daniel Axtens <dja at axtens.net>
---
include/linux/kasan.h | 5 +++++
mm/kasan/generic.c | 3 +++
2 files changed, 8 insertions(+)
diff --git a/include/linux/kasan.h b/include/linux/kasan.h
index dfee2b42d799..4752749e4797 100644
--- a/include/linux/kasan.h
+++ b/include/linux/kasan.h
@@ -18,6 +18,11 @@ struct task_struct;
static inline bool kasan_arch_is_ready(void) { return true; }
#endif
+#ifndef kasan_arch_can_register_global
+static inline bool kasan_arch_can_register_global(const void * addr) { return true; }
+#endif
+
+
#ifndef ARCH_HAS_KASAN_EARLY_SHADOW
extern unsigned char kasan_early_shadow_page[PAGE_SIZE];
extern pte_t kasan_early_shadow_pte[PTRS_PER_PTE];
diff --git a/mm/kasan/generic.c b/mm/kasan/generic.c
index 0336f31bbae3..935b06f659a0 100644
--- a/mm/kasan/generic.c
+++ b/mm/kasan/generic.c
@@ -208,6 +208,9 @@ static void register_global(struct kasan_global *global)
{
size_t aligned_size = round_up(global->size, KASAN_SHADOW_SCALE_SIZE);
+ if (!kasan_arch_can_register_global(global->beg))
+ return;
+
kasan_unpoison_shadow(global->beg, global->size);
kasan_poison_shadow(global->beg + aligned_size,
--
2.19.1
More information about the Linuxppc-dev
mailing list