Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp827339lqs; Tue, 5 Mar 2024 19:26:16 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXg/HTtfmHHW0oONrLcbnM5mhRqNSk1t8PNc/Sv/DpAZebWujHjOlrRHtupJp373fD48DkQNBZ3M33s52aOdYAK08IaTF3zsukl3nYTiA== X-Google-Smtp-Source: AGHT+IEkGowLJhvuij4lGejH938hKoraA7X9SE/8LaUUVtw+LKDcAINPc/D5F/8zZLu/MIfoUdz8 X-Received: by 2002:a05:6a00:3c96:b0:6e4:b4ca:992b with SMTP id lm22-20020a056a003c9600b006e4b4ca992bmr15703752pfb.21.1709695576034; Tue, 05 Mar 2024 19:26:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709695576; cv=pass; d=google.com; s=arc-20160816; b=k0t9skR8Ymq/q6QBy4FTCD4SMD+KiFIwTpX6AmozrCN+p+FjzBrXXkHZwQgx5pPVJR 9TYmO6EpQBBL1sJyrgKO19GyZLqoGJntGhLRueTSD7o18Ik4a4fdhxMozmaqDmfGdTIN +7UKsldYgiPaP2i6+FdBI5G2nzN6EzgxyR2nfNBSBWxivpDYUHqxORkmKNW5926Pkftw +Oq5/6bXIvbUjuWmsbJiVIEqLgYYBW/0+I1Nk2S0riT8Rw+0SmkO8lDuRKCcTB6oWov5 +HERNqKw+nE7Si75Z+9usZXanrFr4y6PvPfMp96SEv/vqBY5quoX2zV/9nDI9vzcaJze j83Q== 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=hA5anOLDf9hOII6ZL+mpHqZgQ3rs+L/N8KnCrTRwBMY=; fh=zmGXTcG55KEzHBxY+UWewBTJRTUTvplR5Dt+Zy0qDE0=; b=p8p0kgYMaxihR7iQnFnl5XXh9Tq961aagvOnlF500Ln0gRIGR9ZRHB1WsvMcAOZQp3 PUMZZqzKYOGMu6z+dkNN4Yx5wqIhBuf4U4/ULkfg6GPIBiAYh8mh0soB6KOThoMU3JGr 2kc1JImydyCb0Je1Au/0xTlgc8hXebU92lNMX06N7RONZLd4i/yQIWf+un9BPIfCLzx+ 7n3znE6TGX1NDiTw26qjVzu67Vyym3ab3eMtUfxelGjVx4GZECaSUublQKX/x+xNRrAo l8+BoNaJsxQITL1TqvAFMiBcLNh9iZdX4fT452hFBPnKp9hyz91zL19CIh/zdgiLRM6F MSJg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@embeddedor.com header.s=default header.b=OgJGzG5u; arc=pass (i=1 spf=pass spfdomain=embeddedor.com dkim=pass dkdomain=embeddedor.com); spf=pass (google.com: domain of linux-kernel+bounces-93285-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93285-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j5-20020a63e745000000b005df433fcb8fsi10760897pgk.133.2024.03.05.19.26.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 19:26:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-93285-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=fail header.i=@embeddedor.com header.s=default header.b=OgJGzG5u; arc=pass (i=1 spf=pass spfdomain=embeddedor.com dkim=pass dkdomain=embeddedor.com); spf=pass (google.com: domain of linux-kernel+bounces-93285-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93285-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id ACF89289251 for ; Wed, 6 Mar 2024 03:26:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 195AE12E78; Wed, 6 Mar 2024 03:26:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=embeddedor.com header.i=@embeddedor.com header.b="OgJGzG5u" Received: from omta40.uswest2.a.cloudfilter.net (omta40.uswest2.a.cloudfilter.net [35.89.44.39]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E1D27DDBC for ; Wed, 6 Mar 2024 03:26:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=35.89.44.39 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709695567; cv=none; b=A/wR7DCfjlLkyTCO0VSfACtz9h9zXK/oI1nYbB9HuG3i1E63r0Z3nigQ+9tSS9/Z3/rg0DX5NXjLEQk4O8shQRaTS08FByifT50ROHxOs42c3OgSgN+ArlO98CshO7kxpkfo03E+S3IbpfCzkBsin/iQ5t35fk5eaKECudvYvCU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709695567; c=relaxed/simple; bh=zAReeEU8/qi5a+yFDj7UXBuoBjH1MPHcc7huo3+zByw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=qio0doQxK9UgGXqqV4iXC+OhQeEE/RXMwEj7DOSDrpwE3+fIYn02smAIUetmi3mDpGsrFZfw9WlgHOuz4BSAJJ5cl34VD/oUp3j0EtUlXvBT/BGCIPtG4zEJYY++DMfPJHfDRNrHPg060kfkkndluVnNFxSTcgAk2OO34y/wXUI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=embeddedor.com; spf=pass smtp.mailfrom=embeddedor.com; dkim=pass (2048-bit key) header.d=embeddedor.com header.i=@embeddedor.com header.b=OgJGzG5u; arc=none smtp.client-ip=35.89.44.39 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=embeddedor.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=embeddedor.com Received: from eig-obgw-6008a.ext.cloudfilter.net ([10.0.30.227]) by cmsmtp with ESMTPS id hefRraGC7PM1hhhumrLDfQ; Wed, 06 Mar 2024 03:25:56 +0000 Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with ESMTPS id hhulrMoGeikfchhumrkBNw; Wed, 06 Mar 2024 03:25:56 +0000 X-Authority-Analysis: v=2.4 cv=A7pqPbWG c=1 sm=1 tr=0 ts=65e7e244 a=1YbLdUo/zbTtOZ3uB5T3HA==:117 a=VhncohosazJxI00KdYJ/5A==:17 a=IkcTkHD0fZMA:10 a=K6JAEmCyrfEA:10 a=wYkD_t78qR0A:10 a=cm27Pg_UAAAA:8 a=XVdhlGlpZy0Tqqe4dGwA:9 a=QEXdDO2ut3YA:10 a=xmb-EsYY8bH0VWELuYED:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=embeddedor.com; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=hA5anOLDf9hOII6ZL+mpHqZgQ3rs+L/N8KnCrTRwBMY=; b=OgJGzG5urvOSye6X4o/ZpFKHHX TbW58mPd5ZZTTYRrOfSOsYbTltFxdq/haZS2WgK4RzIVvF6vv1E2KwmkmgVoaO8ts84sRaGGGLy4A JpAIy29MWILwYRBPY6ygZJ4Xb6JkMkR0A+20gaC9EyZPjW7qw9J/ld6ZpVB27UL+u2Dci3Tm7caLY 5OAiRCHSdvKjD8WrqiQCXOTi3bKUV0622cYY7YWN3zFrPjmKNiCaL6qnNrlGk/iGjnlFYrTqYcKAm wU5U99v5vc0nvjAba/Ymv1j9eur9ovuP/TcwFBetIXAZgib48WQgdySJx0DyGVd/JeGNheFLMa1kv vArK3QuQ==; Received: from [201.172.172.225] (port=46818 helo=[192.168.15.14]) by gator4166.hostgator.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96.2) (envelope-from ) id 1rhhuj-001ukg-2u; Tue, 05 Mar 2024 21:25:53 -0600 Message-ID: <9c2990f0-7407-49c6-9e3a-b92de82ea437@embeddedor.com> Date: Tue, 5 Mar 2024 21:25:51 -0600 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] overflow: Change DEFINE_FLEX to take __counted_by member Content-Language: en-US To: Kees Cook , Przemek Kitszel Cc: Jesse Brandeburg , Tony Nguyen , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Gustavo A. R. Silva" , intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-hardening@vger.kernel.org, Andrew Morton , linux-kernel@vger.kernel.org References: <20240306010746.work.678-kees@kernel.org> From: "Gustavo A. R. Silva" In-Reply-To: <20240306010746.work.678-kees@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 201.172.172.225 X-Source-L: No X-Exim-ID: 1rhhuj-001ukg-2u X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: ([192.168.15.14]) [201.172.172.225]:46818 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 1 X-Org: HG=hgshared;ORG=hostgator; X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfHuanEjSOjq60NWQIdNtYQCVhS/beZKDudcoiAVaokcAoax93F+6W1M8wskADsWkJC6Qr0stdFzPmOJQIaFj6Y9JiSeBqp84rScUN95xFTA3P5jHotBN KCCiqLn627WleIEPkk/NsTJMz21xP6DPjiJLsqlEtPmqIdQgm6NvrIeJxVrsz33Wan8Rn2Bl/f3quDuJYBdDx8u84IMhmQlBrZw7SuxdODl29gEp6RmB86i5 On 05/03/24 19:07, Kees Cook wrote: > The norm should be flexible array structures with __counted_by > annotations, so DEFINE_FLEX() is updated to expect that. Rename > the non-annotated version to DEFINE_RAW_FLEX(), and update the few > existing users. Additionally add self-tests to validate syntax and > size calculations. > > Signed-off-by: Kees Cook > --- [..] > +/** > + * DEFINE_FLEX() - Define an on-stack instance of structure with a trailing > + * flexible array member. > + * > + * @TYPE: structure type name, including "struct" keyword. > + * @NAME: Name for a variable to define. > + * @COUNTER: Name of the __counted_by member. > + * @MEMBER: Name of the array member. > + * @COUNT: Number of elements in the array; must be compile-time const. > + * > + * Define a zeroed, on-stack, instance of @TYPE structure with a trailing > + * flexible array member. > + * Use __struct_size(@NAME) to get compile-time size of it afterwards. > + */ > +#define DEFINE_FLEX(TYPE, NAME, COUNTER, MEMBER, COUNT) \ Probably, swapping COUNTER and MEMBER is better? DEFINE_FLEX(TYPE, NAME, MEMBER, COUNTER, COUNT) Thanks -- Gustavo