linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Harry Yoo <harry.yoo@oracle.com>
To: Vlastimil Babka <vbabka@suse.cz>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Christoph Lameter <cl@gentwo.org>,
	David Rientjes <rientjes@google.com>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	Alexei Starovoitov <ast@kernel.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	kernel test robot <oliver.sang@intel.com>
Subject: Re: [PATCH] slab: fix clearing freelist in free_deferred_objects()
Date: Tue, 14 Oct 2025 17:46:09 +0900	[thread overview]
Message-ID: <aO4N0Up_g8JvJj9x@hyeyoo> (raw)
In-Reply-To: <1dbe9c35-9ce7-47b5-ae32-f406bdff58fd@suse.cz>

On Tue, Oct 14, 2025 at 10:44:51AM +0200, Vlastimil Babka wrote:
> On 10/14/25 10:40, Vlastimil Babka wrote:
> > defer_free() links pending objects using the slab's freelist offset
> > which is fine as they are not free yet. free_deferred_objects() then
> > clears this pointer to avoid confusing the debugging consistency checks
> > that may be enabled for the cache.
> > 
> > However, with CONFIG_SLAB_FREELIST_HARDENED, even the NULL pointer needs
> > to be encoded appropriately using set_freepointer(), otherwise it's
> > decoded as something else and triggers the consistency checks, as found
> > by the kernel test robot.
> > 
> > Use set_freepointer() to prevent the issue.
> > 
> > Fixes: af92793e52c3 ("slab: Introduce kmalloc_nolock() and kfree_nolock().")
> > Reported-by: kernel test robot <oliver.sang@intel.com>
> > Closes: https://lore.kernel.org/oe-lkp/202510101652.7921fdc6-lkp@intel.com
> > Acked-by: Alexei Starovoitov <ast@kernel.org>
> > Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
> > ---
> > will be added to slab/for-next-fixes and sent later this week
> > ---
> >  mm/slub.c | 7 ++++---
> >  1 file changed, 4 insertions(+), 3 deletions(-)
> > 
> > diff --git a/mm/slub.c b/mm/slub.c
> > index b1f15598fbfd..64c17afc375b 100644
> > --- a/mm/slub.c
> > +++ b/mm/slub.c
> > @@ -6443,15 +6443,16 @@ static void free_deferred_objects(struct irq_work *work)
> >  		slab = virt_to_slab(x);
> >  		s = slab->slab_cache;
> >  
> > +
> 
> extra newline moved...
> 
> > +		/* Point 'x' back to the beginning of allocated object */
> > +		x -= s->offset;
> 
> ... here. noticed and fixed up locally after sending...

LGTM,
Reviewed-by: Harry Yoo <harry.yoo@oracle.com>

Thanks for fixing it!

> >  		/*
> >  		 * We used freepointer in 'x' to link 'x' into df->objects.
> >  		 * Clear it to NULL to avoid false positive detection
> >  		 * of "Freepointer corruption".
> >  		 */
> > -		*(void **)x = NULL;
> > +		set_freepointer(s, x, NULL);
> >  
> > -		/* Point 'x' back to the beginning of allocated object */
> > -		x -= s->offset;
> >  		__slab_free(s, slab, x, x, 1, _THIS_IP_);
> >  	}

-- 
Cheers,
Harry / Hyeonggon


      reply	other threads:[~2025-10-14  8:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-14  8:40 Vlastimil Babka
2025-10-14  8:44 ` Vlastimil Babka
2025-10-14  8:46   ` Harry Yoo [this message]

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=aO4N0Up_g8JvJj9x@hyeyoo \
    --to=harry.yoo@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=ast@kernel.org \
    --cc=cl@gentwo.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=oliver.sang@intel.com \
    --cc=rientjes@google.com \
    --cc=roman.gushchin@linux.dev \
    --cc=vbabka@suse.cz \
    /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