Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2888098rdb; Mon, 12 Feb 2024 23:22:26 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWr1mrSLK2Io5/6npr9PRANJ0vmrtPlADQ6p1prOn6JBnMGo2g876LgFNapV9eNV8PfFBBeA8Ax0Zxcqors0mMf16tSFf43Lih1kobGsg== X-Google-Smtp-Source: AGHT+IFR0WmDbFe1CEetP7MqGf62si6WuzfottJdelRjEJT6KBcRx8TQwQVCL2yTL2ZFpAFQC92E X-Received: by 2002:a05:6808:3a06:b0:3bf:fdb2:ca5b with SMTP id gr6-20020a0568083a0600b003bffdb2ca5bmr14148544oib.3.1707808945992; Mon, 12 Feb 2024 23:22:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707808945; cv=pass; d=google.com; s=arc-20160816; b=O3QAyF3eEWVYLfGB3QM01RUs9C8WmxSA09GPqUs0sXQUqEIvpkDgmXBfMOJ4eriEv9 8lRvYZ5z/+ymMpkHMEQrzJOLGsF4Y3RKKokcUuQj1+nvX5qmzm5gEhxf8rmKFtmLuAO3 WXm0Si0BFNBgeIkVJj3++5+fQ3mphmXdD5JCnwhaOS8TGbQRnbrhSRqqmuh8CJGF7274 pGk139xp9z3dWWcXHyi8Xd3Vyi4DSGjpJR+AbrbuKu2O/3gawccXYTtqW4E5kEYRf0Fh bYzXiB4c+rk+aCJFfAYSe67oNdfEpBG+JZVStHu0k+SjlnOnKwiJz+g9uCoVTFsrvkIT R4ww== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=AD0DXnUm1FBXgA9YUMc+TzzukaEUgpwUDBCCVIkam5I=; fh=ftFLYAVxnB9mYYOxuf5x/qgbvC+nC1P+XHkKG2QRpaw=; b=uBdIHr6MIX00LP3JYZwFbLIQbrYb2byhRuadDSqwrraZqLp1aoF7T56COjvZvsZMOx NSOjgCyKzzXKUXP155buxYzli5sRv7t96BrcnNCHTVGrnz9ZFp+sCMWPNqAV9jaMU9xH x0S7UJi9r6oU5dk6kUIpiPM4fkecZt3C3aMamP7XhUnXpGu3Q0l327k8XOAny81H92ro 95x52mDT41YG4TcDibvjyjavqqIjNh/2Gh4qTD55Bitfbv83UKEsQWhfgQowGzuotzvF EhwlR/wctzns5gDdNbRr0UZBD2BZkLUchVyja+iwvFd8LJEMKiwkQ7RaYA/84NS78/1M JLsQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=IrQ75Qfu; arc=pass (i=1 spf=pass spfdomain=rasmusvillemoes.dk dkim=pass dkdomain=rasmusvillemoes.dk); spf=pass (google.com: domain of linux-kernel+bounces-63041-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63041-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCVlJgcggllFnLjqYRxpmd6qtRc/aY5S4MvBazqtZy82M0SmuVNc0XGlLJnXVEmuoomPExsJaxSuu8zK0jm+zXWbx56QoL3nOQRFJMxASQ== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id i6-20020a05620a0a0600b0078715367700si2017206qka.64.2024.02.12.23.22.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 23:22:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63041-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=IrQ75Qfu; arc=pass (i=1 spf=pass spfdomain=rasmusvillemoes.dk dkim=pass dkdomain=rasmusvillemoes.dk); spf=pass (google.com: domain of linux-kernel+bounces-63041-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63041-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id B98241C22772 for ; Tue, 13 Feb 2024 07:22:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3CEF81754F; Tue, 13 Feb 2024 07:22:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=rasmusvillemoes.dk header.i=@rasmusvillemoes.dk header.b="IrQ75Qfu" Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) (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 7EF081754E for ; Tue, 13 Feb 2024 07:22:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707808927; cv=none; b=m2WJtziKAp2IEMMQNoJcQc+3DNmIzvRYXMAN/MPAxf16u/FcM7r5Dwb2Tx4ofl7zpxK7MvyBZo03gr13uoUzUhzUgpTdL64e/SqFYCbTYdWM3QvbQkuk2DNitVCcwY5Ob/VFvVGmWVwCs/Z5CT+3luE1LazRwJndOcg/1nDJ0mQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707808927; c=relaxed/simple; bh=DONVtGRnA1valXDHvMXR3w+eZ1ofjI09Edkc2KsjAf8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=KPh0YrTkL3m81zIu1HWqPgKscqJBb3K9dH7JJdkj0A/dnmnIDEalJeEAyuVqY1DVlFaL6yBT8AQdQuBsmysySSzeh2FUbHtT0kuh4QNUjJOa4FXvQj0cv4myZ7Z1ZeG2wdx5X8kCkhf4BNbbIbDy4EUzEb2BSk1KcjQULcIbTEo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rasmusvillemoes.dk; spf=pass smtp.mailfrom=rasmusvillemoes.dk; dkim=pass (1024-bit key) header.d=rasmusvillemoes.dk header.i=@rasmusvillemoes.dk header.b=IrQ75Qfu; arc=none smtp.client-ip=209.85.218.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rasmusvillemoes.dk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rasmusvillemoes.dk Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-a3566c0309fso484034266b.1 for ; Mon, 12 Feb 2024 23:22:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; t=1707808924; x=1708413724; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=AD0DXnUm1FBXgA9YUMc+TzzukaEUgpwUDBCCVIkam5I=; b=IrQ75QfujO74PbxNkhTLvq9ci591E89y0XThGIjyBgV2RjYNUd3kOnhv9jVZVhxU+L 2ScAl9rLithDNCVRY4mhuDm/OEA4nyyyesbNEf8I6iYeSzztcWLjv0Kdm5sJuCBYtIBA yOzOoLabloeTYQtip4yo57hGjI5CKJdHuX8o4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707808924; x=1708413724; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=AD0DXnUm1FBXgA9YUMc+TzzukaEUgpwUDBCCVIkam5I=; b=PGrWkXggxtAJK8h0U6ipcEHFWhiJmTi83o37egFBmB4rR24OJDYcF5C29U0VzHgJs3 ZNz1JQEXuIOjsuDLFAmL5n/Y5BkS0TxJTkhXrg6HzXxKZu8zM5nJRRy0IO6tYsj3Sc3/ F5XCVQXRsmzWl7F1Hi19kPgba4XsX6h0QZYITEETxp6aMnabc+BHqxqZvyVLlZlZaatH iIi94Ih/3mv/s13BFSms1WV3ySjwdszOmP5IENcUefOG38mZdn4cbdBtXI/H1JkmOsB+ hEarGrM0QEgApgYfQwkHmnjBdg+3elJi0cwOMVH/GRlQfs1nmekIQi4pQBK5fSWNZ4wY 0QoQ== X-Forwarded-Encrypted: i=1; AJvYcCWmfdKNlnHZtJab7kqIT07VQOS9E/hjeDOSIi+TnUFycyWrQLgD66Nh31mEFwy2SZjoyI2f8eGCU1lYQEPZyBdn2PvnEL1N81zXloeU X-Gm-Message-State: AOJu0Yw/IDqJaui4A30xp2IVEiSq//WVmK6ZYaQVvGhllMu/Ml8FRcry 7fGZXPKFZWI1z1WpCb0l6Ow+4qcW2QRT1wWBH4Yq+6V8W2a87gDzk+qyM7dymEQ= X-Received: by 2002:a17:906:d118:b0:a3c:98aa:5ad1 with SMTP id b24-20020a170906d11800b00a3c98aa5ad1mr3635223ejz.56.1707808923400; Mon, 12 Feb 2024 23:22:03 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCX4luXF08VL+zicwLTq9Xh9Y8kYxOhF1kPJ8oNRVthKZvF5fDS8k7GzWn/v2C4YriRdYy6OKFge2XgzXaOfqo+Dacyrr/xdAcYXw2QHv16NvAU0+p1OZ9XCkLVY3W1aEH8W+nJM/QmyL30GQDNC3SpubkgIgY3CFZOZn0Gi4uuTL1N818XMcYBXyOo0c0QYkr+l+0ZDKrzrguP82tn8WI9D27oZYKS3/zTRxlAGVZpcoCaUcleacl/jl2c6hmUejIyVz1/lA0opNJ2mMOHutw2MnE2MqvC9Z3bJU3A/m6RgBaD214WXoF2ChIs5Maf1Q7SlrNK0LMWEOJchld8QTcPwUh5SnCV1LM9CFCqVdAs4TA5FhPdvHpT57nHICPmIdyiHOV68CoqABWDw6UZpkHP0jmLx5ATRMRNGZ/Psly4dQdfUd6dHE2MF+SKITHDjqMOWePMRGoWG5L3achTmGQ== Received: from [172.16.11.116] ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id vb1-20020a170907d04100b00a3cfe376116sm379292ejc.57.2024.02.12.23.22.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Feb 2024 23:22:02 -0800 (PST) Message-ID: <8ff2496e-925a-4a86-b402-6229767d218d@rasmusvillemoes.dk> Date: Tue, 13 Feb 2024 08:22:00 +0100 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 1/2] stddef: Allow attributes to be used when creating flex arrays Content-Language: en-US, da To: Kees Cook , Jakub Kicinski Cc: "Gustavo A . R . Silva" , Dan Williams , Keith Packard , Miguel Ojeda , Alexey Dobriyan , Dmitry Antipov , "David S. Miller" , Eric Dumazet , Paolo Abeni , Nathan Chancellor , kernel test robot , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-hardening@vger.kernel.org References: <20240210011452.work.985-kees@kernel.org> <20240210011643.1706285-1-keescook@chromium.org> From: Rasmus Villemoes In-Reply-To: <20240210011643.1706285-1-keescook@chromium.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 10/02/2024 02.16, Kees Cook wrote: > With the coming support for the __counted_by struct member attribute, we > will need a way to add such annotations to the places where > DECLARE_FLEX_ARRAY() is used. Introduce DECLARE_FLEX_ARRAY_ATTR() which > takes a third argument: the attributes to apply to the flexible array. > > - * __DECLARE_FLEX_ARRAY() - Declare a flexible array usable in a union > - * > + * __DECLARE_FLEX_ARRAY_ATTR() - Declare a flexible array usable in a union > * @TYPE: The type of each flexible array element > * @NAME: The name of the flexible array member > + * @ATTRS: The list of member attributes to apply > * > * In order to have a flexible array member in a union or alone in a > * struct, it needs to be wrapped in an anonymous struct with at least 1 > * named member, but that member can be empty. > */ > -#define __DECLARE_FLEX_ARRAY(TYPE, NAME) \ > +#define __DECLARE_FLEX_ARRAY_ATTR(TYPE, NAME, ATTRS) \ > struct { \ > struct { } __empty_ ## NAME; \ > - TYPE NAME[]; \ > + TYPE NAME[] ATTRS; \ > } Is it too ugly to not introduce a separate _ATTR macro but instead just do #define __DECLARE_FLEX_ARRAY(TYPE, NAME, ...) \ ... TYPE NAME[] __VA_ARGS__; ? Rasmus