From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 633903F6C48 for ; Fri, 5 Jun 2026 05:59:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780639175; cv=none; b=e4e4n0t0bHJ4Qt7YtJqbL5YqgsBJBNzbIRl+DtC7rqkZ/F/8NMKc1SoJo4f60ma9ZmMPkMailn7tArlno6uATv31iOIPgl2iyH0ME1UT6fctJELPUlXoSXRALLnszFEeuCzKRCws71L5HbWFKMtFb9pxvYE81lEKlDbdP2nTsjg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780639175; c=relaxed/simple; bh=YZRZA4KM0SzMFR9V10TrDjVlo+fJ3JDCnJSQBhVjit0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=jqqEYGxU1FxFy/HrME2zaEMVlyTjDZ/L22k+MVV3E2EzWALhdzOx0wBgRoHQZ6opVZ+3/iEYIr0Wdq7XPQKREI/v4aW1P7yuCvzuSeEXRKDEKW4U8v9o4ncfmcioCeaWDXHDsv0zZwRq4nTHBRSeuRis9pon+7eEIRcVW3swXDw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=afXQTfY7; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="afXQTfY7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B42AE1F00893; Fri, 5 Jun 2026 05:59:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780639174; bh=VZG9no7GTW408RV/60BpZX7jKUvr/kEIeLtGBvYuZZ0=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=afXQTfY7mlWhg66Vp8DQgnBNBuw1R80YdSq++am4RaFjH5i2h1K/w9tWb1CCQMA9n B2+xwhktTQ3oczmJe/BO3NKZ9nOROjxpaaGuvQCMt2EUiUrYilQNF0N9GsBtIZYEFM 0NhWFxTTiNAc1f/z2ck6N1neKifOxCk39hprXyWSTrcUJA/iZjlraVBanBY2DjRT8O AyxeP+SnxAHgkRjI9YLUDopGnScNZiTxVg5ZjYHAyBFcXPDd7MfvbSYcDJphLcpDUs e935zO9VR4bVKaRzo+zWWHwk+RcvqJD9+pARw3BIcYc1l/Cuu39wEsD0ufUS9k48Yu keK25jwAMDxPQ== Message-ID: Date: Fri, 5 Jun 2026 14:59:22 +0900 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] mm/slub: preserve original size in _kmalloc_nolock_noprof retry path To: hu.shengming@zte.com.cn, vbabka@kernel.org, akpm@linux-foundation.org Cc: hao.li@linux.dev, cl@gentwo.org, rientjes@google.com, roman.gushchin@linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, zhang.run@zte.com.cn, cai.qu@zte.com.cn References: <202606042027323804pk3MRY42Jy7y42OHAhQZ@zte.com.cn> Content-Language: en-US From: Harry Yoo In-Reply-To: <202606042027323804pk3MRY42Jy7y42OHAhQZ@zte.com.cn> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------mvMhvM0STHKjAKiB8hmyrDMn" This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --------------mvMhvM0STHKjAKiB8hmyrDMn Content-Type: multipart/mixed; boundary="------------UaqwdqBkjfBUljnSAbpOsztD"; protected-headers="v1" From: Harry Yoo To: hu.shengming@zte.com.cn, vbabka@kernel.org, akpm@linux-foundation.org Cc: hao.li@linux.dev, cl@gentwo.org, rientjes@google.com, roman.gushchin@linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, zhang.run@zte.com.cn, cai.qu@zte.com.cn Message-ID: Subject: Re: [PATCH v2] mm/slub: preserve original size in _kmalloc_nolock_noprof retry path References: <202606042027323804pk3MRY42Jy7y42OHAhQZ@zte.com.cn> In-Reply-To: <202606042027323804pk3MRY42Jy7y42OHAhQZ@zte.com.cn> --------------UaqwdqBkjfBUljnSAbpOsztD Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 6/4/26 9:27 PM, hu.shengming@zte.com.cn wrote: > From: Shengming Hu >=20 > _kmalloc_nolock_noprof() retries from the next kmalloc bucket when the > initial allocation fails. The retry currently reuses `size` as the > bucket selector and overwrites it with s->object_size + 1. >=20 > That value is later passed as the original allocation size to > __slab_alloc_node(), slab_post_alloc_hook() and kasan_kmalloc(). On a > successful retry this makes KASAN/slub-debug observe the retry bucket > selector rather than the caller requested size, potentially widening th= e > valid kmalloc range and hiding overflows. >=20 > Keep the caller requested size separately as orig_size and pass it to > the allocation/debug/KASAN paths. Continue using `size` as the retry ca= che > selector. >=20 > Fixes: af92793e52c3 ("slab: Introduce kmalloc_nolock() and kfree_nolock= ()") > Signed-off-by: Shengming Hu > --- > Changes in v2: > - Use an explicit orig_size variable instead of bucket_size, as suggest= ed > by Harry and Vlastimil. > - Link to v1: https://lore.kernel.org/all/20260603211011530GqLSXP_rgcuQ= dR47IGQLL@zte.com.cn/ >=20 > --- Reviewed-by: Harry Yoo (Oracle) --=20 Cheers, Harry / Hyeonggon --------------UaqwdqBkjfBUljnSAbpOsztD-- --------------mvMhvM0STHKjAKiB8hmyrDMn Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature.asc" -----BEGIN PGP SIGNATURE----- iHUEARYKAB0WIQQQ1ub6gR5ogjaKRmOGXBN6rc5S1gUCaiJluwAKCRCGXBN6rc5S 1mDiAQDMsuhI+fb3bj0yV2uXPZmU7SL6rZGXaVTpa+0qqfyOXAEA4c7/8ULItr0w L8g4FZ2T8JQFVYrjv1BlKTwU2h5EdAY= =ADM0 -----END PGP SIGNATURE----- --------------mvMhvM0STHKjAKiB8hmyrDMn--