[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAG_fn=WuEL0ZGdmy3fhY9gW-nBw_qG9_yb3Ut1+17By3h=d0Jg@mail.gmail.com>
Date: Tue, 25 Jun 2019 18:16:43 +0200
From: Alexander Potapenko <glider@...gle.com>
To: Qian Cai <cai@....pw>
Cc: Kees Cook <keescook@...omium.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Christoph Lameter <cl@...ux.com>,
Pekka Enberg <penberg@...nel.org>,
David Rientjes <rientjes@...gle.com>,
Linux Memory Management List <linux-mm@...ck.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH -next] slub: play init_on_free=1 well with SLAB_RED_ZONE
On Fri, Jun 21, 2019 at 2:55 PM Qian Cai <cai@....pw> wrote:
>
> On Thu, 2019-06-20 at 18:19 -0700, Kees Cook wrote:
> > On Thu, Jun 20, 2019 at 06:14:33PM -0700, Kees Cook wrote:
> > > On Thu, Jun 20, 2019 at 03:28:01PM -0400, Qian Cai wrote:
> > > > diff --git a/mm/slub.c b/mm/slub.c
> > > > index a384228ff6d3..787971d4fa36 100644
> > > > --- a/mm/slub.c
> > > > +++ b/mm/slub.c
> > > > @@ -1437,7 +1437,7 @@ static inline bool slab_free_freelist_hook(struct
> > > > kmem_cache *s,
> > > > do {
> > > > object = next;
> > > > next = get_freepointer(s, object);
> > > > - memset(object, 0, s->size);
> > > > + memset(object, 0, s->object_size);
> > >
> > > I think this should be more dynamic -- we _do_ want to wipe all
> > > of object_size in the case where it's just alignment and padding
> > > adjustments. If redzones are enabled, let's remove that portion only.
> >
> > (Sorry, I meant: all of object's "size", not object_size.)
> >
>
> I suppose Alexander is going to revise the series anyway, so he can probably
> take care of the issue here in the new version as well. Something like this,
>
> memset(object, 0, s->object_size);
> memset(object, 0, s->size - s->inuse);
Looks like we also need to account for the redzone size. I'm testing
the fix right now.
--
Alexander Potapenko
Software Engineer
Google Germany GmbH
Erika-Mann-Straße, 33
80636 München
Geschäftsführer: Paul Manicle, Halimah DeLaine Prado
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Powered by blists - more mailing lists