aboutsummaryrefslogtreecommitdiffstats
path: root/mm/kasan/common.c
diff options
context:
space:
mode:
authorDaniel Axtens <dja@axtens.net>2021-06-28 19:40:42 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2021-06-29 10:53:53 -0700
commitaf3751f3c2b6282bebcb56c35bbe4c8b671f80aa (patch)
tree1bfdeaffdc16132fe926773b99edee86bb4e99fc /mm/kasan/common.c
parentkasan: allow an architecture to disable inline instrumentation (diff)
downloadlinux-dev-af3751f3c2b6282bebcb56c35bbe4c8b671f80aa.tar.xz
linux-dev-af3751f3c2b6282bebcb56c35bbe4c8b671f80aa.zip
kasan: allow architectures to provide an outline readiness check
Allow architectures to define a kasan_arch_is_ready() hook that bails out of any function that's about to touch the shadow unless the arch says that it is ready for the memory to be accessed. This is fairly uninvasive and should have a negligible performance penalty. This will only work in outline mode, so an arch must specify ARCH_DISABLE_KASAN_INLINE if it requires this. Link: https://lkml.kernel.org/r/20210624034050.511391-3-dja@axtens.net Signed-off-by: Daniel Axtens <dja@axtens.net> Reviewed-by: Marco Elver <elver@google.com> Suggested-by: Christophe Leroy <christophe.leroy@csgroup.eu> Reviewed-by: Andrey Konovalov <andreyknvl@gmail.com> Cc: Balbir Singh <bsingharora@gmail.com> Cc: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> Cc: Alexander Potapenko <glider@google.com> Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com> Cc: Dmitry Vyukov <dvyukov@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/kasan/common.c')
-rw-r--r--mm/kasan/common.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/mm/kasan/common.c b/mm/kasan/common.c
index 2586d3718600..267500896b1e 100644
--- a/mm/kasan/common.c
+++ b/mm/kasan/common.c
@@ -331,6 +331,9 @@ static inline bool ____kasan_slab_free(struct kmem_cache *cache, void *object,
u8 tag;
void *tagged_object;
+ if (!kasan_arch_is_ready())
+ return false;
+
tag = get_tag(object);
tagged_object = object;
object = kasan_reset_tag(object);