From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796052362; b=E9ac96Fu7PRjgy2qIx/7r3IOoeDD7r50QXxMEcVtG9P0Y16VlC6A6q6zNjy3sdAlaDJH xom37wy0XagNhUIxlf6DlWIgUW+CSwNps4KjO3HtGi0XJIXjL5mjPW2DS7uB7A/aMSefW 3AXQKtYoF/iIBA2LHnyS1U2MnRI/PfA97kL0AlzfRMIApqvHosSoeWuFENBLzsgh/I4mC o3IqkcqEMIQVIHJDlqS/pTj9q/9X+kJF7Q/ZP0YbdJPjglU6zin5MDb0ULjzn1Ldg9M4y UM41iKMdFAgvwQOYBLw5WrnAThDR6bofJoTjPb8Gt8l0WgBDOvMLNISxydk3VmHOErA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796052362; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=rVF7PiKZ2j7PLuzbaxKez9WM5PqqgHnz2m76FNd1p5I=; b=IjZiUpCAnd8tr9gbirkTHCm4NZuq9UAKMexjS78quD+j6u+v+R4PnUVpgYO6hIJJ98VQ l/eRc01tcdzX3x6Z0FlQ+Aqjz8UxV4OBrFOq4g+4OVlZNqNSZMl4Q/Ba1sM3XG8HKpFfp XWJVc/lZ4UhfczNWIMAVob3vpncFp1DqlgRiWRRt96DtVAeEJDL7bKRkEhpNWqqR4uddJ /Uik3/6puSAQu2c5kfXrCzfKX3B6/T/a5BghddLmsGVtTzxn1c/mVd3yjhJfkZpP/YkQv CTB90L6mgqhi3O8aSuzIqcG//dl3VmQNWm+B9Jh7IZTwE9HSQMY0hbG/U2YG1Z+E7eA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mFiz8Efy; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD371606A31C; Mon, 30 Nov 2026 15:26:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mFiz8Efy Received: by smtp.kernel.org (Postfix) with ESMTPSA id D97461F00A22; Mon, 30 Nov 2026 15:26:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796052362; bh=rVF7PiKZ2j7PLuzbaxKez9WM5PqqgHnz2m76FNd1p5I=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=mFiz8EfyGbp0uIPpYHf5yR9rQJPSqlW3HD06cM6aHQe7v59BPlHQWoM6fzU/Xq8w3 k92306rum2UDNKkTjtqA3hrYBPsWJU+QFRqvvUvSjT87/mMMg1u0/zKssE0wKtAwd2 6IDmUfU+EFKbPR+qoE/iSqEqyeLjw5b0zt9pA7HPERfGEi2KNsSGEQmrenk9ryjPFg xiRAr66z1yY1G1h80QJfn0PpIoHn37zmct62IPbhMEf6alBeJ/ZTpo+kF82B9+a1AX sqHmEemKIe/+fWpibUxgvnhsOUb1J5d7kW+xloMgtcQjrsz00IiOXXaBpUDplMeH1b d0tiwGYQTwRHQ== Date: Mon, 30 Nov 2026 15:26:00 +0000 From: Harry Yoo To: "Vlastimil Babka (SUSE)" Cc: Hao Li , Christoph Lameter , David Rientjes , Roman Gushchin , "David Hildenbrand (Arm)" , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Chris Mason , stable@vger.kernel.org Subject: Re: [PATCH 4/4] mm/slab: clear stale layout values in calculate_sizes() Message-ID: References: <20261127-slab-ai-fixes-v1-0-cf13b6be6692@kernel.org> <20261127-slab-ai-fixes-v1-4-cf13b6be6692@kernel.org> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 > > 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: > Signed-off-by: Chris Mason > Signed-off-by: David Hildenbrand (Arm) > Co-developed-by: Vlastimil Babka (SUSE) > Signed-off-by: Vlastimil Babka (SUSE) > --- Looks good to me, Reviewed-by: Harry Yoo (Meta) -- Cheers, Harry / Hyeonggon