Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3291143iog; Mon, 27 Jun 2022 12:59:40 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sQ6sCxhjHyV0FE2NhioPMWFGEDD2xoJgeC+VFu+aUoX3/Y9IwOK+sNTJJ0nlLhghgp2Ey8 X-Received: by 2002:a17:907:6ea3:b0:726:ca39:5d98 with SMTP id sh35-20020a1709076ea300b00726ca395d98mr527916ejc.400.1656359980721; Mon, 27 Jun 2022 12:59:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656359980; cv=none; d=google.com; s=arc-20160816; b=x1I58QQMVEPsAKqV6O3WIQnJBo0G831ObufsoPuMlGcrj4H7zo/eUjo/3th3dav0T/ veKXwgKyRA0XKYWvNnT2Ys5GR9ydIMJ3rMu9BvqVgaQAYRuY5tPl7GAAnwLts5SwdW4A ZDKEFHvuWh5KPlGl5PtgAc9izxNvTos3776Wg9ghS7FMQlaxcjHWeEr8gh44eSzY55FT Wy6ExDnU4ds5n/TeRCeLzyMzkRunsUifj1LBn+hHfU3Rv7PdaCLvBlpzDRHGoQdUWonz 4JTsmnYxvmp5HE7lJa8hqAWfpgB2bMYHQ1edkhokXAnaY3TItqlxHIY1bzkiKqs470yo 5Ang== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=k/l4LcE4w+6LYrCo6/Ek+44r04gbnpHm9yyPA0qKR6A=; b=HfoGYgpY0pz4J2nZ8hfNsAexEQpWz6MXahlEqB1Ob2FTqZ1pwxLr/6K66hvnPXNsXG toyi9+OS9V5/yPEkYulGI2tsNc0Y5R/QRKw67dSQAUvPCaBNJEsss1i2pc5UUjAVarZ2 lXxWeaXWIk9niz/0kfkDxUixK8JlIL8u2LVrwNJ2pmzrNdjr0I3nZORT4EjomB6ymqR4 y32q3gSTu5jClEvPH+M8+sjVK+90IC5fUNKqGrqarN6X8aXy/zvuhRKZMz4db4/pyWaN SCc2ihSDWSUR87o5EOZSuCMY2M6cmfB3DAVFYBnl3EjXeW5WAblPwOv0G1Gb2BgBiMEC wDrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@networkplumber-org.20210112.gappssmtp.com header.s=20210112 header.b=ryYp2naL; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q11-20020a056402518b00b0042df65ab08csi15218571edd.578.2022.06.27.12.59.16; Mon, 27 Jun 2022 12:59:40 -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=@networkplumber-org.20210112.gappssmtp.com header.s=20210112 header.b=ryYp2naL; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241238AbiF0TyJ (ORCPT + 99 others); Mon, 27 Jun 2022 15:54:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241250AbiF0Txt (ORCPT ); Mon, 27 Jun 2022 15:53:49 -0400 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C4501AD86 for ; Mon, 27 Jun 2022 12:53:47 -0700 (PDT) Received: by mail-pg1-x533.google.com with SMTP id g4so3151620pgc.1 for ; Mon, 27 Jun 2022 12:53:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=k/l4LcE4w+6LYrCo6/Ek+44r04gbnpHm9yyPA0qKR6A=; b=ryYp2naL1201DMNfPmSbpexCs+zqiLsBQDBXHc9esFHxBJ8Ep2LLrsgHtxJtosu2+J 1iBYfvQQXv6NYwKQ2qXQCc4mHXYQGPYeeUC3hu2OgPUPjZXH+3Hi6Zqo5SyTeGerBVQA p1Bh5daOuP6Q9UMRPxlj6vxZpUjBpxOPEYhjttl3pP6gtksJnO1wA5G3ERXmm3iOhFrs MlyYmEaZt8I/cdZ0xlE1RQA9V/oE3k4e+iV7r8nrUlXmSvlRImOQktUmXD254MFh7ceV 2zbWTxt+/QD0MTYLBrv8xqePAliI2A59OkEqXOPrksIatTeOcW53aiRz+65e7KopsoX+ 3osw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=k/l4LcE4w+6LYrCo6/Ek+44r04gbnpHm9yyPA0qKR6A=; b=kVWMu45tuaJNB8P/yL2dBPUVSvs/sC8Vmu71rN+pweDPvaO+k/4ElQe0NlmFrN5j3Z yZkrZ1UjtjIy2HjvZbni/hlUY7buEFABldqQdi/ifxdcjnVUP18sSIPlYdfKsT28YIHC igA4xz9pxiOpNrk0FvcqNbaq9TYmFE0hBJV54kHCIhKYWa9yHwsBNDDRx8sOV/yIml21 wwwrIEim3TxemwmRpo9+GZJ1JoWg68P3NeRPPfLAl7tX4SBG47YdpOPjLtUXZvIs+fwb fRi52ZxLNsSWAWflJ+CxJOW9A8IasxoqpIn5vJmcVnSaaafRWfnyiKoJMO/YE2si6aSe eBNw== X-Gm-Message-State: AJIora/cvTyB+R7KM1vYMJBF3Gc1ZVI5VZ5rIfvAKi0KeTHHxUBnc814 SbRRhfI0tV7qYs5v6d0v18hqPA== X-Received: by 2002:a63:7a5d:0:b0:40c:fcbe:4799 with SMTP id j29-20020a637a5d000000b0040cfcbe4799mr14428539pgn.297.1656359626928; Mon, 27 Jun 2022 12:53:46 -0700 (PDT) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id c16-20020a056a00009000b0051c1b445094sm7821510pfj.7.2022.06.27.12.53.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jun 2022 12:53:46 -0700 (PDT) Date: Mon, 27 Jun 2022 12:53:43 -0700 From: Stephen Hemminger To: "Gustavo A. R. Silva" Cc: Kees Cook , linux-kernel@vger.kernel.org, x86@kernel.org, dm-devel@redhat.com, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-can@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux1394-devel@lists.sourceforge.net, io-uring@vger.kernel.org, lvs-devel@vger.kernel.org, linux-mtd@lists.infradead.org, kasan-dev@googlegroups.com, linux-mmc@vger.kernel.org, nvdimm@lists.linux.dev, netfilter-devel@vger.kernel.org, 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-kernel@lists.infradead.org, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, linux-usb@vger.kernel.org, virtualization@lists.linux-foundation.org, v9fs-developer@lists.sourceforge.net, linux-rdma@vger.kernel.org, alsa-devel@alsa-project.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH][next] treewide: uapi: Replace zero-length arrays with flexible-array members Message-ID: <20220627125343.44e24c41@hermes.local> In-Reply-To: <20220627180432.GA136081@embeddedor> References: <20220627180432.GA136081@embeddedor> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 Mon, 27 Jun 2022 20:04:32 +0200 "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 =E2=80=9Cflexible array members=E2=80=9D[1]= for these > cases. The older style of one-element or zero-length arrays should > no longer be used[2]. >=20 > This code was transformed with the help of Coccinelle: > (linux-5.19-rc2$ spatch --jobs $(getconf _NPROCESSORS_ONLN) --sp-file scr= ipt.cocci --include-headers --dir . > output.patch) >=20 > @@ > identifier S, member, array; > type T1, T2; > @@ >=20 > struct S { > ... > T1 member; > T2 array[ > - 0 > ]; > }; >=20 > -fstrict-flex-arrays=3D3 is coming and we need to land these changes > to prevent issues like these in the short future: >=20 > ../fs/minix/dir.c:337:3: warning: 'strcpy' will always overflow; destinat= ion buffer has size 0, > but the source string has length 2 (including NUL byte) [-Wfortify-source] > strcpy(de3->name, "."); > ^ >=20 > Since these are all [0] to [] changes, the risk to UAPI is nearly zero. If > this breaks anything, we can use a union with a new member name. >=20 > [1] https://en.wikipedia.org/wiki/Flexible_array_member > [2] https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-le= ngth-and-one-element-arrays >=20 > Link: https://github.com/KSPP/linux/issues/78 > Build-tested-by: https://lore.kernel.org/lkml/62b675ec.wKX6AOZ6cbE71vtF%2= 5lkp@intel.com/ > Signed-off-by: Gustavo A. R. Silva Thanks this fixes warning with gcc-12 in iproute2. In function =E2=80=98xfrm_algo_parse=E2=80=99, inlined from =E2=80=98xfrm_state_modify.constprop=E2=80=99 at xfrm_stat= e.c:573:5: xfrm_state.c:162:32: warning: writing 1 byte into a region of size 0 [-Wstr= ingop-overflow=3D] 162 | buf[j] =3D val; | ~~~~~~~^~~~~