From: Harry Yoo <harry@kernel.org>
To: "Vlastimil Babka (SUSE)" <vbabka@kernel.org>
Cc: Hao Li <hao.li@linux.dev>, Christoph Lameter <cl@gentwo.org>,
David Rientjes <rientjes@google.com>,
Roman Gushchin <roman.gushchin@linux.dev>,
"David Hildenbrand (Arm)" <david@kernel.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Chris Mason <mason@kernel.org>,
stable@vger.kernel.org
Subject: Re: [PATCH 4/4] mm/slab: clear stale layout values in calculate_sizes()
Date: Mon, 30 Nov 2026 15:26:00 +0000 [thread overview]
Message-ID: <aw2UiK1TKQ4YTP4g@thinkstation> (raw)
In-Reply-To: <20261127-slab-ai-fixes-v1-4-cf13b6be6692@kernel.org>
On Fri, Nov 27, 2026 at 09:12:33PM +0100, Vlastimil Babka (SUSE) wrote:
> From: Chris Mason <mason@kernel.org>
>
> With O in slab_debug, SLUB can place the slabobj_ext of an object out
> of bounds: in another object, or past the end of the slab.
>
> If debug metadata raises the minimum order of a cache,
> do_kmem_cache_create() drops the metadata flags and runs
> calculate_sizes() again, which has to recompute the whole layout. But
> calculate_sizes() only ever sets SLAB_OBJ_EXT_IN_OBJ and s->red_left_pad
> when they apply and never resets, so the values of the first run stay,
> and alloc_slab_obj_exts_early() uses both. For kmalloc-cg-4k with
> slab_debug=FZPUO, 4K pages and no KASAN:
>
> first run second run
> ========= ==========
> s->size 12288 4096
> alignment padding yes none
> SLAB_OBJ_EXT_IN_OBJ set still set
> s->red_left_pad 4096 still 4096
>
> slabobj_ext of object i
> = slab + s->red_left_pad + s->inuse + i * s->size
> = object i + 2
>
> The fix used here is to reset both values before the second run. The
> s->offset is already reset that way.
>
> [vbabka: consolidate the resets in the caller]
>
> Fixes: a77d6d338685 ("mm/slab: place slabobj_ext metadata in unused space within s->size")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Chris Mason <mason@kernel.org>
> Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
> Co-developed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
> Signed-off-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
> ---
Looks good to me,
Reviewed-by: Harry Yoo (Meta) <harry@kernel.org>
--
Cheers,
Harry / Hyeonggon
prev parent reply other threads:[~2026-11-30 15:26 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 20:12 [PATCH 0/4] slab AI fixes Vlastimil Babka (SUSE)
2026-11-27 20:12 ` [PATCH 1/4] mm/slab: drop __GFP_NOFAIL when refilling sheaves Vlastimil Babka (SUSE)
2026-11-30 14:10 ` Harry Yoo
2026-11-27 20:12 ` [PATCH 2/4] mm/slab: handle __GFP_NOFAIL better with prefilled sheaves Vlastimil Babka (SUSE)
2026-11-27 21:15 ` sashiko-bot
2026-11-30 14:58 ` Harry Yoo
2026-11-27 20:12 ` [PATCH 3/4] mm/slab: keep caches that drop debug flags unmergeable Vlastimil Babka (SUSE)
2026-11-27 21:15 ` sashiko-bot
2026-11-30 15:14 ` Harry Yoo
2026-11-27 20:12 ` [PATCH 4/4] mm/slab: clear stale layout values in calculate_sizes() Vlastimil Babka (SUSE)
2026-11-27 21:16 ` sashiko-bot
2026-11-30 15:31 ` Harry Yoo
2026-11-30 15:26 ` 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=aw2UiK1TKQ4YTP4g@thinkstation \
--to=harry@kernel.org \
--cc=cl@gentwo.org \
--cc=david@kernel.org \
--cc=hao.li@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mason@kernel.org \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=stable@vger.kernel.org \
--cc=vbabka@kernel.org \
/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