From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (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 720CE37AA81 for ; Tue, 24 Feb 2026 11:11:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771931516; cv=none; b=ju0HA2LjQhgCmADbRqa5saGzLf+ySjqXnPH3zS1B/aaSpn5RD2BhCEvxGIf+uX153L2fW8AXkI4xIbcdBDN9g5cW4dQAiECJF7WZuSm64JsGLvG+SJwABDJzU2JbsMaJ71j7tcvv6ykcveW03/9K2wUZ0dIY38iqaDOezQZu4Xs= 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.128.50 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-wm1-f50.google.com with SMTP id 5b1f17b1804b1-4837f27cf2dso45944185e9.2 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=JiJGcrjCtA0roxdaAhx1cPdp6Ka3qrw64SXh4ZW5EG9F9NI9UZ/HefxD/IZH3IMUgp XW4cNRgeEANIoyUVbK6Q3PCkT9RxMSfoj0MzVgIbIWcanUIGj/aap7q4axApprnhKABd oHKIM57MY+wjA9GU/UoWsIaSAQ84/eoO9pDs/pI4x0oE2KlvgQwfCBCBS+RXk7nlUG2R Zy1KkXS8G5XwbcJ249a0QGEoX3n8Pd3uCnC/5HJlY8JXzB9U8d2mouU02vLFfwLE0wpd Iekh73DFXyf7EU6VltdhmICwR/dJTGUe7pDuYo3IjG3y9wAVDkqevxn4o/e69bwKLx1/ thVg== X-Forwarded-Encrypted: i=1; AJvYcCXzCMpT0zmlMjJTyqF3s590moLcwDljrLnNOIeSFnrJ3sBZWmJoWTSdE6VksB+zsoN7a+hva50uwgw=@vger.kernel.org X-Gm-Message-State: AOJu0YxryqsadRSFZ6y5kxX3iji7BvHgeVDdjVyrLxfIvxychfqLYC82 VQ/ojDjSBweOvfwoZ5WwJ+aeybCz0YCqRf/ElP0Zx19NcPBl/lUiWpsZ X-Gm-Gg: AZuq6aJXxEuQ8TEHR2o6Ypn3DPChrsag9F5Y3YvSrnao++yt0RynfDWlvkiRzn0cQBn QfkoQLrv181hi43x26hwNcSqUELdgV+uf9vu2boCEmgiVLZF1H3MWAiaSdeE3en8e/tb8nfDiuJ gzwLAtdEaC/9Fw6lewgD9HOvgP0dC/UhnKWXF991F5qgt5v5egjg1cQNVQMMGWHL81R5ts1IA1z BM+N0PWKxdIO/An4TTpO17tcAxjHrINQpGrN1FX698LpKrUet0HUInvIy6EvKaq1X7pk2L3RpYU Kum/zIwLbg9uJAePm+gKFMJ42DyrD5qyZVxd70aTW+1YgWPrC02KDi0da44eE+IQH/CFBHyno8w sZ0YzFQl3L9JtpqQ/rtyMzHoCLNDQt+e69RrzhFhQu+tlwXNqLhwxaJgGPGBomWApfuePExjm8C K5cCFYzOWk38qjZv45tdS2yOUf9lQpFrTEWOEQd0ON+wHOx+mkC7k+XhzKW8tcVNbf 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: workflows@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