From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_SOFTFAIL,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9513DC43334 for ; Mon, 27 Jun 2022 19:54:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240991AbiF0TyZ (ORCPT ); Mon, 27 Jun 2022 15:54:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241259AbiF0Txu (ORCPT ); Mon, 27 Jun 2022 15:53:50 -0400 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 938441ADBE for ; Mon, 27 Jun 2022 12:53:47 -0700 (PDT) Received: by mail-pg1-x531.google.com with SMTP id z14so10102287pgh.0 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=YMCl80X8V9dJxr8W0HavXyKAlwfNeiy4239KcNKt0m/97Ljit0Sp0VOW26213+twk2 FXCg5EanLhW/2zx4D20N2XoBdmHXSx9kJLdBuj2tryKdSGryV5DYm/R703AnNSoL0kdk Z6hR+HYy/jxUqC09SNJErBp1fMUHjV4PXk/2eBnwH/remkZdgD5X7Zx/9cn29W6QrnXR GuAAY/VFTr+z8NKpSpC5dCens79bqUj8eUwwX+7S+DGF8f80CEfVVQrk1grLO4hGsDfL 0DXl6SkE4w0e6rtqbvm74/EuS217dxBERibfeZ3XnDa+WWUplxJlLVEWXKmwwhI+zJBu lR3Q== X-Gm-Message-State: AJIora86oYFP2yawJVErK1FUmqy6ghWNNc7Qlunt0CAuckgjG4Hih0AI WL5rfoK/jVLm+DHwRh460YJUjg== X-Google-Smtp-Source: AGRyM1ssDeW6Ux1oaY9ixgaaapzXMFszbxcRVeOWaHAYiiaVMZ4HUYtPzqxXzR6I8+fqeJNf8u9hpg== 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 Precedence: bulk List-ID: X-Mailing-List: io-uring@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; | ~~~~~~~^~~~~