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+wKp_foQz9vnMbKA5hMqTgMK4Uczy8ZEb33S3j1rHX=Sw@mail.gmail.com>
Date:   Fri, 30 Oct 2020 17:07:14 +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 10/21] kasan: inline random_tag for HW_TAGS

On Fri, Oct 30, 2020 at 4:48 PM Andrey Konovalov <andreyknvl@...gle.com> wrote:
>
> On Wed, Oct 28, 2020 at 12:08 PM Dmitry Vyukov <dvyukov@...gle.com> wrote:
> >
> > On Thu, Oct 22, 2020 at 3:19 PM Andrey Konovalov <andreyknvl@...gle.com> wrote:
> > >
> > > Using random_tag() currently results in a function call. Move its
> > > definition to mm/kasan/kasan.h and turn it into a static inline function
> > > for hardware tag-based mode to avoid uneeded function call.
> > >
> > > Signed-off-by: Andrey Konovalov <andreyknvl@...gle.com>
> > > Link: https://linux-review.googlesource.com/id/Iac5b2faf9a912900e16cca6834d621f5d4abf427
> > > ---
> > >  mm/kasan/hw_tags.c |  5 -----
> > >  mm/kasan/kasan.h   | 37 ++++++++++++++++++++-----------------
> > >  2 files changed, 20 insertions(+), 22 deletions(-)
> > >
> > > diff --git a/mm/kasan/hw_tags.c b/mm/kasan/hw_tags.c
> > > index c3a0e83b5e7a..4c24bfcfeff9 100644
> > > --- a/mm/kasan/hw_tags.c
> > > +++ b/mm/kasan/hw_tags.c
> > > @@ -36,11 +36,6 @@ void kasan_unpoison_memory(const void *address, size_t size)
> > >                           round_up(size, KASAN_GRANULE_SIZE), get_tag(address));
> > >  }
> > >
> > > -u8 random_tag(void)
> > > -{
> > > -       return get_random_tag();
> > > -}
> > > -
> > >  bool check_invalid_free(void *addr)
> > >  {
> > >         u8 ptr_tag = get_tag(addr);
> > > diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h
> > > index 0ccbb3c4c519..94ba15c2f860 100644
> > > --- a/mm/kasan/kasan.h
> > > +++ b/mm/kasan/kasan.h
> > > @@ -188,6 +188,12 @@ static inline bool addr_has_metadata(const void *addr)
> > >
> > >  #endif /* CONFIG_KASAN_GENERIC || CONFIG_KASAN_SW_TAGS */
> > >
> > > +#if defined(CONFIG_KASAN_SW_TAGS) || defined(CONFIG_KASAN_HW_TAGS)
> > > +void print_tags(u8 addr_tag, const void *addr);
> > > +#else
> > > +static inline void print_tags(u8 addr_tag, const void *addr) { }
> > > +#endif
> > > +
> > >  bool check_invalid_free(void *addr);
> > >
> > >  void *find_first_bad_addr(void *addr, size_t size);
> > > @@ -223,23 +229,6 @@ static inline void quarantine_reduce(void) { }
> > >  static inline void quarantine_remove_cache(struct kmem_cache *cache) { }
> > >  #endif
> > >
> > > -#if defined(CONFIG_KASAN_SW_TAGS) || defined(CONFIG_KASAN_HW_TAGS)
> > > -
> > > -void print_tags(u8 addr_tag, const void *addr);
> > > -
> > > -u8 random_tag(void);
> > > -
> > > -#else
> > > -
> > > -static inline void print_tags(u8 addr_tag, const void *addr) { }
> > > -
> > > -static inline u8 random_tag(void)
> > > -{
> > > -       return 0;
> > > -}
> > > -
> > > -#endif
> > > -
> > >  #ifndef arch_kasan_set_tag
> > >  static inline const void *arch_kasan_set_tag(const void *addr, u8 tag)
> > >  {
> > > @@ -273,6 +262,20 @@ static inline const void *arch_kasan_set_tag(const void *addr, u8 tag)
> > >  #define get_mem_tag(addr)                      arch_get_mem_tag(addr)
> > >  #define set_mem_tag_range(addr, size, tag)     arch_set_mem_tag_range((addr), (size), (tag))
> > >
> > > +#ifdef CONFIG_KASAN_SW_TAGS
> > > +u8 random_tag(void);
> > > +#elif defined(CONFIG_KASAN_HW_TAGS)
> > > +static inline u8 random_tag(void)
> > > +{
> > > +       return get_random_tag();
> >
> > What's the difference between random_tag() and get_random_tag()? Do we
> > need both?
>
> Not really. Will simplify this in the next version and give cleaner names.

Actually I think I'll keep both for the next version, but rename
get_random_tag() into hw_get_random_tag() along with other hw-specific
calls. The idea is to have hw_*() calls for things that are
implemented by the hardware for HW_TAGS, and then define random_tag()
based on that for HW_TAGS and based on a software implementation for
SW_TAGS.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ