From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3EFF6A0544; Wed, 8 Jun 2022 17:23:10 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D74FF4069C; Wed, 8 Jun 2022 17:23:09 +0200 (CEST) Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) by mails.dpdk.org (Postfix) with ESMTP id 50BCA40687 for ; Wed, 8 Jun 2022 17:23:08 +0200 (CEST) Received: by mail-pg1-f175.google.com with SMTP id 129so19205621pgc.2 for ; Wed, 08 Jun 2022 08:23:08 -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=AynklfquO/rcZDNIHtCJkr1yuKW11xtNiKElBFfeN+M=; b=Nx5BKJZtP7Vi7JVDF6JIWmrIBQFpOEav96T+fZLBoGQDRxpMfc0hT/XrgXCFD8AVtp Ehvt1FLWAKQYk9O5lM6SyKOsKO5Gf4HS/vaAh0hcbnKyWMoZaPglao4l77qL7UjgX3ft 2ChkrN3xCWcu/95alRxHaCLr9aemHdGIm+5ylsmAbnXAryfbvbFcCx81NPnsv4urHZvw E16p2ZMIxWAeVqIy7ZptKosvA9BGXO9H/sbR2qkE6WpGHPDP4qiaLUyvmM7QAnQyDgs+ fpPvOPGm9NOELn6ilNA6puSNFzBhl5M+PhdqxigzPEm6sPzC8s5xFa4zPKOKOcK27CAl Disw== 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=AynklfquO/rcZDNIHtCJkr1yuKW11xtNiKElBFfeN+M=; b=tonkhvGWNlmvRb+WQETIeVFwEB0LOyihAWnkz0KNPlvhEc5oEvvUT4MvU3v6Ji1J7K bA8E2n64QM4D8oJaizOHaWwGE8DaESi4F0qeJbmTGVmRVtZ0bzds9d1BQMELX79BdNDg 5GWOuET5BadDEvXNSmzJ7j+SQybtN4pKMmYF8qvAJhkjTu8KwP6bb1o+rlrrvTiUnkky u2KSGq79TmvQHyLDOwGcX0K9XvppXPh+hf3xPvTIX15M1WCOKmwNRcyTo+WzkbGlEltu 4YAcWKv39SzE+xm+HRwTDb33faEnR4SEDCfBNZ8tlhkmVseiocS7ToEjn0j6+L3oxYtd ENwA== X-Gm-Message-State: AOAM530JO6JDbWUuSY9rRHGZGcFWglGaruCXJWDzLjfTNnZT7oVHUTmg EIJVWC+0phm+djkQ9nZM8ucd5xr3aqe/EA== X-Google-Smtp-Source: ABdhPJx7almApkx+00i4ZJuRiKv71TxRysICNZ7dpWYKoo5lguwrAMKs1CF9fgPL+8hzga581Zfg3w== X-Received: by 2002:a63:69c5:0:b0:3fb:a606:819a with SMTP id e188-20020a6369c5000000b003fba606819amr30458397pgc.81.1654701787320; Wed, 08 Jun 2022 08:23:07 -0700 (PDT) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id l19-20020a170902d35300b0015e8d4eb2easm14747609plk.308.2022.06.08.08.23.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 08:23:06 -0700 (PDT) Date: Wed, 8 Jun 2022 08:23:02 -0700 From: Stephen Hemminger To: Bruce Richardson Cc: dev@dpdk.org, david.marchand@redhat.com, ktraynor@redhat.com Subject: Re: [PATCH 0/4] clean up zero-length arrays Message-ID: <20220608082302.09de7deb@hermes.local> In-Reply-To: <20220602150834.643745-1-bruce.richardson@intel.com> References: <20220602150834.643745-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Thu, 2 Jun 2022 16:08:30 +0100 Bruce Richardson wrote: > This patchset adds a coccinelle script to clean-up zero-length > arrays in structures. The final patches are the result of running > that script on the DPDK repository. >=20 > Bruce Richardson (4): > cocci: add script for zero-length arrays in structs > drivers: replace zero-length arrays with undimensioned ones > lib: replace zero-length arrays with undimensioned ones > app: examples: replace zero-length arrays with undimensioned ones >=20 > app/test/test_table_tables.c | 2 +- > devtools/cocci/zero_length_array.cocci | 21 +++++++++++++++ > drivers/bus/dpaa/include/netcfg.h | 4 +-- > drivers/bus/vmbus/rte_vmbus_reg.h | 4 +-- > drivers/common/cnxk/roc_se.h | 2 +- > drivers/common/dpaax/caamflib/desc/ipsec.h | 2 +- > drivers/common/dpaax/dpaax_iova_table.h | 2 +- > drivers/common/mlx5/mlx5_prm.h | 10 +++---- > drivers/crypto/ipsec_mb/ipsec_mb_private.h | 4 +-- > drivers/crypto/virtio/virtio_ring.h | 4 +-- > drivers/crypto/virtio/virtqueue.h | 2 +- > drivers/net/atlantic/hw_atl/hw_atl_utils.h | 2 +- > drivers/net/cxgbe/clip_tbl.h | 2 +- > drivers/net/cxgbe/l2t.h | 2 +- > drivers/net/cxgbe/mps_tcam.h | 2 +- > drivers/net/cxgbe/smt.h | 2 +- > drivers/net/enic/base/vnic_devcmd.h | 2 +- > drivers/net/hinic/hinic_pmd_tx.h | 2 +- > drivers/net/mlx5/mlx5_tx.h | 2 +- > drivers/net/nfp/nfpcore/nfp_nsp.h | 2 +- > drivers/net/virtio/virtio_ring.h | 4 +-- > drivers/net/virtio/virtio_user/vhost_kernel.c | 2 +- > drivers/net/virtio/virtio_user/vhost_vdpa.c | 2 +- > drivers/net/virtio/virtqueue.h | 2 +- > drivers/regex/mlx5/mlx5_rxp.h | 4 +-- > examples/ip_reassembly/main.c | 2 +- > examples/ptpclient/ptpclient.c | 4 +-- > lib/cryptodev/cryptodev_pmd.h | 2 +- > lib/cryptodev/rte_cryptodev.h | 2 +- > lib/eventdev/rte_event_timer_adapter.h | 2 +- > lib/ip_frag/ip_reassembly.h | 2 +- > lib/ipsec/sa.h | 2 +- > lib/rib/rte_rib.c | 2 +- > lib/rib/rte_rib6.c | 2 +- > lib/table/rte_swx_table_learner.c | 4 +-- > lib/table/rte_table_hash_key16.c | 4 +-- > lib/table/rte_table_hash_key32.c | 4 +-- > lib/table/rte_table_hash_key8.c | 4 +-- > lib/vhost/rte_vhost.h | 4 +-- > 40 files changed, 101 insertions(+), 54 deletions(-) > create mode 100644 devtools/cocci/zero_length_array.cocci > create mode 100644 lib/count_comments.py >=20 > -- > 2.34.1 >=20 Bruce, looking at this commit, it looks like the underlying cause of the problem with iavf was it is using array size of one when flex array should be used: commit b5b3ea803e4741ad6a46a38d8227c78226d9054d Author: Kevin Traynor Date: Fri Apr 17 16:43:35 2020 +0100 eal/x86: ignore gcc 10 stringop-overflow warnings =20 stringop-overflow warns when it sees a possible overflow in a string operation. =20 In the rte_memcpy functions different branches are taken depending on the size. stringop-overflow is raised for the branches in the function where it sees the static size of the src could be overflowed. =20 However, in reality a correct size argument and in some cases dynamic allocation would ensure that this does not happen. =20 For example, in the case below for key, the correct path will be chosen in rte_memcpy_generic at runtime based on the size argument but as some paths in the function could lead to a cast to 32 bytes a warning is raised. =20 In function =E2=80=98_mm256_storeu_si256=E2=80=99, inlined from =E2=80=98rte_memcpy_generic=E2=80=99 at ../lib/librte_eal/common/include/arch/x86/rte_memcpy.h:315:2, inlined from =E2=80=98iavf_configure_rss_key=E2=80=99 at ../lib/librte_eal/common/include/arch/x86/rte_memcpy.h:869:10: =20 /usr/lib/gcc/x86_64-redhat-linux/10/include/avxintrin.h:928:8: warning: writing 32 bytes into a region of size 1 [-Wstringop-overflow= =3D] 928 | *__P =3D __A; | ~~~~~^~~~~ In file included from ../drivers/net/iavf/../../common/iavf/iavf_prototype.h:10, from ../drivers/net/iavf/iavf.h:9, from ../drivers/net/iavf/iavf_vchnl.c:22: =20 ../drivers/net/iavf/iavf_vchnl.c: In function =E2=80=98iavf_configure_rss_key=E2=80=99: =20 ../drivers/net/iavf/../../common/iavf/virtchnl.h:508:5: note: at offset 0 to object =E2=80=98key=E2=80=99 with size 1 declared = here 508 | u8 key[1]; /* RSS hash key, packed bytes */ | ^~~ =20 Ignore the stringop-overflow warnings for rte_memcpy.h functions. =20 Bugzilla ID: 394 Bugzilla ID: 421 Cc: stable@dpdk.org =20 Signed-off-by: Kevin Traynor Acked-by: Bruce Richardson Acked-by: Konstantin Ananyev