* [PATCH mm v2] another fix for "kasan: improve vmalloc tests"
@ 2022-02-22 18:26 andrey.konovalov
2022-02-22 18:48 ` Marco Elver
0 siblings, 1 reply; 2+ messages in thread
From: andrey.konovalov @ 2022-02-22 18:26 UTC (permalink / raw)
To: Andrew Morton
Cc: Andrey Konovalov, Marco Elver, Alexander Potapenko,
Dmitry Vyukov, Andrey Ryabinin, kasan-dev, linux-mm,
linux-kernel, Andrey Konovalov, kernel test robot
From: Andrey Konovalov <andreyknvl@google.com>
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.
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
---
Changes v1->v2:
- Hide checks under #if instead of dropping.
---
lib/test_kasan.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lib/test_kasan.c b/lib/test_kasan.c
index ef99d81fe8b3..c4b7eb2bad77 100644
--- a/lib/test_kasan.c
+++ b/lib/test_kasan.c
@@ -1083,11 +1083,13 @@ static void vmalloc_helpers_tags(struct kunit *test)
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);
}
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH mm v2] another fix for "kasan: improve vmalloc tests"
2022-02-22 18:26 [PATCH mm v2] another fix for "kasan: improve vmalloc tests" andrey.konovalov
@ 2022-02-22 18:48 ` Marco Elver
0 siblings, 0 replies; 2+ messages in thread
From: Marco Elver @ 2022-02-22 18:48 UTC (permalink / raw)
To: andrey.konovalov
Cc: Andrew Morton, Andrey Konovalov, Alexander Potapenko,
Dmitry Vyukov, Andrey Ryabinin, kasan-dev, linux-mm,
linux-kernel, Andrey Konovalov, kernel test robot
On Tue, 22 Feb 2022 at 19:26, <andrey.konovalov@linux.dev> wrote:
>
> From: Andrey Konovalov <andreyknvl@google.com>
>
> 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.
>
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Looks reasonable, thanks.
Reviewed-by: Marco Elver <elver@google.com>
> ---
>
> Changes v1->v2:
> - Hide checks under #if instead of dropping.
> ---
> lib/test_kasan.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/lib/test_kasan.c b/lib/test_kasan.c
> index ef99d81fe8b3..c4b7eb2bad77 100644
> --- a/lib/test_kasan.c
> +++ b/lib/test_kasan.c
> @@ -1083,11 +1083,13 @@ static void vmalloc_helpers_tags(struct kunit *test)
> 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);
> }
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-02-22 18:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-22 18:26 [PATCH mm v2] another fix for "kasan: improve vmalloc tests" andrey.konovalov
2022-02-22 18:48 ` Marco Elver
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.