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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 966DDC43334 for ; Tue, 28 Jun 2022 18:05:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233284AbiF1SF5 (ORCPT ); Tue, 28 Jun 2022 14:05:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232388AbiF1SF4 (ORCPT ); Tue, 28 Jun 2022 14:05:56 -0400 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27AE81CFF8 for ; Tue, 28 Jun 2022 11:05:55 -0700 (PDT) Received: by mail-pg1-x52b.google.com with SMTP id h192so12949697pgc.4 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=bNTZoYxgAeGyZRnrNTb1d/k9Kz7CnoIzX1Tiq/BrGktcS6sEyurwC4HoxQPGaK/wAY YFzcq80YVCfq1iSJojSKiYNoDxtTUi4g5Uf9VJGlErNLAZ20IZzEg3emNp0eYWdDulRa sTHpPazgttAZww2He3Otdv2JbTqKon3VU0dNc++VKn9zwX736M+bxu1gpFTV8EaufITU Xk852RoQBKSGAR0uF5R70Ivqcao5VV4tLmzFQ3ZaLwQBXviCPHHDDtraME+MHSDYCTVB eTOHAOm2FycxgmdOs/A5J/AYhV8t6nvBaI4v5fegf4EwutRwl/8N+DEmW73ISc3DPSwB rUJA== X-Gm-Message-State: AJIora9TvjfMCUwCKiqEL/6h6rElTI/esMbmPWm54tel6acf5BrEmnwl rbM8zM9ImHTvlecU7O+9fjKLKg== X-Google-Smtp-Source: AGRyM1v6cdnwBfGpeB2JnkCbahQ14YUYaqjRd3VUKbR8YPBigZjfWVkzlvmFIFzfbBj+r2XqbA+86w== 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: Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@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