From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-177.mta0.migadu.com (out-177.mta0.migadu.com [91.218.175.177]) (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 E6C38324B33 for ; Fri, 12 Jun 2026 03:47:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781236058; cv=none; b=QBtmeBMYLoVAps6oCYRqsE35iFUIga6oa7wQ3movyOrm8Tuz6r44HmqxmpNbdNeuXnhD//2wiYkOE8DX56h/fLfHyVrUBsnf8DXYYfR3aWcj4pwfEi3uS/CdPVr1/0hqyvrTqkIaqlgfbM8xLGuztnoU5ONhiGZ56BUOq93QT/g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781236058; c=relaxed/simple; bh=H97jfEEYQhCuSJ4c7swSHPYmSzdA+8b/wp5bds66LCc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=PSyz0GecB3T86or4MG3Iy9ckgsqEGKCBIJYbBN2do4rK/coXFlBOU3EaKC23F53j5e+EQ6yqaUMVxC/gvykVoznZ3yZlZeR2lsrGDhMyw3b7mtuv925n4ts/zj5Ba57vHgdkekZwlfuJiPbFHDFpGJu2n7hSbrLaEnSufbpGWcQ= 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=mYQDZ7X9; arc=none smtp.client-ip=91.218.175.177 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="mYQDZ7X9" Date: Fri, 12 Jun 2026 11:47:10 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1781236045; 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=3vlsXwbdv4YLsjOvBE7ppjfwl98GoswDXJt/chitc04=; b=mYQDZ7X9hjPoIXj3GM2UvtX4VuTFvaVx9H8Va2kBNqeVRS+KhX8YbfQWTKX6CKUSn/JbsR Q/HbJRrr7Bx+6xwbxAWOn7dj5Me/RWlWWZBXtGRUGNchUT/9Ep+78HAik1d+0j+SlaRAX5 zKxzweN8o+wR+3NAcFL5PD8rlrEooYc= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Hao Li To: "Vlastimil Babka (SUSE)" Cc: Harry Yoo , Christoph Lameter , David Rientjes , Roman Gushchin , Suren Baghdasaryan , Alexei Starovoitov , Andrew Morton , Johannes Weiner , Michal Hocko , Shakeel Butt , Alexander Potapenko , Marco Elver , Dmitry Vyukov , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH v2 01/16] mm/slab: do not limit zeroing to orig_size when only red zoning is enabled Message-ID: References: <20260610-slab_alloc_flags-v2-0-7190909db118@kernel.org> <20260610-slab_alloc_flags-v2-1-7190909db118@kernel.org> 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: <20260610-slab_alloc_flags-v2-1-7190909db118@kernel.org> X-Migadu-Flow: FLOW_OUT On Wed, Jun 10, 2026 at 05:40:03PM +0200, Vlastimil Babka (SUSE) wrote: > When init (zeroing) on allocation is requested, for kmalloc() we > generally have to zero the full object size even if a smaller size is > requested, in order to provide krealloc()'s __GFP_ZERO guarantees. > > But if we track the requested size, krealloc() uses that information to > do the right thing. With red zoning also enabled, any unused size > became part of the red zone, so it must not be zeroed. > > However the check is imprecise, and will trigger also when only > SLAB_RED_ZONE is enabled without SLAB_STORE_USER. This means enabling > red zoning alone can compromise krealloc()'s __GFP_ZERO contract. > > Fix this by using slub_debug_orig_size() instead, which is the exact > check for whether the requested size is tracked. We don't need to care > if red zoning is also enabled or not. Also update and expand the > comment accordingly. > > Fixes: 9ce67395f5a0 ("mm/slub: only zero requested size of buffer for kzalloc when debug enabled") > Cc: > Signed-off-by: Vlastimil Babka (SUSE) > --- Reviewed-by: Hao Li -- Thanks, Hao