aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Konovalov <[email protected]>2021-02-24 12:06:02 -0800
committerLinus Torvalds <[email protected]>2021-02-24 13:38:31 -0800
commitd82dc3a40d12c6eea15c18d24c0bdbc887d0e7c6 (patch)
tree8cd903c892ad056a63867fb606829eb3b4bd882e
parent115161354d0e0af6fc07dcbbf0fc4e7574d32cd6 (diff)
kasan: don't run tests when KASAN is not enabled
Don't run KASAN tests when it's disabled with kasan.mode=off to avoid corrupting kernel memory. Link: https://linux-review.googlesource.com/id/I6447af436a69a94bfc35477f6bf4e2122948355e Link: https://lkml.kernel.org/r/25bd4fb5cae7b421d806a1f33fb633edd313f0c7.1610733117.git.andreyknvl@google.com Signed-off-by: Andrey Konovalov <[email protected]> Reviewed-by: Marco Elver <[email protected]> Reviewed-by: Alexander Potapenko <[email protected]> Cc: Andrey Ryabinin <[email protected]> Cc: Branislav Rankov <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Dmitry Vyukov <[email protected]> Cc: Evgenii Stepanov <[email protected]> Cc: Kevin Brodsky <[email protected]> Cc: Peter Collingbourne <[email protected]> Cc: Vincenzo Frascino <[email protected]> Cc: Will Deacon <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
-rw-r--r--lib/test_kasan.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/test_kasan.c b/lib/test_kasan.c
index b04729b61d1d..25576303897b 100644
--- a/lib/test_kasan.c
+++ b/lib/test_kasan.c
@@ -47,6 +47,11 @@ static bool multishot;
*/
static int kasan_test_init(struct kunit *test)
{
+ if (!kasan_enabled()) {
+ kunit_err(test, "can't run KASAN tests with KASAN disabled");
+ return -1;
+ }
+
multishot = kasan_save_enable_multi_shot();
kasan_set_tagging_report_once(false);
return 0;