lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+fCnZe0av3Ko8iRGAFjF1jpG77cE3mtQVK-HqZE9sP=eGwGtQ@mail.gmail.com>
Date:   Tue, 22 Nov 2022 10:57:56 +0100
From:   Andrey Konovalov <andreyknvl@...il.com>
To:     Feng Tang <feng.tang@...el.com>
Cc:     Andrew Morton <akpm@...ux-foundation.org>,
        Vlastimil Babka <vbabka@...e.cz>,
        Christoph Lameter <cl@...ux.com>,
        Pekka Enberg <penberg@...nel.org>,
        David Rientjes <rientjes@...gle.com>,
        Joonsoo Kim <iamjoonsoo.kim@....com>,
        Roman Gushchin <roman.gushchin@...ux.dev>,
        Hyeonggon Yoo <42.hyeyoo@...il.com>,
        Dmitry Vyukov <dvyukov@...gle.com>,
        Andrey Ryabinin <ryabinin.a.a@...il.com>,
        Alexander Potapenko <glider@...gle.com>,
        Vincenzo Frascino <vincenzo.frascino@....com>,
        linux-mm@...ck.org, kasan-dev@...glegroups.com,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH -next 2/2] mm/kasan: simplify is_kmalloc check

On Tue, Nov 22, 2022 at 7:56 AM Feng Tang <feng.tang@...el.com> wrote:
>
> On Mon, Nov 21, 2022 at 04:15:32PM +0100, Andrey Konovalov wrote:
> > On Mon, Nov 21, 2022 at 2:53 PM Feng Tang <feng.tang@...el.com> wrote:
> > >
> > > Use new is_kmalloc_cache() to simplify the code of checking whether
> > > a kmem_cache is a kmalloc cache.
> > >
> > > Signed-off-by: Feng Tang <feng.tang@...el.com>
> >
> > Hi Feng,
> >
> > Nice simplification!
> >
> > > ---
> > >  include/linux/kasan.h | 9 ---------
> > >  mm/kasan/common.c     | 9 ++-------
> > >  mm/slab_common.c      | 1 -
> > >  3 files changed, 2 insertions(+), 17 deletions(-)
> > >
> > > diff --git a/include/linux/kasan.h b/include/linux/kasan.h
> > > index dff604912687..fc46f5d6f404 100644
> > > --- a/include/linux/kasan.h
> > > +++ b/include/linux/kasan.h
> > > @@ -102,7 +102,6 @@ struct kasan_cache {
> > >         int alloc_meta_offset;
> > >         int free_meta_offset;
> > >  #endif
> > > -       bool is_kmalloc;
> > >  };
> >
> > We can go even further here, and only define the kasan_cache struct
> > and add the kasan_info field to kmem_cache when CONFIG_KASAN_GENERIC
> > is enabled.
>
> Good idea. thanks!
>
> I mainly checked the kasan_cache related code, and make an add-on
> patch below, please let me know if my understanding is wrong or I
> missed anything.
>
> Thanks,
> Feng
>
> ---
> diff --git a/include/linux/kasan.h b/include/linux/kasan.h
> index 0ac6505367ee..f2e41290094e 100644
> --- a/include/linux/kasan.h
> +++ b/include/linux/kasan.h
> @@ -96,14 +96,6 @@ static inline bool kasan_has_integrated_init(void)
>  }
>
>  #ifdef CONFIG_KASAN
> -
> -struct kasan_cache {
> -#ifdef CONFIG_KASAN_GENERIC
> -       int alloc_meta_offset;
> -       int free_meta_offset;
> -#endif
> -};
> -
>  void __kasan_unpoison_range(const void *addr, size_t size);
>  static __always_inline void kasan_unpoison_range(const void *addr, size_t size)
>  {
> @@ -293,6 +285,11 @@ static inline void kasan_unpoison_task_stack(struct task_struct *task) {}
>
>  #ifdef CONFIG_KASAN_GENERIC
>
> +struct kasan_cache {
> +       int alloc_meta_offset;
> +       int free_meta_offset;
> +};
> +
>  size_t kasan_metadata_size(struct kmem_cache *cache, bool in_object);
>  slab_flags_t kasan_never_merge(void);
>  void kasan_cache_create(struct kmem_cache *cache, unsigned int *size,
> diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
> index f0ffad6a3365..39f7f1f95de2 100644
> --- a/include/linux/slab_def.h
> +++ b/include/linux/slab_def.h
> @@ -72,7 +72,7 @@ struct kmem_cache {
>         int obj_offset;
>  #endif /* CONFIG_DEBUG_SLAB */
>
> -#ifdef CONFIG_KASAN
> +#ifdef CONFIG_KASAN_GENERIC
>         struct kasan_cache kasan_info;
>  #endif
>
> diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
> index f9c68a9dac04..4e7cdada4bbb 100644
> --- a/include/linux/slub_def.h
> +++ b/include/linux/slub_def.h
> @@ -132,7 +132,7 @@ struct kmem_cache {
>         unsigned int *random_seq;
>  #endif
>
> -#ifdef CONFIG_KASAN
> +#ifdef CONFIG_KASAN_GENERIC
>         struct kasan_cache kasan_info;
>  #endif

Yes, this looks good.

Please resend as a v2 and I'll give a Reviewed-by.

Thanks!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ