Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp144374pxb; Wed, 25 Aug 2021 22:57:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJJu72SEC9codlrpPo61wIDtaT5yynkxwGEaDYDGJ5YSCmm4nWnbhzV3O4hFujT6KEVaNp X-Received: by 2002:a17:906:691:: with SMTP id u17mr2428444ejb.149.1629957426794; Wed, 25 Aug 2021 22:57:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629957426; cv=none; d=google.com; s=arc-20160816; b=GF891aLfiAxkAs7xeNuwmIkjyhM4fvv0uMgPgTE779Mow74OS21cISApDTG+pj34re 04pHpiyVDVbeVOHGsrgPAHISnbpF4GE6YexdB+qlPHfB4FZEGKrAPxLx4jlO09KOTUb1 4pmMa1KL93hlinQWHMcjMsJbMUN+wIKxY8pC6SZ69EhaxI+LC0WdabpbLx2xGz5KrnJJ xxMpmOg7Oav1qoUtCN3rIEuGEUJdFEg3vrgqRdPhyl5GzE43S3Nm/MMiXLLqFsOjB0Jn et/Qa2Dvv63DkW59Hr2R18IZQW6K5o1KHeMq2phixqJv+mBBOUMkxmycVCGaP3Mpr4S3 VAQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ccQ0MGCdd2sOJEH6txbJHSp3br3UWRPN7Oxkykdkfrk=; b=eKnJFFLpM/7rMzqOOftWnOuaCxSBvl0wtgQa+eK8QDEmKAqy4oQXCFvppcHshkxJVE mWrB5uBvOzwQgUZbGINqNEKF5KM7FKQJ40GIMhe6P3PMFxZdJgoBkS8IJlV3QEbtD6MI lp8rvl2BWYUtBeBLv7Gqa965oAYEv0CvFMsv1gClHzHb1n3fk6lxuU0zPqxZclCmYmtg UFGfNE6aavxxQ51795w0I2BpGDOtxuzFgN1wt5P8yb3GzNleZedtWFOlfE8B9rQPMMuv TKi1a4WTSIFW4i/61cHY/x0yEIQ12tmSZvrUfca1GlUPJO3anSurBlYSVmfnZf1vJ7on ewEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=h98ncCno; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id he13si1927070ejc.28.2021.08.25.22.56.30; Wed, 25 Aug 2021 22:57:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=h98ncCno; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235822AbhHZFwK (ORCPT + 99 others); Thu, 26 Aug 2021 01:52:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231134AbhHZFwJ (ORCPT ); Thu, 26 Aug 2021 01:52:09 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87C26C0613C1 for ; Wed, 25 Aug 2021 22:51:22 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id h1so1468469pjs.2 for ; Wed, 25 Aug 2021 22:51:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ccQ0MGCdd2sOJEH6txbJHSp3br3UWRPN7Oxkykdkfrk=; b=h98ncCnoSgRO/F8RcTGwgl4lQgtwO7Z069Jg7gZwqH61LgYfFHRkVKlkk5SYejX3Qo wp+dBQvMBboIKtqJi98pwPqrfc0z40lBaUNd0lecBa90rVYJ+4XjuIYSPHipBNUKEW6J /Ns8wV2HFg8eY7ZT5jRFEk0xCu3jQqxN02ClQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ccQ0MGCdd2sOJEH6txbJHSp3br3UWRPN7Oxkykdkfrk=; b=P38jwgjbOXhWvn+XA5hanEvziURnlolZYqNtMM1MzjosofatVJ1skeL7bgON1vXRwg jghEc7E1pyhlZAoG5gjfHcKX6z9zWAuWZpcchX0iac8BVSDJr2VAA0qLhrQvhnQL6Bhm yRmSK7/YGCGgXpQRVkKP9+bIDb+QSnRm2MKWax6EsFa1YACQyx82bPRakP7HS2X4zm0y zxGU7C/hKBmVMj6Li/HAs9J0bynycfXJ0qrbBNVyqw4WmF3Jy17/iO45CcP8twR617GF mxnEvI+S3gaXe5s0YxjLOU8jmJFblWDBaoffwWMGGzTqRXI24Zf1k/Z91VnjdfGzKw6A CIqw== X-Gm-Message-State: AOAM531HC/f2kxtSd2++vi9hnWhAG3mmZLr5eoWUtRMFGAo7nHR86UOs cxTmaaea8NWY4hwa8Lo0hMAAjA== X-Received: by 2002:a17:90a:dac2:: with SMTP id g2mr14392631pjx.45.1629957082083; Wed, 25 Aug 2021 22:51:22 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id c24sm2088939pgj.11.2021.08.25.22.51.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Aug 2021 22:51:21 -0700 (PDT) Date: Wed, 25 Aug 2021 22:51:20 -0700 From: Kees Cook To: Keith Packard Cc: linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , Arnd Bergmann , Kalle Valo , "David S. Miller" , Jakub Kicinski , Nilesh Javali , Manish Rangankar , GR-QLogic-Storage-Upstream@marvell.com, "James E.J. Bottomley" , "Martin K. Petersen" , Larry Finger , Phillip Potter , Greg Kroah-Hartman , Florian Schilhabel , Johannes Berg , Christophe JAILLET , Fabio Aiuto , Ross Schmidt , Marco Cesati , ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-scsi@vger.kernel.org, linux-staging@lists.linux.dev, Rasmus Villemoes , Dan Williams , Daniel Vetter , clang-built-linux@googlegroups.com, linux-hardening@vger.kernel.org Subject: Re: [PATCH v2 3/5] treewide: Replace 0-element memcpy() destinations with flexible arrays Message-ID: <202108252250.C1DAEE5@keescook> References: <20210826050458.1540622-1-keescook@chromium.org> <20210826050458.1540622-4-keescook@chromium.org> <87r1egpym5.fsf@keithp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87r1egpym5.fsf@keithp.com> Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Wed, Aug 25, 2021 at 10:24:18PM -0700, Keith Packard wrote: > Kees Cook writes: > > > In some cases, use of the flex_array() helper is needed when a flexible > > array is part of a union. > > The code below seems to show that the helper is also needed when the > flexible array is the only member of a struct? Or is this just an > extension of the 'part of a union' clause? That's correct. I have that documented in the DECLARE_FLEX_ARRAY macro itself, but I mis-spoke in this changelog here (the uses were for "alone in a struct"). I've adjusted the changelog now. :) Thanks! -Kees > > > @@ -160,7 +160,7 @@ struct bmi_cmd { > > > > union bmi_resp { > > struct { > > - u8 payload[0]; > > + DECLARE_FLEX_ARRAY(u8, payload); > > } read_mem; > > struct { > > __le32 result; > > -- > -keith -- Kees Cook