From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CDEF8C05052 for ; Fri, 18 Aug 2023 07:14:22 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 6738941BE6; Fri, 18 Aug 2023 07:14:22 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 6738941BE6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1692342862; bh=qgmFWtFVqPa5OLq/9W/+//9MIU8aWink+NGl6V/CMVY=; h=From:To:Date:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=kVIa8+JMmLPqLf1JKp1CR+ngznLQF1lnJ65iBXIFV+/J4UrFIS4gJAEhf53uUNlQR Ot5g1+vVl8+vZ3P84bsBM2jQe+3RuS9tjj2BHg8s6AsY4AyILxQ+Lm0qe/MqFmkPVR XwhKHX9vX3swBmE201ceWp2cMghVH3x6WG1SYMyr4QlEz3hEJCXIp0qFl+DKBwkN1T 42V4Lpb0hRygYOVnXz3H9naiwYEGFHLsQObOt3l2GNXry5XtXqjMr1qgzKWGFpBYZW ZS8tALh4c6IEycm7qZs5Q0WV5qjD8Apx9eLy8C84d1HxenAv2XTQeWWIwP5zVh/pYl yscfYB70L7Alg== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5qjSNTKjJDJ4; Fri, 18 Aug 2023 07:14:21 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp4.osuosl.org (Postfix) with ESMTP id 2C23341B80; Fri, 18 Aug 2023 07:14:21 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 2C23341B80 Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 8D32C1BF378 for ; Fri, 18 Aug 2023 07:14:19 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 6424A60E81 for ; Fri, 18 Aug 2023 07:14:19 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 6424A60E81 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8C2Btes3-9bH for ; Fri, 18 Aug 2023 07:14:18 +0000 (UTC) X-Greylist: delayed 59926 seconds by postgrey-1.37 at util1.osuosl.org; Fri, 18 Aug 2023 07:14:17 UTC DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org E1B6760E5D Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) by smtp3.osuosl.org (Postfix) with ESMTPS id E1B6760E5D for ; Fri, 18 Aug 2023 07:14:17 +0000 (UTC) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with both STARTTLS and AUTH (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-74-ikIsBU2DMkidrrqivs1qkQ-1; Fri, 18 Aug 2023 08:14:14 +0100 X-MC-Unique: ikIsBU2DMkidrrqivs1qkQ-1 Received: from AcuMS.Aculab.com (10.202.163.6) by AcuMS.aculab.com (10.202.163.6) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Fri, 18 Aug 2023 08:14:12 +0100 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Fri, 18 Aug 2023 08:14:12 +0100 From: David Laight To: 'Kees Cook' Thread-Topic: [PATCH net-next v3 1/7] overflow: add DEFINE_FLEX() for on-stack allocs Thread-Index: AQHZ0EteSw2XTdntxkSn8fWObNOCVK/uiVWQgAAd6ICAAP4u4A== Date: Fri, 18 Aug 2023 07:14:11 +0000 Message-ID: References: <20230816140623.452869-1-przemyslaw.kitszel@intel.com> <20230816140623.452869-2-przemyslaw.kitszel@intel.com> <1f9cb37f21294c31a01af62fd920f070@AcuMS.aculab.com> <202308170957.F511E69@keescook> In-Reply-To: <202308170957.F511E69@keescook> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Subject: Re: [Intel-wired-lan] [PATCH net-next v3 1/7] overflow: add DEFINE_FLEX() for on-stack allocs X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 'Przemek Kitszel' , Steven Zou , "intel-wired-lan@lists.osuosl.org" , "linux-hardening@vger.kernel.org" , "netdev@vger.kernel.org" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" From: Kees Cook > Sent: Thursday, August 17, 2023 6:00 PM > > On Thu, Aug 17, 2023 at 02:35:23PM +0000, David Laight wrote: > > From: Przemek Kitszel > > > Sent: Wednesday, August 16, 2023 3:06 PM ... > > > +#define DEFINE_FLEX(type, name, member, count) \ > > > + union { \ > > > + u8 bytes[struct_size_t(type, member, count)]; \ > > > + type obj; \ > > > + } name##_u __aligned(_Alignof(type)) = {}; \ > > > > You shouldn't need the _Alignof() it is the default. > > In the sense that since "type" is in the union, it's okay? The alignment of the union is the larger of the alignments of all its members. Which is what you want. > > I'm not sure you should be forcing the memset() either. > > This already got discussed: better to fail safe. Perhaps call it DEFINE_FLEX_Z() to make this clear and give the option for a non-zeroing version later. Not everyone wants the expense of zeroing everything. .. > > You might want to add: > > Static_assert(is_constexpr(count), "DEFINE_FLEX: non-constant count " #count); > > That would be nice, though can Static_assert()s live in the middle of > variable definitions? I checked and it is fine. (I double-checked by adding a statement and getting an error.) David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales) _______________________________________________ Intel-wired-lan mailing list Intel-wired-lan@osuosl.org https://lists.osuosl.org/mailman/listinfo/intel-wired-lan