All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH mm] another fix for "kasan: improve vmalloc tests"
@ 2022-02-22 17:10 andrey.konovalov
  2022-02-22 17:50 ` Marco Elver
  0 siblings, 1 reply; 5+ messages in thread
From: andrey.konovalov @ 2022-02-22 17:10 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.

Drop the checks that rely on these functions.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
---
 lib/test_kasan.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/lib/test_kasan.c b/lib/test_kasan.c
index ef99d81fe8b3..448194bbc41d 100644
--- a/lib/test_kasan.c
+++ b/lib/test_kasan.c
@@ -1083,12 +1083,6 @@ 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));
 
-	/* 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);
-
 	vfree(ptr);
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH mm] another fix for "kasan: improve vmalloc tests"
  2022-02-22 17:10 [PATCH mm] another fix for "kasan: improve vmalloc tests" andrey.konovalov
@ 2022-02-22 17:50 ` Marco Elver
  2022-02-22 18:08   ` Andrey Konovalov
  0 siblings, 1 reply; 5+ messages in thread
From: Marco Elver @ 2022-02-22 17:50 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 18:10, <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.
>
> Drop the checks that rely on these functions.
>
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
> ---
>  lib/test_kasan.c | 6 ------
>  1 file changed, 6 deletions(-)
>
> diff --git a/lib/test_kasan.c b/lib/test_kasan.c
> index ef99d81fe8b3..448194bbc41d 100644
> --- a/lib/test_kasan.c
> +++ b/lib/test_kasan.c
> @@ -1083,12 +1083,6 @@ 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));
>
> -       /* 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);

You can still test it by checking 'ifdef MODULE'. You could add a
separate test which is skipped if MODULE is defined. Does that work?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH mm] another fix for "kasan: improve vmalloc tests"
  2022-02-22 17:50 ` Marco Elver
@ 2022-02-22 18:08   ` Andrey Konovalov
  2022-02-22 18:10     ` Marco Elver
  0 siblings, 1 reply; 5+ messages in thread
From: Andrey Konovalov @ 2022-02-22 18:08 UTC (permalink / raw)
  To: Marco Elver
  Cc: andrey.konovalov, Andrew Morton, Alexander Potapenko,
	Dmitry Vyukov, Andrey Ryabinin, kasan-dev,
	Linux Memory Management List, LKML, Andrey Konovalov,
	kernel test robot

On Tue, Feb 22, 2022 at 6:50 PM Marco Elver <elver@google.com> wrote:
>
> On Tue, 22 Feb 2022 at 18:10, <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.
> >
> > Drop the checks that rely on these functions.
> >
> > Reported-by: kernel test robot <lkp@intel.com>
> > Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
> > ---
> >  lib/test_kasan.c | 6 ------
> >  1 file changed, 6 deletions(-)
> >
> > diff --git a/lib/test_kasan.c b/lib/test_kasan.c
> > index ef99d81fe8b3..448194bbc41d 100644
> > --- a/lib/test_kasan.c
> > +++ b/lib/test_kasan.c
> > @@ -1083,12 +1083,6 @@ 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));
> >
> > -       /* 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);
>
> You can still test it by checking 'ifdef MODULE'. You could add a
> separate test which is skipped if MODULE is defined. Does that work?

Yes, putting it under ifdef will work. I thought that having a
discrepancy between built-in and module tests is weird, but I see the
kprobes tests doing this, so maybe it's not such a bad idea. Will do
in v2.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH mm] another fix for "kasan: improve vmalloc tests"
  2022-02-22 18:08   ` Andrey Konovalov
@ 2022-02-22 18:10     ` Marco Elver
  2022-02-22 18:27       ` Andrey Konovalov
  0 siblings, 1 reply; 5+ messages in thread
From: Marco Elver @ 2022-02-22 18:10 UTC (permalink / raw)
  To: Andrey Konovalov
  Cc: andrey.konovalov, Andrew Morton, Alexander Potapenko,
	Dmitry Vyukov, Andrey Ryabinin, kasan-dev,
	Linux Memory Management List, LKML, Andrey Konovalov,
	kernel test robot

On Tue, 22 Feb 2022 at 19:08, Andrey Konovalov <andreyknvl@gmail.com> wrote:
>
> On Tue, Feb 22, 2022 at 6:50 PM Marco Elver <elver@google.com> wrote:
> >
> > On Tue, 22 Feb 2022 at 18:10, <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.
> > >
> > > Drop the checks that rely on these functions.
> > >
> > > Reported-by: kernel test robot <lkp@intel.com>
> > > Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
> > > ---
> > >  lib/test_kasan.c | 6 ------
> > >  1 file changed, 6 deletions(-)
> > >
> > > diff --git a/lib/test_kasan.c b/lib/test_kasan.c
> > > index ef99d81fe8b3..448194bbc41d 100644
> > > --- a/lib/test_kasan.c
> > > +++ b/lib/test_kasan.c
> > > @@ -1083,12 +1083,6 @@ 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));
> > >
> > > -       /* 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);
> >
> > You can still test it by checking 'ifdef MODULE'. You could add a
> > separate test which is skipped if MODULE is defined. Does that work?
>
> Yes, putting it under ifdef will work. I thought that having a
> discrepancy between built-in and module tests is weird, but I see the
> kprobes tests doing this, so maybe it's not such a bad idea. Will do
> in v2.

Additionally you could have the test skip with kunit_skip(), so it's
at least visible. The code itself has to be #ifdef'd I guess because
set_memory_*() aren't even declared ifdef MODULE (I think?).

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH mm] another fix for "kasan: improve vmalloc tests"
  2022-02-22 18:10     ` Marco Elver
@ 2022-02-22 18:27       ` Andrey Konovalov
  0 siblings, 0 replies; 5+ messages in thread
From: Andrey Konovalov @ 2022-02-22 18:27 UTC (permalink / raw)
  To: Marco Elver
  Cc: andrey.konovalov, Andrew Morton, Alexander Potapenko,
	Dmitry Vyukov, Andrey Ryabinin, kasan-dev,
	Linux Memory Management List, LKML, Andrey Konovalov,
	kernel test robot

On Tue, Feb 22, 2022 at 7:11 PM Marco Elver <elver@google.com> wrote:
>
> On Tue, 22 Feb 2022 at 19:08, Andrey Konovalov <andreyknvl@gmail.com> wrote:
> >
> > On Tue, Feb 22, 2022 at 6:50 PM Marco Elver <elver@google.com> wrote:
> > >
> > > On Tue, 22 Feb 2022 at 18:10, <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.
> > > >
> > > > Drop the checks that rely on these functions.
> > > >
> > > > Reported-by: kernel test robot <lkp@intel.com>
> > > > Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
> > > > ---
> > > >  lib/test_kasan.c | 6 ------
> > > >  1 file changed, 6 deletions(-)
> > > >
> > > > diff --git a/lib/test_kasan.c b/lib/test_kasan.c
> > > > index ef99d81fe8b3..448194bbc41d 100644
> > > > --- a/lib/test_kasan.c
> > > > +++ b/lib/test_kasan.c
> > > > @@ -1083,12 +1083,6 @@ 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));
> > > >
> > > > -       /* 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);
> > >
> > > You can still test it by checking 'ifdef MODULE'. You could add a
> > > separate test which is skipped if MODULE is defined. Does that work?
> >
> > Yes, putting it under ifdef will work. I thought that having a
> > discrepancy between built-in and module tests is weird, but I see the
> > kprobes tests doing this, so maybe it's not such a bad idea. Will do
> > in v2.
>
> Additionally you could have the test skip with kunit_skip(), so it's
> at least visible. The code itself has to be #ifdef'd I guess because
> set_memory_*() aren't even declared ifdef MODULE (I think?).

I sent v2 with the simplest approach without an additional test. I
hope that's OK with you.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-02-22 18:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-22 17:10 [PATCH mm] another fix for "kasan: improve vmalloc tests" andrey.konovalov
2022-02-22 17:50 ` Marco Elver
2022-02-22 18:08   ` Andrey Konovalov
2022-02-22 18:10     ` Marco Elver
2022-02-22 18:27       ` Andrey Konovalov

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.