Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp4217498iog; Tue, 28 Jun 2022 11:21:03 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uFPL0/pA1m/lkp13PC331Djb6IaZGx0aQSlpbhVXAv7x+0i+OoPB6cubyxmUrsczpw59EC X-Received: by 2002:a17:906:794a:b0:722:efd0:862f with SMTP id l10-20020a170906794a00b00722efd0862fmr18896273ejo.650.1656440463712; Tue, 28 Jun 2022 11:21:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656440463; cv=none; d=google.com; s=arc-20160816; b=APYbNKirfTxkEKX8+GxUhNCCBpJZvx/eWJDaHCk33h3L5JSl+bT7Vw+QVV5Nj9K6Fe j07NbsKsl7nkSpsfdNBGQZhXjXAOEwsQ/mYaM0gscX/jrANe+uDeELoXPCWcpgrhS2/J uw8L7z2Trk27Pkkwe2yXOBx2n/dlLCrmzY6ZGueBZeGb89pRMPB9qLU1Q0IvDplsDDjF UwwP1z9WQyIsJaZz4McsFZhqJqJfJ4CdXYIWJvgZIS36BSHmsaWWIizDm9pDlu2EHn/a 5PT80Hf/ORiZKRYOaNCd2XNxTWPMZrdO6EkpguEl+mGlRMes3JKeu3yPIyg+cblvHOdW nZwA== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=pTcGgtfSu6n7KkCWKQ4ciWe5XeKK5S4riO8KfNVW7Ig=; b=xXFwLScFsrIbcqzmPunXsivAbMcD82RuifzR9StkeD8TnbQki9/lPUmp/pvp69/iy5 SUBs3jHx1+zAKZCoDc72CBlx56E2IK6KOlHeiYKGZGilQakJxBoUF4kJG2FrJnK3Ey5U 6MLwiNajQXUL3fEUV+ohSe3fJ7igMhCFE2NHdwztqxIwa2HaUSBUo/98oA9tFTab45W1 LS32PBMxOXuTx6vINE/JNVAjXa1Km9tlhLeLc4eanmDR/mEUI1rz48spAEgOIRtN+k7l j0Dp10Bbk1v7KON5mBgMNZE20rFv6hYRQhqbiDfTwmPd63+AzQHyZggFMkudVrn9yuvs 0Lug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="F/CZTCTD"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f20-20020a056402355400b004379267f19csi427804edd.453.2022.06.28.11.20.37; Tue, 28 Jun 2022 11:21:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="F/CZTCTD"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S233904AbiF1SGI (ORCPT + 99 others); Tue, 28 Jun 2022 14:06:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233855AbiF1SGA (ORCPT ); Tue, 28 Jun 2022 14:06:00 -0400 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 456A61EAD6 for ; Tue, 28 Jun 2022 11:05:55 -0700 (PDT) Received: by mail-pf1-x42e.google.com with SMTP id p14so12713217pfh.6 for ; Tue, 28 Jun 2022 11:05:55 -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:content-transfer-encoding:in-reply-to; bh=pTcGgtfSu6n7KkCWKQ4ciWe5XeKK5S4riO8KfNVW7Ig=; b=F/CZTCTDOlhkWqZ+vOzW0DaoZ/EZ1dOhoCSSJ2RrwBNwuY7CCyvEtaLLk8DO+FYVI8 oY1bh2Rw2NH/e7uwuajkABgxQQynq/vb9wDrQT1ziurYSmeBDoqa9s9XGmGLyXXXVu1m Ptj/OKkdrLcBprdD9gQ9RffSNU26yKh9HCJiI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=pTcGgtfSu6n7KkCWKQ4ciWe5XeKK5S4riO8KfNVW7Ig=; b=yVKFab56u1lvloYqgLebNHTkaUcU9+BuvuPUBkEb5GFMjp1pv3RSRzI65DiOB+dw9N Q7cBOwXvoe56f6X9F/VvDbxlJgTBjV+voS3J/EUr83qCg+8bMcBZHd9+CWEUkZvq4X2E ZE4QSjddA+zuKLYHgTkaYeEvPiaskgTOyZEP9tN7AOWnghZ0xDdpJUVD0xhEg8IpdpgP cLKWnb+6zJsPXCRN3YHsWHxaFGi+YT83Io6ft9s+cvSiqfulLRZyEEjKGqreXHC0jMm7 ZKNpmczblox8UIcJW8X6tD5FNPNKmpRhZXjhPHR2noqY7lxNfuoPBpES8AyZG1K2jT5i P3Bw== X-Gm-Message-State: AJIora99J154rw3K9j4zhqSriRIlsPlz/06JCHKwgxJAqY4xhsZTMiy5 y9H3tKrrhfQLwC/0Tn6uIpJ0lA== X-Received: by 2002:a63:7412:0:b0:40c:fa27:9d07 with SMTP id p18-20020a637412000000b0040cfa279d07mr18441815pgc.27.1656439554674; Tue, 28 Jun 2022 11:05:54 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id i3-20020a170902cf0300b0016a0ac06424sm9669985plg.51.2022.06.28.11.05.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jun 2022 11:05:54 -0700 (PDT) Date: Tue, 28 Jun 2022 11:05:53 -0700 From: Kees Cook To: Geert Uytterhoeven Cc: "Gustavo A. R. Silva" , Linux Kernel Mailing List , the arch/x86 maintainers , dm-devel@redhat.com, linux-m68k , "open list:BROADCOM NVRAM DRIVER" , linux-s390 , KVM list , Intel Graphics Development , DRI Development , netdev , bpf , linux-btrfs , linux-can@vger.kernel.org, Linux FS Devel , linux1394-devel@lists.sourceforge.net, io-uring@vger.kernel.org, lvs-devel@vger.kernel.org, MTD Maling List , kasan-dev , Linux MMC List , nvdimm@lists.linux.dev, NetFilter , coreteam@netfilter.org, linux-perf-users@vger.kernel.org, linux-raid@vger.kernel.org, linux-sctp@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, Linux ARM , scsi , target-devel , USB list , virtualization@lists.linux-foundation.org, V9FS Developers , linux-rdma , ALSA Development Mailing List , linux-hardening@vger.kernel.org Subject: Re: [PATCH][next] treewide: uapi: Replace zero-length arrays with flexible-array members Message-ID: <202206281104.7CC3935@keescook> References: <20220627180432.GA136081@embeddedor> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 28, 2022 at 09:27:21AM +0200, Geert Uytterhoeven wrote: > Hi Gustavo, > > Thanks for your patch! > > On Mon, Jun 27, 2022 at 8:04 PM Gustavo A. R. Silva > wrote: > > There is a regular need in the kernel to provide a way to declare > > having a dynamically sized set of trailing elements in a structure. > > Kernel code should always use “flexible array members”[1] for these > > cases. The older style of one-element or zero-length arrays should > > no longer be used[2]. > > These rules apply to the kernel, but uapi is not considered part of the > kernel, so different rules apply. Uapi header files should work with > whatever compiler that can be used for compiling userspace. Right, userspace isn't bound by these rules, but the kernel ends up consuming these structures, so we need to fix them. The [0] -> [] changes (when they are not erroneously being used within other structures) is valid for all compilers. Flexible arrays are C99; it's been 23 years. :) But, yes, where we DO break stuff we need to workaround it, etc. -- Kees Cook