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: <CAMn1gO4sdaqZDoa0CErkTOaP=z2Y_ZitPck9opdXNbexdLaVOg@mail.gmail.com>
Date:   Thu, 28 Apr 2022 14:55:51 -0700
From:   Peter Collingbourne <pcc@...gle.com>
To:     Andrew Morton <akpm@...ux-foundation.org>
Cc:     Andrey Konovalov <andreyknvl@...il.com>,
        Hyeonggon Yoo <42.hyeyoo@...il.com>,
        Catalin Marinas <catalin.marinas@....com>,
        Linux ARM <linux-arm-kernel@...ts.infradead.org>,
        Linux Memory Management List <linux-mm@...ck.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Vlastimil Babka <vbabka@...e.cz>,
        Pekka Enberg <penberg@...nel.org>, roman.gushchin@...ux.dev,
        Joonsoo Kim <iamjoonsoo.kim@....com>,
        David Rientjes <rientjes@...gle.com>,
        Herbert Xu <herbert@...dor.apana.org.au>,
        Andrey Ryabinin <ryabinin.a.a@...il.com>,
        Alexander Potapenko <glider@...gle.com>,
        Dmitry Vyukov <dvyukov@...gle.com>,
        kasan-dev <kasan-dev@...glegroups.com>,
        Eric Biederman <ebiederm@...ssion.com>,
        Kees Cook <keescook@...omium.org>
Subject: Re: [PATCH v5 2/2] mm: make minimum slab alignment a runtime property

On Wed, Apr 27, 2022 at 1:27 PM Andrew Morton <akpm@...ux-foundation.org> wrote:
>
> On Wed, 27 Apr 2022 12:58:20 -0700 Peter Collingbourne <pcc@...gle.com> wrote:
>
> > When CONFIG_KASAN_HW_TAGS is enabled we currently increase the minimum
> > slab alignment to 16. This happens even if MTE is not supported in
> > hardware or disabled via kasan=off, which creates an unnecessary
> > memory overhead in those cases. Eliminate this overhead by making
> > the minimum slab alignment a runtime property and only aligning to
> > 16 if KASAN is enabled at runtime.
> >
> > On a DragonBoard 845c (non-MTE hardware) with a kernel built with
> > CONFIG_KASAN_HW_TAGS, waiting for quiescence after a full Android
> > boot I see the following Slab measurements in /proc/meminfo (median
> > of 3 reboots):
> >
> > ...
> >
> > --- a/mm/slab.c
> > +++ b/mm/slab.c
> > @@ -3009,10 +3009,9 @@ static void *cache_alloc_debugcheck_after(struct kmem_cache *cachep,
> >       objp += obj_offset(cachep);
> >       if (cachep->ctor && cachep->flags & SLAB_POISON)
> >               cachep->ctor(objp);
> > -     if (ARCH_SLAB_MINALIGN &&
> > -         ((unsigned long)objp & (ARCH_SLAB_MINALIGN-1))) {
> > -             pr_err("0x%px: not aligned to ARCH_SLAB_MINALIGN=%d\n",
> > -                    objp, (int)ARCH_SLAB_MINALIGN);
> > +     if ((unsigned long)objp & (arch_slab_minalign() - 1)) {
> > +             pr_err("0x%px: not aligned to arch_slab_minalign()=%d\n", objp,
> > +                    (int)arch_slab_minalign());
>
> printf/printk know about size_t.  Use %zu, no cast needed.  But...
>
> >       }
> >       return objp;
> >  }
> > diff --git a/mm/slab_common.c b/mm/slab_common.c
> > index 2b3206a2c3b5..33cc49810a54 100644
> > --- a/mm/slab_common.c
> > +++ b/mm/slab_common.c
> > @@ -154,8 +154,7 @@ static unsigned int calculate_alignment(slab_flags_t flags,
> >               align = max(align, ralign);
> >       }
> >
> > -     if (align < ARCH_SLAB_MINALIGN)
> > -             align = ARCH_SLAB_MINALIGN;
> > +     align = max_t(size_t, align, arch_slab_minalign());
>
> max_t/min_t are nature's way of telling us "you screwed up the types".
>
> So what type _is_ slab alignment?  size_t seems sensible, but the code
> prefers unsigned int.  So how about we stick with that?
>
>
> This compiles.  Still some max_t's in slob.c because I was too lazy to
> go fix the type of ARCH_KMALLOC_MINALIGN.
>
> Shrug, I don't know if we can be bothered.   You decide :)

Hi Andrew,

No strong opinions here. I'm happy with the fixup that you added to
your tree on top of my patch.

Peter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ