[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANpmjNOJoR2ReowDbw5DG3i95392uiukXmVmkSKL3ORLeW_6Zg@mail.gmail.com>
Date: Mon, 20 Jun 2022 15:39:34 +0200
From: Marco Elver <elver@...gle.com>
To: andrey.konovalov@...ux.dev
Cc: Alexander Potapenko <glider@...gle.com>,
Andrey Konovalov <andreyknvl@...il.com>,
Dmitry Vyukov <dvyukov@...gle.com>,
Andrey Ryabinin <ryabinin.a.a@...il.com>,
kasan-dev@...glegroups.com, Peter Collingbourne <pcc@...gle.com>,
Evgenii Stepanov <eugenis@...gle.com>,
Florian Mayer <fmayer@...gle.com>,
Andrew Morton <akpm@...ux-foundation.org>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org,
Andrey Konovalov <andreyknvl@...gle.com>
Subject: Re: [PATCH 03/32] kasan: move is_kmalloc check out of save_alloc_info
On Mon, 13 Jun 2022 at 22:15, <andrey.konovalov@...ux.dev> wrote:
>
> From: Andrey Konovalov <andreyknvl@...gle.com>
>
> Move kasan_info.is_kmalloc check out of save_alloc_info().
>
> This is a preparatory change that simplifies the following patches
> in this series.
>
> Signed-off-by: Andrey Konovalov <andreyknvl@...gle.com>
Reviewed-by: Marco Elver <elver@...gle.com>
> ---
> mm/kasan/common.c | 15 +++++----------
> 1 file changed, 5 insertions(+), 10 deletions(-)
>
> diff --git a/mm/kasan/common.c b/mm/kasan/common.c
> index 753775b894b6..a6107e8375e0 100644
> --- a/mm/kasan/common.c
> +++ b/mm/kasan/common.c
> @@ -423,15 +423,10 @@ void __kasan_slab_free_mempool(void *ptr, unsigned long ip)
> }
> }
>
> -static void save_alloc_info(struct kmem_cache *cache, void *object,
> - gfp_t flags, bool is_kmalloc)
> +static void save_alloc_info(struct kmem_cache *cache, void *object, gfp_t flags)
> {
> struct kasan_alloc_meta *alloc_meta;
>
> - /* Don't save alloc info for kmalloc caches in kasan_slab_alloc(). */
> - if (cache->kasan_info.is_kmalloc && !is_kmalloc)
> - return;
> -
> alloc_meta = kasan_get_alloc_meta(cache, object);
> if (alloc_meta)
> kasan_set_track(&alloc_meta->alloc_track, flags);
> @@ -466,8 +461,8 @@ void * __must_check __kasan_slab_alloc(struct kmem_cache *cache,
> kasan_unpoison(tagged_object, cache->object_size, init);
>
> /* Save alloc info (if possible) for non-kmalloc() allocations. */
> - if (kasan_stack_collection_enabled())
> - save_alloc_info(cache, (void *)object, flags, false);
> + if (kasan_stack_collection_enabled() && !cache->kasan_info.is_kmalloc)
> + save_alloc_info(cache, (void *)object, flags);
>
> return tagged_object;
> }
> @@ -512,8 +507,8 @@ static inline void *____kasan_kmalloc(struct kmem_cache *cache,
> * Save alloc info (if possible) for kmalloc() allocations.
> * This also rewrites the alloc info when called from kasan_krealloc().
> */
> - if (kasan_stack_collection_enabled())
> - save_alloc_info(cache, (void *)object, flags, true);
> + if (kasan_stack_collection_enabled() && cache->kasan_info.is_kmalloc)
> + save_alloc_info(cache, (void *)object, flags);
>
> /* Keep the tag that was set by kasan_slab_alloc(). */
> return (void *)object;
> --
> 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@...glegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/kasan-dev/ad7b6cfa3fbe10d2d9c4d15a9d30c2db9a41362c.1655150842.git.andreyknvl%40google.com.
Powered by blists - more mailing lists