kasan: move kasan_get_alloc/free_track definitions
authorAndrey Konovalov <andreyknvl@google.com>
Mon, 5 Sep 2022 21:05:35 +0000 (23:05 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 3 Oct 2022 21:02:59 +0000 (14:02 -0700)
Move the definitions of kasan_get_alloc/free_track() to report_*.c, as
they belong with other the reporting code.

Link: https://lkml.kernel.org/r/0cb15423956889b3905a0174b58782633bbbd72e.1662411799.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Reviewed-by: Marco Elver <elver@google.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Evgenii Stepanov <eugenis@google.com>
Cc: Peter Collingbourne <pcc@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/kasan/generic.c
mm/kasan/report_generic.c
mm/kasan/report_tags.c
mm/kasan/tags.c

index aff39af3c532a9b3dfb999e98f0009db3624cc13..d8b5590f9484bb6ce8ae5bee152f361bc41c4de8 100644 (file)
@@ -512,24 +512,3 @@ void kasan_save_free_info(struct kmem_cache *cache, void *object)
        /* The object was freed and has free track set. */
        *(u8 *)kasan_mem_to_shadow(object) = KASAN_SLAB_FREETRACK;
 }
-
-struct kasan_track *kasan_get_alloc_track(struct kmem_cache *cache,
-                                               void *object)
-{
-       struct kasan_alloc_meta *alloc_meta;
-
-       alloc_meta = kasan_get_alloc_meta(cache, object);
-       if (!alloc_meta)
-               return NULL;
-
-       return &alloc_meta->alloc_track;
-}
-
-struct kasan_track *kasan_get_free_track(struct kmem_cache *cache,
-                                               void *object, u8 tag)
-{
-       if (*(u8 *)kasan_mem_to_shadow(object) != KASAN_SLAB_FREETRACK)
-               return NULL;
-       /* Free meta must be present with KASAN_SLAB_FREETRACK. */
-       return &kasan_get_free_meta(cache, object)->free_track;
-}
index 348dc207d46230c1259243f1eeac79ac30b50db5..74d21786ef091b1e1f64f84bcd7a01a87dd3f4be 100644 (file)
@@ -127,6 +127,27 @@ const char *kasan_get_bug_type(struct kasan_report_info *info)
        return get_wild_bug_type(info);
 }
 
+struct kasan_track *kasan_get_alloc_track(struct kmem_cache *cache,
+                                               void *object)
+{
+       struct kasan_alloc_meta *alloc_meta;
+
+       alloc_meta = kasan_get_alloc_meta(cache, object);
+       if (!alloc_meta)
+               return NULL;
+
+       return &alloc_meta->alloc_track;
+}
+
+struct kasan_track *kasan_get_free_track(struct kmem_cache *cache,
+                                               void *object, u8 tag)
+{
+       if (*(u8 *)kasan_mem_to_shadow(object) != KASAN_SLAB_FREETRACK)
+               return NULL;
+       /* Free meta must be present with KASAN_SLAB_FREETRACK. */
+       return &kasan_get_free_meta(cache, object)->free_track;
+}
+
 void kasan_metadata_fetch_row(char *buffer, void *row)
 {
        memcpy(buffer, kasan_mem_to_shadow(row), META_BYTES_PER_ROW);
index 35cf3cae4aa4587ecf7a3a9ee766a6ababd00111..79b6497d8a81b4f10c707ba52d3e45212b843e77 100644 (file)
@@ -21,3 +21,15 @@ const char *kasan_get_bug_type(struct kasan_report_info *info)
 
        return "invalid-access";
 }
+
+struct kasan_track *kasan_get_alloc_track(struct kmem_cache *cache,
+                                               void *object)
+{
+       return NULL;
+}
+
+struct kasan_track *kasan_get_free_track(struct kmem_cache *cache,
+                                               void *object, u8 tag)
+{
+       return NULL;
+}
index fd11d10a4ffc60c3ef3d619ab6e34b277b110c31..39a0481e5228c2d6096149e829edcd86147f5176 100644 (file)
@@ -24,15 +24,3 @@ void kasan_save_alloc_info(struct kmem_cache *cache, void *object, gfp_t flags)
 void kasan_save_free_info(struct kmem_cache *cache, void *object)
 {
 }
-
-struct kasan_track *kasan_get_alloc_track(struct kmem_cache *cache,
-                                               void *object)
-{
-       return NULL;
-}
-
-struct kasan_track *kasan_get_free_track(struct kmem_cache *cache,
-                                               void *object, u8 tag)
-{
-       return NULL;
-}