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 303BCA0544; Wed, 8 Jun 2022 17:26:49 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 135B54069C; Wed, 8 Jun 2022 17:26:49 +0200 (CEST) Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by mails.dpdk.org (Postfix) with ESMTP id 22ABF40687 for ; Wed, 8 Jun 2022 17:26:48 +0200 (CEST) Received: by mail-pf1-f174.google.com with SMTP id bo5so18637780pfb.4 for ; Wed, 08 Jun 2022 08:26:48 -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=46gr7r+KdHeyPLxjU25jbflUSCJDpNH3s32JvS33c0Q=; b=1THz5ug5NmkadTpzjk/6bHaT/WR9kQMYEKPsI4SbOvRvmOQqIFpkfNK/u6+mERNx10 z6hwjDOABIk945YJ0ZwAnV7fC8OFjUfYQJdSaXxAbd62NTTKTdiz3Sv4Aeqb3HusYEa0 +fLTxqj0pHX1epngKGGs1+LRWkVoAZcnmfFL4ePd5zywzvaO0jeEmM5mdPC4Aln96QPu oqz3c5EBS/WdZrDfvXo3pyk6xwSiMZWm+5Af0Kz723UC4E0MF8E/xf/6NkVMu8jmRGmf BYZM/hneP2LvcFEmwmTyip/otPJBsD/LXeD2Fwh0X7yGQk/zqNRhvnJDKcfYMecgsWSw VV2g== 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=46gr7r+KdHeyPLxjU25jbflUSCJDpNH3s32JvS33c0Q=; b=emuJbVAGL+gyI967GZfyGZdm+e1UsNDjIlfLxE5dGYQ4sEpALKKMZpLMRyJjUtsikk DjB5w1JE4/I9hXToNSieUE6BF4jVp9dsA916KoDUApbItKGdx0Q3k21KTZLCZfwtAreV uWeDg78mqCSEUBiEoswmaaRusix/1dM49KVqlQ1zqZiygVPIRE3UAb3nO565CyGI8SWt 4LMVtAPCLHyHiO71pVRnpEqDkrXKFvgn9kAynzwLTjVNfRuAYWvWfgL0eXcbYN/bUjF0 04ZyXPViK3K6sD9y2dsvbpuHr20DGVCGOvAmVgOFGHV/INec3NsoaB18eDSp80bNs5XO G9uw== X-Gm-Message-State: AOAM530HHRQsP1/OccQuAEfrTX2CW5CWfan7U9PrXDeuiySPrxBHS14o N2Sxs3YYUULiVhGvOCDBmTkMLv9ed4DTHg== X-Google-Smtp-Source: ABdhPJzILs77mEucv6MX5jYe+J7Ni1laVUHEFiRBX9fBjm9gCgIpCZ6/Lmyyf9EYLAmXwdbjqMLhMg== X-Received: by 2002:a63:89c2:0:b0:3fc:8bd2:aa5a with SMTP id v185-20020a6389c2000000b003fc8bd2aa5amr30140273pgd.362.1654702007221; Wed, 08 Jun 2022 08:26:47 -0700 (PDT) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id d12-20020aa7814c000000b0051877c10ec4sm15719085pfn.175.2022.06.08.08.26.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 08:26:46 -0700 (PDT) Date: Wed, 8 Jun 2022 08:26:44 -0700 From: Stephen Hemminger To: Konstantin Ananyev Cc: dev@dpdk.org Subject: Re: [RFC 8/8] ip_frag: fix gcc-12 warnings Message-ID: <20220608082644.5f99029e@hermes.local> In-Reply-To: <5549a996-a058-a9e4-f3f3-f31bfb198d6a@yandex.ru> References: <20220607171746.461772-1-stephen@networkplumber.org> <20220607171746.461772-9-stephen@networkplumber.org> <5549a996-a058-a9e4-f3f3-f31bfb198d6a@yandex.ru> 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 Wed, 8 Jun 2022 09:19:20 +0100 Konstantin Ananyev wrote: > 07/06/2022 18:17, Stephen Hemminger =D0=BF=D0=B8=D1=88=D0=B5=D1=82: > > The function rte_memcpy can derference past source buffer which > > will cause array out of bounds warnings. But there is no good reason > > to use rte_memcpy instead of memcpy in this code. Memcpy is just > > as fast for these small inputs, and compiler will optimize. =20 >=20 >=20 > AFAIK, rte_memcpy() will outperform memcpy() when _size_ parameter > is a variable. Unfortunately that's exactly the case here. > So not sure it is a good change, at least without extensive perf testing. > BTW, if rte_memcpy() really access src buffer beyond it's boundaries, > I think that's definitely a bug that needs to be fixed. Yes and no. IMHO DPDK should not in the C library business, and glibc etc should be more optimized if necessary. The ip_frag warning with rte_memcpy in full is: [296/3606] Compiling C object lib/libr...a.p/ip_frag_rte_ipv4_fragmentation= .c.o In file included from /usr/lib/gcc/x86_64-linux-gnu/12/include/immintrin.h:= 43, from /usr/lib/gcc/x86_64-linux-gnu/12/include/x86intrin.h:= 32, from ../lib/eal/x86/include/rte_vect.h:31, from ../lib/eal/x86/include/rte_memcpy.h:17, from ../lib/ip_frag/rte_ipv4_fragmentation.c:8: In function =E2=80=98_mm256_storeu_si256=E2=80=99, inlined from =E2=80=98rte_mov32=E2=80=99 at ../lib/eal/x86/include/rte_= memcpy.h:347:2, inlined from =E2=80=98rte_mov128=E2=80=99 at ../lib/eal/x86/include/rte= _memcpy.h:369:2, inlined from =E2=80=98rte_memcpy_generic=E2=80=99 at ../lib/eal/x86/inc= lude/rte_memcpy.h:445:4, inlined from =E2=80=98rte_memcpy=E2=80=99 at ../lib/eal/x86/include/rte= _memcpy.h:853:10, inlined from =E2=80=98__create_ipopt_frag_hdr=E2=80=99 at ../lib/ip_fra= g/rte_ipv4_fragmentation.c:68:4, inlined from =E2=80=98rte_ipv4_fragment_packet=E2=80=99 at ../lib/ip_fr= ag/rte_ipv4_fragmentation.c:242:16: /usr/lib/gcc/x86_64-linux-gnu/12/include/avxintrin.h:935:8: warning: array = subscript =E2=80=98__m256i_u[1]=E2=80=99 is partly outside array bounds of = =E2=80=98uint8_t[60]=E2=80=99 {aka =E2=80=98unsigned char[60]=E2=80=99} [-W= array-bounds] 935 | *__P =3D __A; | ~~~~~^~~~~ ../lib/ip_frag/rte_ipv4_fragmentation.c: In function =E2=80=98rte_ipv4_frag= ment_packet=E2=80=99: ../lib/ip_frag/rte_ipv4_fragmentation.c:122:17: note: at offset [52, 60] in= to object =E2=80=98ipopt_frag_hdr=E2=80=99 of size 60 122 | uint8_t ipopt_frag_hdr[IPV4_HDR_MAX_LEN]; | ^~~~~~~~~~~~~~ In function =E2=80=98_mm256_storeu_si256=E2=80=99, inlined from =E2=80=98rte_mov32=E2=80=99 at ../lib/eal/x86/include/rte_= memcpy.h:347:2, inlined from =E2=80=98rte_mov128=E2=80=99 at ../lib/eal/x86/include/rte= _memcpy.h:370:2, inlined from =E2=80=98rte_memcpy_generic=E2=80=99 at ../lib/eal/x86/inc= lude/rte_memcpy.h:445:4, inlined from =E2=80=98rte_memcpy=E2=80=99 at ../lib/eal/x86/include/rte= _memcpy.h:853:10, inlined from =E2=80=98__create_ipopt_frag_hdr=E2=80=99 at ../lib/ip_fra= g/rte_ipv4_fragmentation.c:68:4, inlined from =E2=80=98rte_ipv4_fragment_packet=E2=80=99 at ../lib/ip_fr= ag/rte_ipv4_fragmentation.c:242:16: /usr/lib/gcc/x86_64-linux-gnu/12/include/avxintrin.h:935:8: warning: array = subscript [2, 3] is outside array bounds of =E2=80=98uint8_t[60]=E2=80=99 {= aka =E2=80=98unsigned char[60]=E2=80=99} [-Warray-bounds] 935 | *__P =3D __A; | ~~~~~^~~~~ ../lib/ip_frag/rte_ipv4_fragmentation.c: In function =E2=80=98rte_ipv4_frag= ment_packet=E2=80=99: ../lib/ip_frag/rte_ipv4_fragmentation.c:122:17: note: at offset [84, 124] i= nto object =E2=80=98ipopt_frag_hdr=E2=80=99 of size 60 122 | uint8_t ipopt_frag_hdr[IPV4_HDR_MAX_LEN]; | ^~~~~~~~~~~~~~ In function =E2=80=98_mm256_storeu_si256=E2=80=99, inlined from =E2=80=98rte_mov32=E2=80=99 at ../lib/eal/x86/include/rte_= memcpy.h:347:2, inlined from =E2=80=98rte_mov128=E2=80=99 at ../lib/eal/x86/include/rte= _memcpy.h:371:2, inlined from =E2=80=98rte_memcpy_generic=E2=80=99 at ../lib/eal/x86/inc= lude/rte_memcpy.h:445:4, inlined from =E2=80=98rte_memcpy=E2=80=99 at ../lib/eal/x86/include/rte= _memcpy.h:853:10, inlined from =E2=80=98__create_ipopt_frag_hdr=E2=80=99 at ../lib/ip_fra= g/rte_ipv4_fragmentation.c:68:4, inlined from =E2=80=98rte_ipv4_fragment_packet=E2=80=99 at ../lib/ip_fr= ag/rte_ipv4_fragmentation.c:242:16: /usr/lib/gcc/x86_64-linux-gnu/12/include/avxintrin.h:935:8: warning: array = subscript [3, 4] is outside array bounds of =E2=80=98uint8_t[60]=E2=80=99 {= aka =E2=80=98unsigned char[60]=E2=80=99} [-Warray-bounds] 935 | *__P =3D __A; | ~~~~~^~~~~ ../lib/ip_frag/rte_ipv4_fragmentation.c: In function =E2=80=98rte_ipv4_frag= ment_packet=E2=80=99: ../lib/ip_frag/rte_ipv4_fragmentation.c:122:17: note: at offset [116, 156] = into object =E2=80=98ipopt_frag_hdr=E2=80=99 of size 60 122 | uint8_t ipopt_frag_hdr[IPV4_HDR_MAX_LEN]; | ^~~~~~~~~~~~~~ In function =E2=80=98_mm256_storeu_si256=E2=80=99, inlined from =E2=80=98rte_mov32=E2=80=99 at ../lib/eal/x86/include/rte_= memcpy.h:347:2, inlined from =E2=80=98rte_mov64=E2=80=99 at ../lib/eal/x86/include/rte_= memcpy.h:358:2, inlined from =E2=80=98rte_memcpy_generic=E2=80=99 at ../lib/eal/x86/inc= lude/rte_memcpy.h:452:4, inlined from =E2=80=98rte_memcpy=E2=80=99 at ../lib/eal/x86/include/rte= _memcpy.h:853:10, inlined from =E2=80=98__create_ipopt_frag_hdr=E2=80=99 at ../lib/ip_fra= g/rte_ipv4_fragmentation.c:68:4, inlined from =E2=80=98rte_ipv4_fragment_packet=E2=80=99 at ../lib/ip_fr= ag/rte_ipv4_fragmentation.c:242:16: /usr/lib/gcc/x86_64-linux-gnu/12/include/avxintrin.h:935:8: warning: array = subscript =E2=80=98__m256i_u[1]=E2=80=99 is partly outside array bounds of = =E2=80=98void[60]=E2=80=99 [-Warray-bounds] 935 | *__P =3D __A; | ~~~~~^~~~~ ../lib/ip_frag/rte_ipv4_fragmentation.c: In function =E2=80=98rte_ipv4_frag= ment_packet=E2=80=99: ../lib/ip_frag/rte_ipv4_fragmentation.c:122:17: note: at offset [180, 240] = into object =E2=80=98ipopt_frag_hdr=E2=80=99 of size 60 122 | uint8_t ipopt_frag_hdr[IPV4_HDR_MAX_LEN]; | ^~~~~~~~~~~~~~ ../lib/ip_frag/rte_ipv4_fragmentation.c:122:17: note: at offset [52, 60] in= to object =E2=80=98ipopt_frag_hdr=E2=80=99 of size 60 In function =E2=80=98_mm256_storeu_si256=E2=80=99, inlined from =E2=80=98rte_mov32=E2=80=99 at ../lib/eal/x86/include/rte_= memcpy.h:347:2, inlined from =E2=80=98rte_memcpy_generic=E2=80=99 at ../lib/eal/x86/inc= lude/rte_memcpy.h:457:4, inlined from =E2=80=98rte_memcpy=E2=80=99 at ../lib/eal/x86/include/rte= _memcpy.h:853:10, inlined from =E2=80=98__create_ipopt_frag_hdr=E2=80=99 at ../lib/ip_fra= g/rte_ipv4_fragmentation.c:68:4, inlined from =E2=80=98rte_ipv4_fragment_packet=E2=80=99 at ../lib/ip_fr= ag/rte_ipv4_fragmentation.c:242:16: /usr/lib/gcc/x86_64-linux-gnu/12/include/avxintrin.h:935:8: warning: array = subscript [2, 7] is outside array bounds of =E2=80=98void[60]=E2=80=99 [-Wa= rray-bounds] 935 | *__P =3D __A; | ~~~~~^~~~~ ../lib/ip_frag/rte_ipv4_fragmentation.c: In function =E2=80=98rte_ipv4_frag= ment_packet=E2=80=99: ../lib/ip_frag/rte_ipv4_fragmentation.c:122:17: note: at offset [148, 272] = into object =E2=80=98ipopt_frag_hdr=E2=80=99 of size 60 122 | uint8_t ipopt_frag_hdr[IPV4_HDR_MAX_LEN]; | ^~~~~~~~~~~~~~ ../lib/ip_frag/rte_ipv4_fragmentation.c:122:17: note: at offset [148, 272] = into object =E2=80=98ipopt_frag_hdr=E2=80=99 of size 60 ../lib/ip_frag/rte_ipv4_fragmentation.c:122:17: note: at offset [20, 60] in= to object =E2=80=98ipopt_frag_hdr=E2=80=99 of size 60 In function =E2=80=98_mm256_storeu_si256=E2=80=99, inlined from =E2=80=98rte_mov32=E2=80=99 at ../lib/eal/x86/include/rte_= memcpy.h:347:2, inlined from =E2=80=98rte_memcpy_generic=E2=80=99 at ../lib/eal/x86/inc= lude/rte_memcpy.h:458:4, inlined from =E2=80=98rte_memcpy=E2=80=99 at ../lib/eal/x86/include/rte= _memcpy.h:853:10, inlined from =E2=80=98__create_ipopt_frag_hdr=E2=80=99 at ../lib/ip_fra= g/rte_ipv4_fragmentation.c:68:4, inlined from =E2=80=98rte_ipv4_fragment_packet=E2=80=99 at ../lib/ip_fr= ag/rte_ipv4_fragmentation.c:242:16: /usr/lib/gcc/x86_64-linux-gnu/12/include/avxintrin.h:935:8: warning: array = subscript [2, 8] is outside array bounds of =E2=80=98void[60]=E2=80=99 [-Wa= rray-bounds] 935 | *__P =3D __A; | ~~~~~^~~~~ ../lib/ip_frag/rte_ipv4_fragmentation.c: In function =E2=80=98rte_ipv4_frag= ment_packet=E2=80=99: ../lib/ip_frag/rte_ipv4_fragmentation.c:122:17: note: at offset [149, 273] = into object =E2=80=98ipopt_frag_hdr=E2=80=99 of size 60 122 | uint8_t ipopt_frag_hdr[IPV4_HDR_MAX_LEN]; | ^~~~~~~~~~~~~~ ../lib/ip_frag/rte_ipv4_fragmentation.c:122:17: note: at offset [149, 273] = into object =E2=80=98ipopt_frag_hdr=E2=80=99 of size 60 ../lib/ip_frag/rte_ipv4_fragmentation.c:122:17: note: at offset [21, 60] in= to object =E2=80=98ipopt_frag_hdr=E2=80=99 of size 60 In function =E2=80=98_mm256_storeu_si256=E2=80=99, inlined from =E2=80=98rte_mov32=E2=80=99 at ../lib/eal/x86/include/rte_= memcpy.h:347:2, inlined from =E2=80=98rte_memcpy_generic=E2=80=99 at ../lib/eal/x86/inc= lude/rte_memcpy.h:438:3, inlined from =E2=80=98rte_memcpy=E2=80=99 at ../lib/eal/x86/include/rte= _memcpy.h:853:10, inlined from =E2=80=98__create_ipopt_frag_hdr=E2=80=99 at ../lib/ip_fra= g/rte_ipv4_fragmentation.c:68:4, inlined from =E2=80=98rte_ipv4_fragment_packet=E2=80=99 at ../lib/ip_fr= ag/rte_ipv4_fragmentation.c:242:16: /usr/lib/gcc/x86_64-linux-gnu/12/include/avxintrin.h:935:8: warning: array = subscript =E2=80=98__m256i_u[1]=E2=80=99 is partly outside array bounds of = =E2=80=98uint8_t[60]=E2=80=99 {aka =E2=80=98unsigned char[60]=E2=80=99} [-W= array-bounds] 935 | *__P =3D __A; | ~~~~~^~~~~ ../lib/ip_frag/rte_ipv4_fragmentation.c: In function =E2=80=98rte_ipv4_frag= ment_packet=E2=80=99: ../lib/ip_frag/rte_ipv4_fragmentation.c:122:17: note: at offset [37, 60] in= to object =E2=80=98ipopt_frag_hdr=E2=80=99 of size 60 122 | uint8_t ipopt_frag_hdr[IPV4_HDR_MAX_LEN];