From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (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 65E80156F45 for ; Tue, 24 Feb 2026 11:11:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771931516; cv=none; b=XX6sDBsYA7zD4aBfGj/hfC16znPYqfMRPDDheT+ZpVU7d+XL4sCoE8J/a95jQI6Q6HY2n3G8zgzzDfnn/UF502DDKGkRxnqEXHvMrPpJ7GKO+HuunEHE6sxFV4ywUTgs+1trivASr+LhF4TTRgrCa+2a2NnIsV64xJivdi8kphA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771931516; c=relaxed/simple; bh=wTNPYvldKqT8E/99ZE7dTEJbH62XG1KG1J6bDFSPh+U=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uOFMv4bS1qpkrMk1hg1lhGXnU9nsIpnNoapSEwfHavcWI6ugkSlChacS5YqAs6LEE7HmtiXJrJCIGcZD5QOwmPBXOmqnCbTSu73kEd+Ogmz/eCyaIDGhJcba09as0NP02BTC/yroWB0NxuQHP5WMsTUL8fvEPsqY3iwm7yGqDOc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dvwmLUcw; arc=none smtp.client-ip=209.85.221.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dvwmLUcw" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-4362507f0feso3352638f8f.0 for ; Tue, 24 Feb 2026 03:11:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771931514; x=1772536314; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=UwqR4mogOeV02cqzMt1+tF/fnlUYylAA5gPYZ8oxqZQ=; b=dvwmLUcw2j8Ap3HLEe1aMS+zujYEbqVjuxoeX0lpOxOTrFieSdM6q2WvR+AqFF85JK 83E6jsHSgvul535Ipajrgn4CeMEorEHOtqBq/VXjoQRnlbSTuE12zr0spMK3VxvhA3tB BPBqxH87/omtYoO8/4lR23Tt+TWJp6MwfvlD535ni0HBmYgy32+wV+Mp81lPVWrOQnKM iSFbCl3zDwj8a9YxP1H0GyACAe8yc3+yZ7X53BFhWHMxh6EZt3YdL0lPkupKLnXUZmLj 0XtKl/lQKd8YPv4xQlibcRlh83mJhFlho97Dfg65kZnQfMAeXPgPzTsTI+PA79TLG6o5 ohvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771931514; x=1772536314; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=UwqR4mogOeV02cqzMt1+tF/fnlUYylAA5gPYZ8oxqZQ=; b=PZYUHIQwLZkm982vodvrZuKTeB8za4Y4WHlqrjJs/UKVOSHRW88jwl2C+He+t7ML3I oXG7UclCo41MW67HG0E3x3Po/xGp9f3/DLk+iq0kbzGlqxmcWDR2/DtUUod9//HJMWOI 7BegxY4m+/glvZqAOyUOCJ2h0Gc3p6Nq3mspkTksDCsmwGhNTihv1yyS53qTiAF+d9jM ulSCmyg1yuZ1NzLuL1lu1d6yrol0XFD9gD+/fB8HiEMPrv3SZWD3L8ib3cvT/ooI1aqs boG3zxew4WWEFmagwxLy0jF8tXqr+pyu+eN6gPQUvcZsW71bZWK7On7M4NmPpVBsp4h4 NnPQ== X-Forwarded-Encrypted: i=1; AJvYcCW/p133CvuIwSFdOYVosrkp8J/af/BW7QZjhBCicJaGRHOMttRBwO7Lf/5sbhL6Hp+AjGTTO6bbWaIZT8Y=@vger.kernel.org X-Gm-Message-State: AOJu0Yx9M8f/2r/EWGvaxC+pg3yM09u1gojjxgkrxxvsB5909ziVvDcv wudRwtytchHLV+RTISi8JTttXoWF2o8DUmieTq7YB3xesZDXn+/hf1eL X-Gm-Gg: AZuq6aLNTDf5wmwVSbToPyLA7c9bLDQOBsA+OCvlLDDThqeJbGHCSzy/fYTRr1/BPU4 ajaqaE+uwMcGDI6qGg1djAXyoVJECyC6vtCk9HG+P+mOOX3oCr9e9ZywCt16zaZJnkWhb9cOmlv 44NsiQj/Hub6wY5lwGXA243+ejJiXHXIMTVxDGfXZzrK+YISNqdKhXHpSQSU09tzpOjN1CbLykV VCLH0h/zugDUjsQFKUjvjxkPyKn1MCjMmcJTQ1xSzcRjox6/h7Ynu57dWIsyjN4tv1P2GRpoBD0 UB65HoXXd8+/RpIA8zDgg5YstJ8kk2JC5xcyX2zkjzQh6uvem4q75Ddb4H1BytC8e3DL/7K+hMF +LdTLcMsrQOWpeRg8kubJoN/Kou6dtVrcRK9WMrlFODOSut2+M/lBZktFd8j8NSMIWxyRvipYmJ JfXsNSrxRftdbi37UE90KFtyu+VQGs75VEcDvwx2a+5opA+uqOZCRxY+mKdOx6Lqoh X-Received: by 2002:a05:600c:8b16:b0:480:68ed:1e70 with SMTP id 5b1f17b1804b1-483a963de73mr263902315e9.35.1771931513686; Tue, 24 Feb 2026 03:11:53 -0800 (PST) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9caadedsm216756765e9.10.2026.02.24.03.11.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Feb 2026 03:11:53 -0800 (PST) Date: Tue, 24 Feb 2026 11:11:51 +0000 From: David Laight To: Lorenzo Stoakes Cc: Kees Cook , Vlastimil Babka , Jonathan Corbet , Andrew Morton , Christoph Lameter , David Rientjes , Roman Gushchin , Harry Yoo , "Gustavo A. R. Silva" , workflows@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-hardening@vger.kernel.org, Linus Torvalds , Randy Dunlap , Miguel Ojeda , Przemek Kitszel , Matthew Wilcox , John Hubbard , Joe Perches , Christoph Lameter , Marco Elver , Vegard Nossum , Pekka Enberg , Joonsoo Kim , Bill Wendling , Justin Stitt , Jann Horn , Greg Kroah-Hartman , Sasha Levin , Nathan Chancellor , Peter Zijlstra , Nick Desaulniers , Jakub Kicinski , Yafang Shao , Tony Ambardar , Alexander Lobakin , Jan Hendrik Farr , Alexander Potapenko , linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: Re: [PATCH v6 4/5] slab: Introduce kmalloc_flex() and family Message-ID: <20260224111151.6154ce59@pumpkin> In-Reply-To: <675ec547-dac8-465f-b3c9-a0f97c5bdef7@lucifer.local> References: <20251203233029.it.641-kees@kernel.org> <20251203233036.3212363-4-kees@kernel.org> <675ec547-dac8-465f-b3c9-a0f97c5bdef7@lucifer.local> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) 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-Transfer-Encoding: 7bit On Tue, 24 Feb 2026 10:26:36 +0000 Lorenzo Stoakes wrote: > On Wed, Dec 03, 2025 at 03:30:34PM -0800, Kees Cook wrote: ... > > +/** > > + * __alloc_flex - Allocate an object that has a trailing flexible array > > + * @KMALLOC: kmalloc wrapper function to use for allocation. > > + * @GFP: GFP flags for the allocation. > > + * @TYPE: type of structure to allocate space for. > > + * @FAM: The name of the flexible array member of @TYPE structure. > > + * @COUNT: how many @FAM elements to allocate space for. > > + * > > + * Returns: Newly allocated pointer to @TYPE with @COUNT-many trailing > > + * @FAM elements, or NULL on failure or if @COUNT cannot be represented > > + * by the member of @TYPE that counts the @FAM elements (annotated via > > + * __counted_by()). > > + */ > > +#define __alloc_flex(KMALLOC, GFP, TYPE, FAM, COUNT) \ > > +({ \ > > + const size_t __count = (COUNT); \ > > + const size_t __obj_size = struct_size_t(TYPE, FAM, __count); \ > > + TYPE *__obj_ptr; \ > > + if (WARN_ON_ONCE(overflows_flex_counter_type(TYPE, FAM, __count))) \ > > + __obj_ptr = NULL; \ ... > Annnd now I typed that I realise that Linus fixed this up in mainline and I was > working with a stale version of this file :)) I think someone else mentioned it, but having a WARN_ON_ONCE() is there is really a bad idea. The code bloat must be stunning. I won't ask why the #define parameters are all UPPER CASE. David