From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (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 6B9B3379999 for ; Tue, 24 Feb 2026 11:11:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771931516; cv=none; b=dc/keiOBFEe4sHyuelD8SWj9lPoItZh3piCBAmnIIXaQG0YpH1vZwSzigw50sU7TsXDzMppCcxzcL5dmw7NtrFuvomiuUs+PSfNpiQU3ClUvxw/7b9tqcle5YRoEGAQrZcB0C7Kp22Nt/oN9CgWRZ3O+ALJQ4MxSINl22cOPCWE= 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.41 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-f41.google.com with SMTP id ffacd0b85a97d-4362507f0feso3352639f8f.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=iwszi9gkQyvgCipTTYIgaurGQ30LfC7JgilRQb65SebTJNXds7TVuEFPqMFZ5tClO3 LM0jCPAeTw+1Y4QXKJLgs17TkGP3ASGU/UKtaKiUhJIaBuTgg602u5n2YfZ0ny2nt6xT t6FZU4GpgaOTH+bm+zq6kNbvLE3baZ7BB8Zcl9JSGiMQr5pyzsoM0mPvySMN7TVyTkHt 1OxTi4BaltFHikBwvB+UYEjkD/kwsD53spm0O6GBwtfQCU5zw0Gfss+S79KL2WieFbUD LR6SLOs0UcyFFpt0DD3ZNOsdHH4iBK2WTXCm9qc2EmjPO0PAirzeiaXqrB/I9qbtQ1Ff vteg== X-Forwarded-Encrypted: i=1; AJvYcCVxyvFXQEw0xXypBsKWhsHPdxf5EfiRzjcYiDFkVPxVzo9d0O5Ut75TlDorngCgxfMzypm5AbvMDz8=@vger.kernel.org X-Gm-Message-State: AOJu0YzCowejLxzZkW34G8JiIy8QxMVV8btCFEbuDwgZEyQ8QyFljTSW RMBuB2o7PV2Jc5BYMkGtowysS24f6C5FAV8UfFek6MnlR5B6IoMTtjTv X-Gm-Gg: AZuq6aJhNR9NMW+gp0XLZ73Z0iOtzDSdfECPvIbQw6VthXmpTf+0MijIlXguz743k2I lsrOc+wuKeNVYxO/AQYTa/1w+0hpMWlUJqsFEbIYNyKhV0TCp5qPG73gZglZHl9aTb5N/3i8+G0 tPOorjpgqUFaw+yLeuz/JQxasbvmdcDEqgBkKRE1OQLIsz2k8Vw8CumEYP+s+sgt4+pdKM5/yZk vSv0eME50qHPzdjjLZPG3lZCnYtHSeFMUDKwzHHRmV9e6Ih6DU40hGFzNqRlT6UAKxFl/m4STsc mhaQlKlQzVW5INu2NZs0LkugVoSvbbdL3gpKPretDC/Vrc4366UOL0z9m4lsuAhO7jm5odUhGal +kjs79+JNZtVNH+dBwBUMeQ3tTr3RsxObhde9dkfGt9PTiW0Q5HDasjoXJKWsHdhoF/Z8zpZrfb VJm47SGPdJseZ3D+QKbamrDLyIexUtwMxfqzH9g8DzysIPWONnR73AWOkbcHgmDFvi 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-doc@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