linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Vyukov <dvyukov@google.com>
To: Andrey Konovalov <andreyknvl@google.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will.deacon@arm.com>,
	 Vincenzo Frascino <vincenzo.frascino@arm.com>,
	Alexander Potapenko <glider@google.com>,
	 Marco Elver <elver@google.com>,
	Evgenii Stepanov <eugenis@google.com>,
	 Kostya Serebryany <kcc@google.com>,
	Peter Collingbourne <pcc@google.com>,
	 Serban Constantinescu <serbanc@google.com>,
	Andrey Ryabinin <aryabinin@virtuozzo.com>,
	 Elena Petrova <lenaptr@google.com>,
	Branislav Rankov <Branislav.Rankov@arm.com>,
	 Kevin Brodsky <kevin.brodsky@arm.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	 kasan-dev <kasan-dev@googlegroups.com>,
	 Linux ARM <linux-arm-kernel@lists.infradead.org>,
	Linux-MM <linux-mm@kvack.org>,
	 LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH RFC v2 18/21] kasan: rename kasan_poison_kfree
Date: Wed, 28 Oct 2020 17:58:03 +0100	[thread overview]
Message-ID: <CACT4Y+Z88xqdz4vbPeLzPwxX77FJUxbz+bqiSs1aMDVSGxcpUg@mail.gmail.com> (raw)
In-Reply-To: <5a6f32308101c49da5eef652437bd3da9234c0da.1603372719.git.andreyknvl@google.com>

On Thu, Oct 22, 2020 at 3:20 PM Andrey Konovalov <andreyknvl@google.com> wrote:
>
> Rename kasan_poison_kfree() into kasan_slab_free_mempool() as it better
> reflects what this annotation does.
>
> No functional changes.
>
> Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
> Link: https://linux-review.googlesource.com/id/I5026f87364e556b506ef1baee725144bb04b8810

Reviewed-by: Dmitry Vyukov <dvyukov@google.com>

> ---
>  include/linux/kasan.h | 16 ++++++++--------
>  mm/kasan/common.c     | 16 ++++++++--------
>  mm/mempool.c          |  2 +-
>  3 files changed, 17 insertions(+), 17 deletions(-)
>
> diff --git a/include/linux/kasan.h b/include/linux/kasan.h
> index 8654275aa62e..2ae92f295f76 100644
> --- a/include/linux/kasan.h
> +++ b/include/linux/kasan.h
> @@ -162,6 +162,13 @@ static inline bool kasan_slab_free(struct kmem_cache *s, void *object, unsigned
>         return false;
>  }
>
> +void __kasan_slab_free_mempool(void *ptr, unsigned long ip);
> +static inline void kasan_slab_free_mempool(void *ptr, unsigned long ip)
> +{
> +       if (static_branch_likely(&kasan_enabled))
> +               __kasan_slab_free_mempool(ptr, ip);
> +}
> +
>  void * __must_check __kasan_slab_alloc(struct kmem_cache *s,
>                                        void *object, gfp_t flags);
>  static inline void * __must_check kasan_slab_alloc(struct kmem_cache *s,
> @@ -202,13 +209,6 @@ static inline void * __must_check kasan_krealloc(const void *object,
>         return (void *)object;
>  }
>
> -void __kasan_poison_kfree(void *ptr, unsigned long ip);
> -static inline void kasan_poison_kfree(void *ptr, unsigned long ip)
> -{
> -       if (static_branch_likely(&kasan_enabled))
> -               __kasan_poison_kfree(ptr, ip);
> -}
> -
>  void __kasan_kfree_large(void *ptr, unsigned long ip);
>  static inline void kasan_kfree_large(void *ptr, unsigned long ip)
>  {
> @@ -244,6 +244,7 @@ static inline bool kasan_slab_free(struct kmem_cache *s, void *object,
>  {
>         return false;
>  }
> +static inline void kasan_slab_free_mempool(void *ptr, unsigned long ip) {}
>  static inline void *kasan_slab_alloc(struct kmem_cache *s, void *object,
>                                    gfp_t flags)
>  {
> @@ -264,7 +265,6 @@ static inline void *kasan_krealloc(const void *object, size_t new_size,
>  {
>         return (void *)object;
>  }
> -static inline void kasan_poison_kfree(void *ptr, unsigned long ip) {}
>  static inline void kasan_kfree_large(void *ptr, unsigned long ip) {}
>
>  #endif /* CONFIG_KASAN */
> diff --git a/mm/kasan/common.c b/mm/kasan/common.c
> index b82dbae0c5d6..5622b0ec0907 100644
> --- a/mm/kasan/common.c
> +++ b/mm/kasan/common.c
> @@ -334,6 +334,14 @@ bool __kasan_slab_free(struct kmem_cache *cache, void *object, unsigned long ip)
>         return ____kasan_slab_free(cache, object, ip, true);
>  }
>
> +void __kasan_slab_free_mempool(void *ptr, unsigned long ip)
> +{
> +       struct page *page;
> +
> +       page = virt_to_head_page(ptr);
> +       ____kasan_slab_free(page->slab_cache, ptr, ip, false);
> +}
> +
>  static void set_alloc_info(struct kmem_cache *cache, void *object, gfp_t flags)
>  {
>         kasan_set_track(&kasan_get_alloc_meta(cache, object)->alloc_track, flags);
> @@ -436,14 +444,6 @@ void * __must_check __kasan_krealloc(const void *object, size_t size, gfp_t flag
>                                                 flags, true);
>  }
>
> -void __kasan_poison_kfree(void *ptr, unsigned long ip)
> -{
> -       struct page *page;
> -
> -       page = virt_to_head_page(ptr);
> -       ____kasan_slab_free(page->slab_cache, ptr, ip, false);
> -}
> -
>  void __kasan_kfree_large(void *ptr, unsigned long ip)
>  {
>         if (ptr != page_address(virt_to_head_page(ptr)))
> diff --git a/mm/mempool.c b/mm/mempool.c
> index 79bff63ecf27..0e8d877fbbc6 100644
> --- a/mm/mempool.c
> +++ b/mm/mempool.c
> @@ -106,7 +106,7 @@ static inline void poison_element(mempool_t *pool, void *element)
>  static __always_inline void kasan_poison_element(mempool_t *pool, void *element)
>  {
>         if (pool->alloc == mempool_alloc_slab || pool->alloc == mempool_kmalloc)
> -               kasan_poison_kfree(element, _RET_IP_);
> +               kasan_slab_free_mempool(element, _RET_IP_);
>         if (pool->alloc == mempool_alloc_pages)
>                 kasan_free_pages(element, (unsigned long)pool->pool_data);
>  }
> --
> 2.29.0.rc1.297.gfa9743e501-goog
>


  reply	other threads:[~2020-10-28 16:58 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-22 13:18 [PATCH RFC v2 00/21] kasan: hardware tag-based mode for production use on arm64 Andrey Konovalov
2020-10-22 13:18 ` [PATCH RFC v2 01/21] kasan: simplify quarantine_put call site Andrey Konovalov
2020-10-27 12:40   ` Dmitry Vyukov
2020-10-22 13:18 ` [PATCH RFC v2 02/21] kasan: rename get_alloc/free_info Andrey Konovalov
2020-10-27 12:40   ` Dmitry Vyukov
2020-10-22 13:18 ` [PATCH RFC v2 03/21] kasan: introduce set_alloc_info Andrey Konovalov
2020-10-27 12:41   ` Dmitry Vyukov
2020-10-22 13:18 ` [PATCH RFC v2 04/21] kasan: unpoison stack only with CONFIG_KASAN_STACK Andrey Konovalov
2020-10-27 12:44   ` Dmitry Vyukov
2020-10-27 12:45     ` Dmitry Vyukov
2020-10-29 19:57     ` Andrey Konovalov
2020-11-16 10:59       ` Dmitry Vyukov
2020-11-16 11:50         ` Marco Elver
2020-11-16 12:16           ` Catalin Marinas
2020-11-16 12:19             ` Dmitry Vyukov
2020-11-16 12:45               ` Vincenzo Frascino
2020-11-16 13:50                 ` Andrey Konovalov
2020-11-16 14:50                   ` Vincenzo Frascino
2020-10-22 13:18 ` [PATCH RFC v2 05/21] kasan: allow VMAP_STACK for HW_TAGS mode Andrey Konovalov
2020-10-27 12:49   ` Dmitry Vyukov
2020-10-29 20:00     ` Andrey Konovalov
2020-10-22 13:18 ` [PATCH RFC v2 06/21] kasan: mark kasan_init_tags as __init Andrey Konovalov
2020-10-28 10:08   ` Dmitry Vyukov
2020-10-29 20:08     ` Andrey Konovalov
2020-10-22 13:18 ` [PATCH RFC v2 07/21] kasan, arm64: move initialization message Andrey Konovalov
2020-10-28 10:55   ` Dmitry Vyukov
2020-10-29 20:14     ` Andrey Konovalov
2020-11-03 15:33       ` Andrey Konovalov
2020-10-22 13:19 ` [PATCH RFC v2 08/21] kasan: remove __kasan_unpoison_stack Andrey Konovalov
2020-10-28 10:57   ` Dmitry Vyukov
2020-10-22 13:19 ` [PATCH RFC v2 09/21] kasan: inline kasan_reset_tag for tag-based modes Andrey Konovalov
2020-10-28 11:05   ` Dmitry Vyukov
2020-10-30 16:19     ` Andrey Konovalov
2020-10-22 13:19 ` [PATCH RFC v2 10/21] kasan: inline random_tag for HW_TAGS Andrey Konovalov
2020-10-28 11:08   ` Dmitry Vyukov
2020-10-30 15:48     ` Andrey Konovalov
2020-10-30 16:07       ` Andrey Konovalov
2020-10-22 13:19 ` [PATCH RFC v2 11/21] kasan: inline kasan_poison_memory and check_invalid_free Andrey Konovalov
2020-10-28 11:29   ` Dmitry Vyukov
2020-10-22 13:19 ` [PATCH RFC v2 12/21] kasan: inline and rename kasan_unpoison_memory Andrey Konovalov
2020-10-28 11:36   ` Dmitry Vyukov
2020-10-30 16:34     ` Andrey Konovalov
2020-10-30 17:46       ` Dmitry Vyukov
2020-10-22 13:19 ` [PATCH RFC v2 13/21] arm64: kasan: Add cpu_supports_tags helper Andrey Konovalov
2020-10-28 11:38   ` Dmitry Vyukov
2020-10-22 13:19 ` [PATCH RFC v2 14/21] kasan: add and integrate kasan boot parameters Andrey Konovalov
2020-10-22 18:50   ` Marco Elver
2020-10-22 20:28     ` Andrey Konovalov
2020-10-28 12:27   ` Dmitry Vyukov
2020-10-30 19:30     ` Andrey Konovalov
2020-10-30 14:45   ` Marco Elver
2020-10-30 19:30     ` Andrey Konovalov
2020-10-22 13:19 ` [PATCH RFC v2 15/21] kasan: check kasan_enabled in annotations Andrey Konovalov
2020-10-28 16:47   ` Dmitry Vyukov
2020-10-30 19:47     ` Andrey Konovalov
2020-10-22 13:19 ` [PATCH RFC v2 16/21] kasan: optimize poisoning in kmalloc and krealloc Andrey Konovalov
2020-10-28 16:55   ` Dmitry Vyukov
2020-11-02 15:17     ` Andrey Konovalov
2020-10-22 13:19 ` [PATCH RFC v2 17/21] kasan: simplify kasan_poison_kfree Andrey Konovalov
2020-10-28 16:57   ` Dmitry Vyukov
2020-10-22 13:19 ` [PATCH RFC v2 18/21] kasan: rename kasan_poison_kfree Andrey Konovalov
2020-10-28 16:58   ` Dmitry Vyukov [this message]
2020-10-22 13:19 ` [PATCH RFC v2 19/21] kasan: don't round_up too much Andrey Konovalov
2020-10-28 17:01   ` Dmitry Vyukov
2020-10-22 13:19 ` [PATCH RFC v2 20/21] kasan: simplify assign_tag and set_tag calls Andrey Konovalov
2020-10-28 17:03   ` Dmitry Vyukov
2020-10-22 13:19 ` [PATCH RFC v2 21/21] kasan: clarify comment in __kasan_kfree_large Andrey Konovalov
2020-10-28 17:04   ` Dmitry Vyukov
2020-10-22 15:15 ` [PATCH RFC v2 00/21] kasan: hardware tag-based mode for production use on arm64 Dmitry Vyukov
2020-10-22 17:00   ` Andrey Konovalov
2020-10-22 18:29     ` Kostya Serebryany

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CACT4Y+Z88xqdz4vbPeLzPwxX77FJUxbz+bqiSs1aMDVSGxcpUg@mail.gmail.com \
    --to=dvyukov@google.com \
    --cc=Branislav.Rankov@arm.com \
    --cc=akpm@linux-foundation.org \
    --cc=andreyknvl@google.com \
    --cc=aryabinin@virtuozzo.com \
    --cc=catalin.marinas@arm.com \
    --cc=elver@google.com \
    --cc=eugenis@google.com \
    --cc=glider@google.com \
    --cc=kasan-dev@googlegroups.com \
    --cc=kcc@google.com \
    --cc=kevin.brodsky@arm.com \
    --cc=lenaptr@google.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=pcc@google.com \
    --cc=serbanc@google.com \
    --cc=vincenzo.frascino@arm.com \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).