From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-188.mta0.migadu.com (out-188.mta0.migadu.com [91.218.175.188]) (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 2761D2E2DF2 for ; Fri, 12 Jun 2026 03:47:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781236048; cv=none; b=Evsbh9UykF1KAX6ifyoGW9yL+1/Ii+X8m6fd+I/jGwkRobwY1hTN9kPYBxtOn7wvSOcQR1KcCx9SjKdzcTFWcQkUGkb2YnBbN4tDM4fAObAY/+i13IcMK99KlYueBuwuuUwo1E0ABTe2657fzF8HhtheSzuiaNds7+U434A9N8k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781236048; 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=FmjNzSM7hda0X3COU3w0ZGn55CQK9YXRwhgMQiBFrqXeFjqmcHE1sfZ96WC5G0MlkHjh8PGx2YK9+07IsnZgK30MB9NQtz/Pu6cMOX097fr0sb8oZf7J/GdCvLSJVB9yKsAXS/5kvWS3Rhpgv7pKvZdKTg9MBxX6GwGSxCQX3UA= 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.188 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: cgroups@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