| From: Andrey Konovalov <andreyknvl@google.com> |
| Subject: another fix for "kasan: improve vmalloc tests" |
| |
| set_memory_rw/ro() are not exported to be used in modules and thus |
| cannot be used in KUnit-compatible KASAN tests. |
| |
| Do the checks that rely on these functions only when the tests are |
| built-in. |
| |
| Link: https://lkml.kernel.org/r/019ac41602e0c4a7dfe96dc8158a95097c2b2ebd.1645554036.git.andreyknvl@google.com |
| Signed-off-by: Andrey Konovalov <andreyknvl@google.com> |
| Reported-by: kernel test robot <lkp@intel.com> |
| Reviewed-by: Marco Elver <elver@google.com> |
| Signed-off-by: Andrew Morton <akpm@linux-foundation.org> |
| --- |
| |
| lib/test_kasan.c | 2 ++ |
| 1 file changed, 2 insertions(+) |
| |
| --- a/lib/test_kasan.c~kasan-improve-vmalloc-tests-fix-3 |
| +++ a/lib/test_kasan.c |
| @@ -1084,11 +1084,13 @@ static void vmalloc_helpers_tags(struct |
| KUNIT_ASSERT_TRUE(test, is_vmalloc_addr(ptr)); |
| KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vmalloc_to_page(ptr)); |
| |
| +#if !IS_MODULE(CONFIG_KASAN_KUNIT_TEST) |
| /* Make sure vmalloc'ed memory permissions can be changed. */ |
| rv = set_memory_ro((unsigned long)ptr, 1); |
| KUNIT_ASSERT_GE(test, rv, 0); |
| rv = set_memory_rw((unsigned long)ptr, 1); |
| KUNIT_ASSERT_GE(test, rv, 0); |
| +#endif |
| |
| vfree(ptr); |
| } |
| _ |