summaryrefslogtreecommitdiffstats
path: root/mm/kasan/generic.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/generic.c
parent158f25522ca8cc87f512a03ed5e2a5923bd37eb3 (diff)
downloadlinux-af3751f3c2b6282bebcb56c35bbe4c8b671f80aa.tar.gz
linux-af3751f3c2b6282bebcb56c35bbe4c8b671f80aa.tar.bz2
linux-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/generic.c')
-rw-r--r--mm/kasan/generic.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/mm/kasan/generic.c b/mm/kasan/generic.c
index 53cbf28859b5..c3f5ba7a294a 100644
--- a/mm/kasan/generic.c
+++ b/mm/kasan/generic.c
@@ -163,6 +163,9 @@ static __always_inline bool check_region_inline(unsigned long addr,
size_t size, bool write,
unsigned long ret_ip)
{
+ if (!kasan_arch_is_ready())
+ return true;
+
if (unlikely(size == 0))
return true;