linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: Waiman Long <longman@redhat.com>,
	Christoph Lameter <cl@linux.com>,
	Pekka Enberg <penberg@kernel.org>,
	David Rientjes <rientjes@google.com>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Kees Cook <keescook@chromium.org>,
	Changbin Du <changbin.du@gmail.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] mm/slub: Fix incorrect interpretation of s->offset
Date: Wed, 29 Apr 2020 11:25:08 -0700	[thread overview]
Message-ID: <20200429182508.GU29705@bombadil.infradead.org> (raw)
In-Reply-To: <af19e771-062f-6ed7-0b9a-e8cd8d0fdb6a@web.de>

On Wed, Apr 29, 2020 at 06:42:55PM +0200, Markus Elfring wrote:
> > In a couple of places in the slub memory allocator, the code uses
> > "s->offset" as a check to see if the free pointer is put right after the
> > object. That check is no longer true with commit 3202fa62fb43 ("slub:
> > relocate freelist pointer to middle of object").
> 
> Will any further collateral evolution become interesting?

What do you mean by this question?

> > +static inline unsigned int get_info_end(struct kmem_cache *s)
> > +{
> > +	if (freeptr_outside_object(s))
> > +		return s->inuse + sizeof(void *);
> > +	else
> > +		return s->inuse;
> > +}
> 
> How do you think about the following source code variants?
> 
> +	return freeptr_outside_object(s)
> +	       ? s->inuse + sizeof(void *)
> +	       : s->inuse;

That is less clear than the version Wayman posted.

> >  static struct track *get_track(struct kmem_cache *s, void *object,
> >  	enum track_item alloc)
> >  {
> >  	struct track *p;
> >
> > -	if (s->offset)
> > -		p = object + s->offset + sizeof(void *);
> > -	else
> > -		p = object + s->inuse;
> > +	p = object + get_info_end(s);
> >
> >  	return p + alloc;
> >  }
> 
> +	struct track *p = object + get_info_end(s);
> 
>  	return p + alloc;

Yes, I think that's an improvement.


  reply	other threads:[~2020-04-29 18:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-29 13:53 Waiman Long
2020-04-29 13:55 ` Waiman Long
2020-04-29 15:54 ` Matthew Wilcox
2020-04-29 16:42 ` Markus Elfring
2020-04-29 18:25   ` Matthew Wilcox [this message]
2020-05-01 21:29 ` Rafael Aquini
2020-05-01 22:01 ` Kees Cook

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200429182508.GU29705@bombadil.infradead.org \
    --to=willy@infradead.org \
    --cc=Markus.Elfring@web.de \
    --cc=akpm@linux-foundation.org \
    --cc=changbin.du@gmail.com \
    --cc=cl@linux.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=longman@redhat.com \
    --cc=penberg@kernel.org \
    --cc=rientjes@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox