summaryrefslogtreecommitdiff
path: root/mm/kasan/common.c
diff options
context:
space:
mode:
authorAndrey Konovalov <andreyknvl@google.com>2022-09-05 23:05:19 +0200
committerAndrew Morton <akpm@linux-foundation.org>2022-10-03 14:02:56 -0700
commitccf643e6dacf33ec618bd64e10eb0347173ad482 (patch)
tree68dbea643d209a0590ec805e5c705fd70561caa2 /mm/kasan/common.c
parent196894a6e20273d78479bdf76eec3a741e72d31c (diff)
kasan: split save_alloc_info implementations
Provide standalone implementations of save_alloc_info() for the Generic and tag-based modes. For now, the implementations are the same, but they will diverge later in the series. Link: https://lkml.kernel.org/r/77f1a078489c1e859aedb5403f772e5e1f7410a0.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>
Diffstat (limited to 'mm/kasan/common.c')
-rw-r--r--mm/kasan/common.c13
1 files changed, 2 insertions, 11 deletions
diff --git a/mm/kasan/common.c b/mm/kasan/common.c
index 6a75237ed308..93e64e1b4413 100644
--- a/mm/kasan/common.c
+++ b/mm/kasan/common.c
@@ -424,15 +424,6 @@ void __kasan_slab_free_mempool(void *ptr, unsigned long ip)
}
}
-static void save_alloc_info(struct kmem_cache *cache, void *object, gfp_t flags)
-{
- struct kasan_alloc_meta *alloc_meta;
-
- alloc_meta = kasan_get_alloc_meta(cache, object);
- if (alloc_meta)
- kasan_set_track(&alloc_meta->alloc_track, flags);
-}
-
void * __must_check __kasan_slab_alloc(struct kmem_cache *cache,
void *object, gfp_t flags, bool init)
{
@@ -463,7 +454,7 @@ void * __must_check __kasan_slab_alloc(struct kmem_cache *cache,
/* Save alloc info (if possible) for non-kmalloc() allocations. */
if (kasan_stack_collection_enabled() && !cache->kasan_info.is_kmalloc)
- save_alloc_info(cache, (void *)object, flags);
+ kasan_save_alloc_info(cache, (void *)object, flags);
return tagged_object;
}
@@ -509,7 +500,7 @@ static inline void *____kasan_kmalloc(struct kmem_cache *cache,
* This also rewrites the alloc info when called from kasan_krealloc().
*/
if (kasan_stack_collection_enabled() && cache->kasan_info.is_kmalloc)
- save_alloc_info(cache, (void *)object, flags);
+ kasan_save_alloc_info(cache, (void *)object, flags);
/* Keep the tag that was set by kasan_slab_alloc(). */
return (void *)object;