LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Axtens <dja@axtens.net>
To: aneesh.kumar@linux.ibm.com, christophe.leroy@c-s.fr,
	bsingharora@gmail.com
Cc: linuxppc-dev@lists.ozlabs.org, kasan-dev@googlegroups.com,
	Daniel Axtens <dja@axtens.net>
Subject: [RFC PATCH 6/7] kasan: allow arches to hook into global registration
Date: Thu, 23 May 2019 15:21:19 +1000	[thread overview]
Message-ID: <20190523052120.18459-7-dja@axtens.net> (raw)
In-Reply-To: <20190523052120.18459-1-dja@axtens.net>

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@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


  parent reply	other threads:[~2019-05-23  5:30 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-23  5:21 [RFC PATCH 0/7] powerpc: KASAN for 64-bit 3s radix Daniel Axtens
2019-05-23  5:21 ` [RFC PATCH 1/7] kasan: do not open-code addr_has_shadow Daniel Axtens
2019-05-23  5:21 ` [RFC PATCH 2/7] kasan: allow architectures to manage the memory-to-shadow mapping Daniel Axtens
2019-05-23  5:21 ` [RFC PATCH 3/7] kasan: allow architectures to provide an outline readiness check Daniel Axtens
2019-05-23  6:14   ` Christophe Leroy
2019-05-23  5:21 ` [RFC PATCH 4/7] powerpc: KASAN for 64bit Book3E Daniel Axtens
2019-05-23  6:15   ` Christophe Leroy
2019-05-23  5:21 ` [RFC PATCH 5/7] kasan: allow arches to provide their own early shadow setup Daniel Axtens
2019-05-23  5:21 ` Daniel Axtens [this message]
2019-05-23  6:31   ` [RFC PATCH 6/7] kasan: allow arches to hook into global registration Christophe Leroy
2019-05-23  6:59     ` Daniel Axtens
2019-05-23  5:21 ` [RFC PATCH 7/7] powerpc: Book3S 64-bit "heavyweight" KASAN support Daniel Axtens
2019-05-23  6:10 ` [RFC PATCH 0/7] powerpc: KASAN for 64-bit 3s radix Christophe Leroy
2019-05-23  6:18   ` Daniel Axtens

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190523052120.18459-7-dja@axtens.net \
    --to=dja@axtens.net \
    --cc=aneesh.kumar@linux.ibm.com \
    --cc=bsingharora@gmail.com \
    --cc=christophe.leroy@c-s.fr \
    --cc=kasan-dev@googlegroups.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox