Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp842375lqj; Mon, 3 Jun 2024 02:28:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX7et/zrBO+w5wgAIP2CB3+DHpvvrl8nFwJ1Ci7EMZvzYLWWoFP0w0gRXGX9/Eu21pVxmS+0UkV5aR3Z5mSofz643ITa6s0/Kj2g64YRA== X-Google-Smtp-Source: AGHT+IFLYyWSHSVZZzDYWdtwclDy8L6hFGiE7Qh8UR+PRugCNl7Yte/ZSqcM42viALCsTomccRJb X-Received: by 2002:a05:6820:1613:b0:5b2:f2e5:a8c8 with SMTP id 006d021491bc7-5ba05e07978mr10087920eaf.8.1717406932614; Mon, 03 Jun 2024 02:28:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717406932; cv=pass; d=google.com; s=arc-20160816; b=pIyHgITEBz8noAeJJPt72/M3lFywhYyU4IEPb5Zd1nmJYVd4wb/ELD03+L1xUXCcJy S90f0SaKug3VhfqF3Tvl7P1ycMzxCpmNUzSE/Gg5pDmQ91az3XlKVChDz+GGNVH/jdS4 Q50RdkZcYzr/My7heJoF+hUMib3io0MVy9ywrqLic6B47T/u39rcThi4LTQKg0buL1sR FJyErWT2TMx01sAv06BfPWP8dofyapuyFVEZ790Pb/BbuB9LiqzSKLzBRiqBCAKmvdV1 ET3ds5rprw2bQZ0otxL3ayl270dVMQwKQM8unnc+1cANQmladziVcnMrKaRUrsIHdXLu G9NA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature:dkim-signature:dkim-signature:dkim-signature; bh=YCVlp6tqy0Lfw4pwRsglQ1xUSbV/yrMGt8kgMUKIWpo=; fh=ka34OsseS3FUR7dFtWsAEC/4UAcTjeXOQD93ddRx7Gc=; b=pqYeODGN0TxEe9Nd7HzcsAL/MYZpiLxqlAlJPVYP/vERB5S9Gpodv3Y/dg9y8WrAM5 z+2ELdwbhcwAVhBRpA9degA8N/i0WH/RKqSk9alJKj89G6HeOO87wxIcCqBfqK8R+/VL uiPbAGbavKEAytoOOGY7froU+vkU0gKiaMTjNb1gl5E0cmPyTikf48CgBC9khgmbJBAd FNtqjbGYhv0OWdwQ3Z8TUApOoGCcwU2AsuNZ1tR988ooB3KWwrjOsA4Z8ZkCkzBOgmNQ 438ZwbGFFzRIhtMzbZccqyB3kra/0NCsLgQ1CwnRV8kQ8nJjWvVOiJAtbHhRbjRppDQn xIUQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=KTQ0Xdje; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=sXpTYDg2; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=Z0tdEgK4; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=OwxJfucO; arc=pass (i=1 spf=pass spfdomain=suse.cz dkim=pass dkdomain=suse.cz dkim=pass dkdomain=suse.cz); spf=pass (google.com: domain of linux-kernel+bounces-198863-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-198863-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6c359e09dc8si6101426a12.292.2024.06.03.02.28.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 02:28:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-198863-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=KTQ0Xdje; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=sXpTYDg2; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=Z0tdEgK4; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=OwxJfucO; arc=pass (i=1 spf=pass spfdomain=suse.cz dkim=pass dkdomain=suse.cz dkim=pass dkdomain=suse.cz); spf=pass (google.com: domain of linux-kernel+bounces-198863-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-198863-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 2736FB2125E for ; Mon, 3 Jun 2024 09:25:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AC1427E77B; Mon, 3 Jun 2024 09:25:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="KTQ0Xdje"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="sXpTYDg2"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="Z0tdEgK4"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="OwxJfucO" Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EF74C5FDA7 for ; Mon, 3 Jun 2024 09:25:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717406749; cv=none; b=q1DFW0+3Z8jViyHCXOLCPo+x5O+zqdvMRU7LIUtS6T/+VeLw/wIgxqzyamEuWTUtzD43B5yHAvSextcPvE9+7jb75ZIauX+yIUmBwJVGL8BqA5BX2ZtkFj+RjdO9U0Fo/mjzehUyZAEjP6NHHqYh3ccUHwfWhoEoug5aY4sxG1I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717406749; c=relaxed/simple; bh=6e7EFjYVIFKKGFSnmJhwLxifmLhnZEVY9OcFSk87wZg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=uIjYLyf/IXUx8mJ+Zo3vvpkXnWzHBGQirpSJsWbatPKFLu/1qFOrGCYjf8boMWeOY0e/WiiDWJ5m0AYDDMUmMAJSjG0+M4JlccjteO+qZTdQa+n3Aywk5s18FSz8hJdK87vYwFuCR49VzTa78L7/bhaStTAhLkk4cFRaZNF1CSE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=KTQ0Xdje; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=sXpTYDg2; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=Z0tdEgK4; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=OwxJfucO; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id DDA5422239; Mon, 3 Jun 2024 09:25:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1717406746; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=YCVlp6tqy0Lfw4pwRsglQ1xUSbV/yrMGt8kgMUKIWpo=; b=KTQ0XdjeFkuuPIxFdUX3/E5sTw4Mp+ELZUtdVuhOxumhQ9d1SyCWDWxWrgUyWvgar93YQe VTCzqf6FaE7bSlrc9nDcUsb5ZcG6b2C9tGqSMMExC03REW3VAOUYKHvoQpt+Oeb13NBGEJ CHxILInrH233d+7QRhzOSlWw6ukWGdM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1717406746; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=YCVlp6tqy0Lfw4pwRsglQ1xUSbV/yrMGt8kgMUKIWpo=; b=sXpTYDg2GUEbDjEtqgvm3LKiOHMj5bR2ObvG2bDGV2+UD3w1FLsmX9Mb3fIZYwb+r8H2hY gMmG6TXGeGJgYpCQ== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1717406745; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=YCVlp6tqy0Lfw4pwRsglQ1xUSbV/yrMGt8kgMUKIWpo=; b=Z0tdEgK4ftWiqI220aQJrowTImlICDL6S2ws7G5UYAvVUM5jMviOt07CXUj6H9B7JdP2eV J/88zVoDkMJ8xjLHNhjyNZvrrRyVGLzNgSbjIPFd6Oxd7YvQwAGZrpvg8uy/PYAkOnqW6W VcdwrdzK4JgSS+jhOmnfyun/cxLS1Ho= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1717406745; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=YCVlp6tqy0Lfw4pwRsglQ1xUSbV/yrMGt8kgMUKIWpo=; b=OwxJfucOPMM7lIuNU5VFpT/vsLjj5ajuyIpGkCIIQWt0aYiZYXie/xixgtyCsc54qOuou+ wQ9GMR9N+zPEuNCw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id C0CB5139CB; Mon, 3 Jun 2024 09:25:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id lmeULhmMXWbkAQAAD6G6ig (envelope-from ); Mon, 03 Jun 2024 09:25:45 +0000 Message-ID: <5a09e348-9eeb-4502-9aa9-ef5da2f94218@suse.cz> Date: Mon, 3 Jun 2024 11:25:45 +0200 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 2/3] slab: don't put freepointer outside of object if only orig_size Content-Language: en-US To: Chengming Zhou , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Feng Tang Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, zhouchengming@bytedance.com References: <20240528-b4-slab-debug-v1-0-8694ef4802df@linux.dev> <20240528-b4-slab-debug-v1-2-8694ef4802df@linux.dev> From: Vlastimil Babka Autocrypt: addr=vbabka@suse.cz; keydata= xsFNBFZdmxYBEADsw/SiUSjB0dM+vSh95UkgcHjzEVBlby/Fg+g42O7LAEkCYXi/vvq31JTB KxRWDHX0R2tgpFDXHnzZcQywawu8eSq0LxzxFNYMvtB7sV1pxYwej2qx9B75qW2plBs+7+YB 87tMFA+u+L4Z5xAzIimfLD5EKC56kJ1CsXlM8S/LHcmdD9Ctkn3trYDNnat0eoAcfPIP2OZ+ 9oe9IF/R28zmh0ifLXyJQQz5ofdj4bPf8ecEW0rhcqHfTD8k4yK0xxt3xW+6Exqp9n9bydiy tcSAw/TahjW6yrA+6JhSBv1v2tIm+itQc073zjSX8OFL51qQVzRFr7H2UQG33lw2QrvHRXqD Ot7ViKam7v0Ho9wEWiQOOZlHItOOXFphWb2yq3nzrKe45oWoSgkxKb97MVsQ+q2SYjJRBBH4 8qKhphADYxkIP6yut/eaj9ImvRUZZRi0DTc8xfnvHGTjKbJzC2xpFcY0DQbZzuwsIZ8OPJCc LM4S7mT25NE5kUTG/TKQCk922vRdGVMoLA7dIQrgXnRXtyT61sg8PG4wcfOnuWf8577aXP1x 6mzw3/jh3F+oSBHb/GcLC7mvWreJifUL2gEdssGfXhGWBo6zLS3qhgtwjay0Jl+kza1lo+Cv BB2T79D4WGdDuVa4eOrQ02TxqGN7G0Biz5ZLRSFzQSQwLn8fbwARAQABzSBWbGFzdGltaWwg QmFia2EgPHZiYWJrYUBzdXNlLmN6PsLBlAQTAQoAPgIbAwULCQgHAwUVCgkICwUWAgMBAAIe AQIXgBYhBKlA1DSZLC6OmRA9UCJPp+fMgqZkBQJkBREIBQkRadznAAoJECJPp+fMgqZkNxIQ ALZRqwdUGzqL2aeSavbum/VF/+td+nZfuH0xeWiO2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CRAiT6fnzIKmZOJGEACOKABgo9wJXsbWhGWYO7mD 8R8mUyJHqbvaz+yTLnvRwfe/VwafFfDMx5GYVYzMY9TWpA8psFTKTUIIQmx2scYsRBUwm5VI EurRWKqENcDRjyo+ol59j0FViYysjQQeobXBDDE31t5SBg++veI6tXfpco/UiKEsDswL1WAr tEAZaruo7254TyH+gydURl2wJuzo/aZ7Y7PpqaODbYv727Dvm5eX64HCyyAH0s6sOCyGF5/p eIhrOn24oBf67KtdAN3H9JoFNUVTYJc1VJU3R1JtVdgwEdr+NEciEfYl0O19VpLE/PZxP4wX PWnhf5WjdoNI1Xec+RcJ5p/pSel0jnvBX8L2cmniYnmI883NhtGZsEWj++wyKiS4NranDFlA HdDM3b4lUth1pTtABKQ1YuTvehj7EfoWD3bv9kuGZGPrAeFNiHPdOT7DaXKeHpW9homgtBxj 8aX/UkSvEGJKUEbFL9cVa5tzyialGkSiZJNkWgeHe+jEcfRT6pJZOJidSCdzvJpbdJmm+eED w9XOLH1IIWh7RURU7G1iOfEfmImFeC3cbbS73LQEFGe1urxvIH5K/7vX+FkNcr9ujwWuPE9b 1C2o4i/yZPLXIVy387EjA6GZMqvQUFuSTs/GeBcv0NjIQi8867H3uLjz+mQy63fAitsDwLmR EP+ylKVEKb0Q2A== In-Reply-To: <20240528-b4-slab-debug-v1-2-8694ef4802df@linux.dev> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Level: X-Spamd-Result: default: False [-2.73 / 50.00]; BAYES_HAM(-2.94)[99.75%]; SUSPICIOUS_RECIPS(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; XM_UA_NO_VERSION(0.01)[]; TAGGED_RCPT(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_TO(0.00)[linux.dev,linux.com,kernel.org,google.com,lge.com,linux-foundation.org,gmail.com,intel.com]; RCPT_COUNT_TWELVE(0.00)[12]; MID_RHS_MATCH_FROM(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; DBL_BLOCKED_OPENRESOLVER(0.00)[linux.dev:email] X-Spam-Score: -2.73 X-Spam-Flag: NO On 5/28/24 9:16 AM, Chengming Zhou wrote: > The commit 946fa0dbf2d8 ("mm/slub: extend redzone check to extra > allocated kmalloc space than requested") will extend right redzone > when allocating for orig_size < object_size. So we can't overlay the > freepointer in the object space in this case. > > But the code looks like it forgot to check SLAB_RED_ZONE, since there > won't be extended right redzone if only orig_size enabled. > > Signed-off-by: Chengming Zhou Seems OK. > --- > mm/slub.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/slub.c b/mm/slub.c > index de57512734ac..b92d9a557852 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -5150,7 +5150,7 @@ static int calculate_sizes(struct kmem_cache *s) > */ > s->inuse = size; > > - if (slub_debug_orig_size(s) || > + if (((flags & SLAB_RED_ZONE) && slub_debug_orig_size(s)) || > (flags & (SLAB_TYPESAFE_BY_RCU | SLAB_POISON)) || > ((flags & SLAB_RED_ZONE) && s->object_size < sizeof(void *)) || Should we consolidate the two cases with flags & SLAB_RED_ZONE? Also below this is a comment that could also mention the slub_debug_orig_size(). > s->ctor) { >