From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-170.mta1.migadu.com (out-170.mta1.migadu.com [95.215.58.170]) (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 64E5423EAB2 for ; Fri, 5 Jun 2026 07:27:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780644469; cv=none; b=pl28dXE0kfFL+glfEQLYA7mBX+o9uSV8CKyCqZwA40BQt3XIumuHLG2mKNy4Ybe624vjKhYlNh62725HCMD0Q4uHTrWePRt7V+Ma0Aw8bIpU5IV5iuz6j3ZgFtnQq051yPuW3V1t06cSVvR5vo+bnxMLe+Jl6R+24k3k1SUnqbQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780644469; c=relaxed/simple; bh=A45JnnWjn0t+oRyujCNhb+sHP34Arjbbv86po7fnwkU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=JnEXyTauPOlxGiWHlphCbX3mBuDg2CHdCTpMyYloT9F7HLgydhbHamzGCi6yhNg0xT8Y7041y7VK313HLkXJEmzlmttpnbepuizlRWXfixdjv/f3fLAb/qbEbbRcwSArdogh53fxY9JDzSD/OewHP/kFL1IGrQzR89aDRzyOiDk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=bvx4SnSE; arc=none smtp.client-ip=95.215.58.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="bvx4SnSE" Date: Fri, 5 Jun 2026 15:27:29 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1780644465; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=pzeMW4oDHPYGz1SVYrNy5ryyyLKS2lEh4AkazzoA850=; b=bvx4SnSEo6uuj1lJ1ykG80vSCM9pjv0e+eonyRfmu35+BN1+XXJ6mu0weBgsmM7Nkp+mpj JhP5+wvfZTxcRyt6pucQyHKfQuggIsUEDostcQqsV8fgSy7NAufu/8aHD5+1hPk3LeFP/V StHu5KhgIkyKAuQaTgEC22foOeuD24M= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Hao Li To: hu.shengming@zte.com.cn Cc: vbabka@kernel.org, harry@kernel.org, akpm@linux-foundation.org, 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 Subject: Re: [PATCH v2] mm/slub: preserve original size in _kmalloc_nolock_noprof retry path Message-ID: References: <202606042027323804pk3MRY42Jy7y42OHAhQZ@zte.com.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202606042027323804pk3MRY42Jy7y42OHAhQZ@zte.com.cn> X-Migadu-Flow: FLOW_OUT On Thu, Jun 04, 2026 at 08:27:32PM +0800, hu.shengming@zte.com.cn wrote: > From: Shengming Hu > > _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. > > 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 the > valid kmalloc range and hiding overflows. > > Keep the caller requested size separately as orig_size and pass it to > the allocation/debug/KASAN paths. Continue using `size` as the retry cache > selector. > > 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 suggested > by Harry and Vlastimil. > - Link to v1: https://lore.kernel.org/all/20260603211011530GqLSXP_rgcuQdR47IGQLL@zte.com.cn/ > LGTM. Reviewed-by: Hao Li -- Thanks, Hao