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 C9D0ACCA483 for ; Tue, 28 Jun 2022 18:06:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233897AbiF1SGE (ORCPT ); Tue, 28 Jun 2022 14:06:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233578AbiF1SF5 (ORCPT ); Tue, 28 Jun 2022 14:05:57 -0400 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28A741D0DC for ; Tue, 28 Jun 2022 11:05:55 -0700 (PDT) Received: by mail-pg1-x52a.google.com with SMTP id 184so12900822pga.12 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=7jG8sTiO6sV0v1J1n+59XF0c0KAIwITk849bGxJFJsVGnbH4ioktQ+Lgbo1J+IWBsT bavKjb3VOHOYqsQhYOzf13Iww5wqM2um9m+6t5CojAVsBjoLlCThYwRsNT4r5E44yg6h Mf5HZIieUK5Ghc2GkLJ8gQYiJ59JpX+T9v6pzfecIg+tVJpS+6DSnLVln5SPKDlUKkfy WzUXFVxZYhTAqGUWecOEs1dTIy1t7i9qOD76EdpGBex4AnYz67vb3jwiOZFnM0g2OuZp cXncvrBMe9iLrFdTBIDMtEcVNORo6ctBKyOrTq8/egz9ZcN/lsMundGl1u53pwMFU7Ze ye7g== X-Gm-Message-State: AJIora+BKbY7WOJJU9paeyATIQs9lApOfGL2aWMCwyx7XKtJo642C42P Y1Mb1OPWmh9x8jTa6E39+SYZvw== 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-mips@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