diff mbox series

[mm,08/22] kasan: check CONFIG_KASAN_KUNIT_TEST instead of CONFIG_KUNIT

Message ID 223592d38d2a601a160a3b2b3d5a9f9090350e62.1646237226.git.andreyknvl@google.com (mailing list archive)
State New
Headers show
Series kasan: report clean-ups and improvements | expand

Commit Message

andrey.konovalov@linux.dev March 2, 2022, 4:36 p.m. UTC
From: Andrey Konovalov <andreyknvl@google.com>

Check the more specific CONFIG_KASAN_KUNIT_TEST config option when
defining things related to KUnit-compatible KASAN tests instead of
CONFIG_KUNIT.

Also put the kunit_kasan_status definition next to the definitons of
other KASAN-related structs.

Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
---
 mm/kasan/kasan.h  | 18 ++++++++----------
 mm/kasan/report.c |  2 +-
 2 files changed, 9 insertions(+), 11 deletions(-)

Comments

Alexander Potapenko March 2, 2022, 5:57 p.m. UTC | #1
On Wed, Mar 2, 2022 at 5:37 PM <andrey.konovalov@linux.dev> wrote:

> From: Andrey Konovalov <andreyknvl@google.com>
>
> Check the more specific CONFIG_KASAN_KUNIT_TEST config option when
> defining things related to KUnit-compatible KASAN tests instead of
> CONFIG_KUNIT.
>
> Also put the kunit_kasan_status definition next to the definitons of
> other KASAN-related structs.
>
> Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
>
Reviewed-by: Alexander Potapenko <glider@google.com>


> ---
>  mm/kasan/kasan.h  | 18 ++++++++----------
>  mm/kasan/report.c |  2 +-
>  2 files changed, 9 insertions(+), 11 deletions(-)
>
> diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h
> index 4447df0d7343..cc7162a9f304 100644
> --- a/mm/kasan/kasan.h
> +++ b/mm/kasan/kasan.h
> @@ -7,16 +7,6 @@
>  #include <linux/kfence.h>
>  #include <linux/stackdepot.h>
>
> -#if IS_ENABLED(CONFIG_KUNIT)
> -
> -/* Used in KUnit-compatible KASAN tests. */
> -struct kunit_kasan_status {
> -       bool report_found;
> -       bool sync_fault;
> -};
> -
> -#endif
> -
>  #ifdef CONFIG_KASAN_HW_TAGS
>
>  #include <linux/static_key.h>
> @@ -224,6 +214,14 @@ struct kasan_free_meta {
>  #endif
>  };
>
> +#if IS_ENABLED(CONFIG_KASAN_KUNIT_TEST)
> +/* Used in KUnit-compatible KASAN tests. */
> +struct kunit_kasan_status {
> +       bool report_found;
> +       bool sync_fault;
> +};
> +#endif
> +
>  struct kasan_alloc_meta *kasan_get_alloc_meta(struct kmem_cache *cache,
>                                                 const void *object);
>  #ifdef CONFIG_KASAN_GENERIC
> diff --git a/mm/kasan/report.c b/mm/kasan/report.c
> index 59db81211b8a..93543157d3e1 100644
> --- a/mm/kasan/report.c
> +++ b/mm/kasan/report.c
> @@ -356,7 +356,7 @@ static bool report_enabled(void)
>         return !test_and_set_bit(KASAN_BIT_REPORTED, &kasan_flags);
>  }
>
> -#if IS_ENABLED(CONFIG_KUNIT)
> +#if IS_ENABLED(CONFIG_KASAN_KUNIT_TEST)
>  static void update_kunit_status(bool sync)
>  {
>         struct kunit *test;
> --
> 2.25.1
>
> --
> You received this message because you are subscribed to the Google Groups
> "kasan-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to kasan-dev+unsubscribe@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/kasan-dev/223592d38d2a601a160a3b2b3d5a9f9090350e62.1646237226.git.andreyknvl%40google.com
> .
>
diff mbox series

Patch

diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h
index 4447df0d7343..cc7162a9f304 100644
--- a/mm/kasan/kasan.h
+++ b/mm/kasan/kasan.h
@@ -7,16 +7,6 @@ 
 #include <linux/kfence.h>
 #include <linux/stackdepot.h>
 
-#if IS_ENABLED(CONFIG_KUNIT)
-
-/* Used in KUnit-compatible KASAN tests. */
-struct kunit_kasan_status {
-	bool report_found;
-	bool sync_fault;
-};
-
-#endif
-
 #ifdef CONFIG_KASAN_HW_TAGS
 
 #include <linux/static_key.h>
@@ -224,6 +214,14 @@  struct kasan_free_meta {
 #endif
 };
 
+#if IS_ENABLED(CONFIG_KASAN_KUNIT_TEST)
+/* Used in KUnit-compatible KASAN tests. */
+struct kunit_kasan_status {
+	bool report_found;
+	bool sync_fault;
+};
+#endif
+
 struct kasan_alloc_meta *kasan_get_alloc_meta(struct kmem_cache *cache,
 						const void *object);
 #ifdef CONFIG_KASAN_GENERIC
diff --git a/mm/kasan/report.c b/mm/kasan/report.c
index 59db81211b8a..93543157d3e1 100644
--- a/mm/kasan/report.c
+++ b/mm/kasan/report.c
@@ -356,7 +356,7 @@  static bool report_enabled(void)
 	return !test_and_set_bit(KASAN_BIT_REPORTED, &kasan_flags);
 }
 
-#if IS_ENABLED(CONFIG_KUNIT)
+#if IS_ENABLED(CONFIG_KASAN_KUNIT_TEST)
 static void update_kunit_status(bool sync)
 {
 	struct kunit *test;