summaryrefslogtreecommitdiffstats
path: root/lib/test_kasan_module.c
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2021-11-05 21:36:12 +0100
committerLinus Torvalds <torvalds@linux-foundation.org>2021-11-06 21:30:33 +0100
commitd73dad4eb5ad8c31ac9cf358eb5a55825bafe706 (patch)
tree34585db952518be749bae401a60156977f93b540 /lib/test_kasan_module.c
parentmm: debug_vm_pgtable: don't use __P000 directly (diff)
downloadlinux-d73dad4eb5ad8c31ac9cf358eb5a55825bafe706.tar.xz
linux-d73dad4eb5ad8c31ac9cf358eb5a55825bafe706.zip
kasan: test: bypass __alloc_size checks
Intentional overflows, as performed by the KASAN tests, are detected at compile time[1] (instead of only at run-time) with the addition of __alloc_size. Fix this by forcing the compiler into not being able to trust the size used following the kmalloc()s. [1] https://lore.kernel.org/lkml/20211005184717.65c6d8eb39350395e387b71f@linux-foundation.org Link: https://lkml.kernel.org/r/20211006181544.1670992-1-keescook@chromium.org Signed-off-by: Kees Cook <keescook@chromium.org> Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com> Cc: Alexander Potapenko <glider@google.com> Cc: Andrey Konovalov <andreyknvl@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 'lib/test_kasan_module.c')
-rw-r--r--lib/test_kasan_module.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/test_kasan_module.c b/lib/test_kasan_module.c
index 7ebf433edef3..b112cbc835e9 100644
--- a/lib/test_kasan_module.c
+++ b/lib/test_kasan_module.c
@@ -35,6 +35,8 @@ static noinline void __init copy_user_test(void)
return;
}
+ OPTIMIZER_HIDE_VAR(size);
+
pr_info("out-of-bounds in copy_from_user()\n");
unused = copy_from_user(kmem, usermem, size + 1);