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: <CAAeHK+xN4x4ggcBxTZj53OWCzKMe5LVLK1JMhKd3u87=E_Aw1A@mail.gmail.com>
Date:   Fri, 30 Oct 2020 17:19:20 +0100
From:   Andrey Konovalov <andreyknvl@...gle.com>
To:     Dmitry Vyukov <dvyukov@...gle.com>
Cc:     Catalin Marinas <catalin.marinas@....com>,
        Will Deacon <will.deacon@....com>,
        Vincenzo Frascino <vincenzo.frascino@....com>,
        Alexander Potapenko <glider@...gle.com>,
        Marco Elver <elver@...gle.com>,
        Evgenii Stepanov <eugenis@...gle.com>,
        Kostya Serebryany <kcc@...gle.com>,
        Peter Collingbourne <pcc@...gle.com>,
        Serban Constantinescu <serbanc@...gle.com>,
        Andrey Ryabinin <aryabinin@...tuozzo.com>,
        Elena Petrova <lenaptr@...gle.com>,
        Branislav Rankov <Branislav.Rankov@....com>,
        Kevin Brodsky <kevin.brodsky@....com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        kasan-dev <kasan-dev@...glegroups.com>,
        Linux ARM <linux-arm-kernel@...ts.infradead.org>,
        Linux-MM <linux-mm@...ck.org>,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH RFC v2 09/21] kasan: inline kasan_reset_tag for tag-based modes

On Wed, Oct 28, 2020 at 12:05 PM Dmitry Vyukov <dvyukov@...gle.com> wrote:
>
> On Thu, Oct 22, 2020 at 3:19 PM Andrey Konovalov <andreyknvl@...gle.com> wrote:
> >
> > Using kasan_reset_tag() currently results in a function call. As it's
> > called quite often from the allocator code this leads to a noticeable
> > slowdown. Move it to include/linux/kasan.h and turn it into a static
> > inline function.
> >
> > Signed-off-by: Andrey Konovalov <andreyknvl@...gle.com>
> > Link: https://linux-review.googlesource.com/id/I4d2061acfe91d480a75df00b07c22d8494ef14b5
> > ---
> >  include/linux/kasan.h | 5 ++++-
> >  mm/kasan/hw_tags.c    | 5 -----
> >  mm/kasan/kasan.h      | 6 ++----
> >  mm/kasan/sw_tags.c    | 5 -----
> >  4 files changed, 6 insertions(+), 15 deletions(-)
> >
> > diff --git a/include/linux/kasan.h b/include/linux/kasan.h
> > index 93d9834b7122..6377d7d3a951 100644
> > --- a/include/linux/kasan.h
> > +++ b/include/linux/kasan.h
> > @@ -187,7 +187,10 @@ static inline void kasan_record_aux_stack(void *ptr) {}
> >
> >  void __init kasan_init_tags(void);
> >
> > -void *kasan_reset_tag(const void *addr);
> > +static inline void *kasan_reset_tag(const void *addr)
> > +{
> > +       return (void *)arch_kasan_reset_tag(addr);
>
> It seems that all implementations already return (void *), so the cast
> is not needed.

arch_kasan_reset_tag() (->__tag_reset() -> __untagged_addr())
preserves the type of the argument, so the cast is needed.

>
> > +}
> >
> >  bool kasan_report(unsigned long addr, size_t size,
> >                 bool is_write, unsigned long ip);
> > diff --git a/mm/kasan/hw_tags.c b/mm/kasan/hw_tags.c
> > index b372421258c8..c3a0e83b5e7a 100644
> > --- a/mm/kasan/hw_tags.c
> > +++ b/mm/kasan/hw_tags.c
> > @@ -24,11 +24,6 @@ void __init kasan_init_tags(void)
> >         pr_info("KernelAddressSanitizer initialized\n");
> >  }
> >
> > -void *kasan_reset_tag(const void *addr)
> > -{
> > -       return reset_tag(addr);
> > -}
> > -
> >  void kasan_poison_memory(const void *address, size_t size, u8 value)
> >  {
> >         set_mem_tag_range(reset_tag(address),
> > diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h
> > index 456b264e5124..0ccbb3c4c519 100644
> > --- a/mm/kasan/kasan.h
> > +++ b/mm/kasan/kasan.h
> > @@ -246,15 +246,13 @@ static inline const void *arch_kasan_set_tag(const void *addr, u8 tag)
> >         return addr;
> >  }
> >  #endif
> > -#ifndef arch_kasan_reset_tag
> > -#define arch_kasan_reset_tag(addr)     ((void *)(addr))
> > -#endif
> >  #ifndef arch_kasan_get_tag
> >  #define arch_kasan_get_tag(addr)       0
> >  #endif
> >
> > +/* kasan_reset_tag() defined in include/linux/kasan.h. */
> > +#define reset_tag(addr)                ((void *)kasan_reset_tag(addr))
>
> The cast is not needed.
>
> I would also now remove reset_tag entirely by replacing it with
> kasan_reset_tag. Having 2 names for the same thing does not add
> clarity.

Will remove it.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ