The patch titled Subject: kasan: export HW_TAGS symbols for KUnit tests has been removed from the -mm tree. Its filename was kasan-arm64-allow-using-kunit-tests-with-hw_tags-mode-fix.patch This patch was dropped because it was folded into kasan-arm64-allow-using-kunit-tests-with-hw_tags-mode.patch ------------------------------------------------------ From: Andrey Konovalov <andreyknvl@xxxxxxxxxx> Subject: kasan: export HW_TAGS symbols for KUnit tests Currently, building KASAN-KUnit tests as a module fails with: ERROR: modpost: "mte_enable_kernel" [lib/test_kasan.ko] undefined! ERROR: modpost: "mte_set_report_once" [lib/test_kasan.ko] undefined! This change adds KASAN wrappers for mte_enable_kernel() and mte_set_report_once() and only defines and exports them when KASAN-KUnit tests are enabled. The wrappers aren't defined when tests aren't enabled to avoid misuse. The mte_() functions aren't exported directly to avoid having low-level KASAN ifdefs in the arch code. Link: https://lkml.kernel.org/r/e7eeb252da408b08f0c81b950a55fb852f92000b.1613155970.git.andreyknvl@xxxxxxxxxx Signed-off-by: Andrey Konovalov <andreyknvl@xxxxxxxxxx> Cc: Catalin Marinas <catalin.marinas@xxxxxxx> Cc: Vincenzo Frascino <vincenzo.frascino@xxxxxxx> Cc: Alexander Potapenko <glider@xxxxxxxxxx> Cc: Andrey Ryabinin <aryabinin@xxxxxxxxxxxxx> Cc: Branislav Rankov <Branislav.Rankov@xxxxxxx> Cc: Dmitry Vyukov <dvyukov@xxxxxxxxxx> Cc: Evgenii Stepanov <eugenis@xxxxxxxxxx> Cc: Kevin Brodsky <kevin.brodsky@xxxxxxx> Cc: Marco Elver <elver@xxxxxxxxxx> Cc: Peter Collingbourne <pcc@xxxxxxxxxx> Cc: Will Deacon <will.deacon@xxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- lib/test_kasan.c | 6 +++--- mm/kasan/hw_tags.c | 16 ++++++++++++++++ mm/kasan/kasan.h | 12 ++++++++++++ 3 files changed, 31 insertions(+), 3 deletions(-) --- a/lib/test_kasan.c~kasan-arm64-allow-using-kunit-tests-with-hw_tags-mode-fix +++ a/lib/test_kasan.c @@ -48,13 +48,13 @@ static bool multishot; static int kasan_test_init(struct kunit *test) { multishot = kasan_save_enable_multi_shot(); - hw_set_tagging_report_once(false); + kasan_set_tagging_report_once(false); return 0; } static void kasan_test_exit(struct kunit *test) { - hw_set_tagging_report_once(true); + kasan_set_tagging_report_once(true); kasan_restore_multi_shot(multishot); } @@ -85,7 +85,7 @@ static void kasan_test_exit(struct kunit fail_data.report_found); \ if (IS_ENABLED(CONFIG_KASAN_HW_TAGS)) { \ if (fail_data.report_found) \ - hw_enable_tagging(); \ + kasan_enable_tagging(); \ migrate_enable(); \ } \ } while (0) --- a/mm/kasan/hw_tags.c~kasan-arm64-allow-using-kunit-tests-with-hw_tags-mode-fix +++ a/mm/kasan/hw_tags.c @@ -185,3 +185,19 @@ struct kasan_track *kasan_get_free_track return &alloc_meta->free_track[0]; } + +#if IS_ENABLED(CONFIG_KASAN_KUNIT_TEST) + +void kasan_set_tagging_report_once(bool state) +{ + hw_set_tagging_report_once(state); +} +EXPORT_SYMBOL_GPL(kasan_set_tagging_report_once); + +void kasan_enable_tagging(void) +{ + hw_enable_tagging(); +} +EXPORT_SYMBOL_GPL(kasan_enable_tagging); + +#endif --- a/mm/kasan/kasan.h~kasan-arm64-allow-using-kunit-tests-with-hw_tags-mode-fix +++ a/mm/kasan/kasan.h @@ -307,6 +307,18 @@ static inline const void *arch_kasan_set #endif /* CONFIG_KASAN_HW_TAGS */ +#if defined(CONFIG_KASAN_HW_TAGS) && IS_ENABLED(CONFIG_KASAN_KUNIT_TEST) + +void kasan_set_tagging_report_once(bool state); +void kasan_enable_tagging(void); + +#else /* CONFIG_KASAN_HW_TAGS || CONFIG_KASAN_KUNIT_TEST */ + +static inline void kasan_set_tagging_report_once(bool state) { } +static inline void kasan_enable_tagging(void) { } + +#endif /* CONFIG_KASAN_HW_TAGS || CONFIG_KASAN_KUNIT_TEST */ + #ifdef CONFIG_KASAN_SW_TAGS u8 kasan_random_tag(void); #elif defined(CONFIG_KASAN_HW_TAGS) _ Patches currently in -mm which might be from andreyknvl@xxxxxxxxxx are kasan-prefix-global-functions-with-kasan_.patch kasan-clarify-hw_tags-impact-on-tbi.patch kasan-clean-up-comments-in-tests.patch kasan-add-macros-to-simplify-checking-test-constraints.patch kasan-add-match-all-tag-tests.patch kasan-arm64-allow-using-kunit-tests-with-hw_tags-mode.patch kasan-rename-config_test_kasan_module.patch kasan-add-compiler-barriers-to-kunit_expect_kasan_fail.patch kasan-adapt-kmalloc_uaf2-test-to-hw_tags-mode.patch kasan-fix-memory-corruption-in-kasan_bitops_tags-test.patch kasan-move-_ret_ip_-to-inline-wrappers.patch kasan-fix-bug-detection-via-ksize-for-hw_tags-mode.patch kasan-add-proper-page-allocator-tests.patch kasan-add-a-test-for-kmem_cache_alloc-free_bulk.patch kasan-dont-run-tests-when-kasan-is-not-enabled.patch kfence-kasan-make-kfence-compatible-with-kasan-fix-2.patch kasan-mm-dont-save-alloc-stacks-twice.patch kasan-mm-optimize-kmalloc-poisoning.patch kasan-optimize-large-kmalloc-poisoning.patch kasan-clean-up-setting-free-info-in-kasan_slab_free.patch kasan-unify-large-kfree-checks.patch kasan-rework-krealloc-tests.patch kasan-mm-fail-krealloc-on-freed-objects.patch kasan-mm-optimize-krealloc-poisoning.patch kasan-ensure-poisoning-size-alignment.patch arm64-kasan-simplify-and-inline-mte-functions.patch kasan-inline-hw_tags-helper-functions.patch kasan-clarify-that-only-first-bug-is-reported-in-hw_tags.patch