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 81289A0544; Wed, 8 Jun 2022 10:19:25 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 360354021F; Wed, 8 Jun 2022 10:19:25 +0200 (CEST) Received: from forward501o.mail.yandex.net (forward501o.mail.yandex.net [37.140.190.203]) by mails.dpdk.org (Postfix) with ESMTP id A7F254021D for ; Wed, 8 Jun 2022 10:19:23 +0200 (CEST) Received: from vla5-d936488e9cef.qloud-c.yandex.net (vla5-d936488e9cef.qloud-c.yandex.net [IPv6:2a02:6b8:c18:351f:0:640:d936:488e]) by forward501o.mail.yandex.net (Yandex) with ESMTP id 06B6C45C52EE; Wed, 8 Jun 2022 11:19:23 +0300 (MSK) Received: from vla1-62318bfe5573.qloud-c.yandex.net (vla1-62318bfe5573.qloud-c.yandex.net [2a02:6b8:c0d:3819:0:640:6231:8bfe]) by vla5-d936488e9cef.qloud-c.yandex.net (mxback/Yandex) with ESMTP id aNTcebwLje-JMg0L7aP; Wed, 08 Jun 2022 11:19:23 +0300 X-Yandex-Fwd: 2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1654676363; bh=NJL8JrxG29BpZeLqNqfcuoUVnYkrUf3vYDAckZFEAOE=; h=In-Reply-To:From:Subject:References:Date:Message-ID:To; b=fF467Z/V76Ud7H4+qFY7t2O2N/gnVLALPe3x01wncsz0mop4RCklIbIa5bc7X8XEw u5g0UjP0oLXIVKK7az/c41olt0iFudp0avXLFuUAKZ4zE4VT96F48nnw00t71Hgstw 8Je8stui7zohw3ufpw6daqz9TO7LutANOG43S2tw= Authentication-Results: vla5-d936488e9cef.qloud-c.yandex.net; dkim=pass header.i=@yandex.ru Received: by vla1-62318bfe5573.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id zibSClW5EO-JMMGXTOG; Wed, 08 Jun 2022 11:19:22 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) Message-ID: <5549a996-a058-a9e4-f3f3-f31bfb198d6a@yandex.ru> Date: Wed, 8 Jun 2022 09:19:20 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [RFC 8/8] ip_frag: fix gcc-12 warnings Content-Language: en-US To: Stephen Hemminger , dev@dpdk.org References: <20220607171746.461772-1-stephen@networkplumber.org> <20220607171746.461772-9-stephen@networkplumber.org> From: Konstantin Ananyev In-Reply-To: <20220607171746.461772-9-stephen@networkplumber.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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 07/06/2022 18:17, Stephen Hemminger пишет: > 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. 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. > > Signed-off-by: Stephen Hemminger > --- > lib/ip_frag/rte_ipv4_fragmentation.c | 7 +++---- > 1 file changed, 3 insertions(+), 4 deletions(-) > > diff --git a/lib/ip_frag/rte_ipv4_fragmentation.c b/lib/ip_frag/rte_ipv4_fragmentation.c > index a19f6fda6408..27a8ad224dec 100644 > --- a/lib/ip_frag/rte_ipv4_fragmentation.c > +++ b/lib/ip_frag/rte_ipv4_fragmentation.c > @@ -5,7 +5,6 @@ > #include > #include > > -#include > #include > > #include "ip_frag_common.h" > @@ -26,7 +25,7 @@ static inline void __fill_ipv4hdr_frag(struct rte_ipv4_hdr *dst, > const struct rte_ipv4_hdr *src, uint16_t header_len, > uint16_t len, uint16_t fofs, uint16_t dofs, uint32_t mf) > { > - rte_memcpy(dst, src, header_len); > + memcpy(dst, src, header_len); > fofs = (uint16_t)(fofs + (dofs >> RTE_IPV4_HDR_FO_SHIFT)); > fofs = (uint16_t)(fofs | mf << RTE_IPV4_HDR_MF_SHIFT); > dst->fragment_offset = rte_cpu_to_be_16(fofs); > @@ -48,7 +47,7 @@ static inline uint16_t __create_ipopt_frag_hdr(uint8_t *iph, > struct rte_ipv4_hdr *iph_opt = (struct rte_ipv4_hdr *)ipopt_frag_hdr; > > ipopt_len = 0; > - rte_memcpy(ipopt_frag_hdr, iph, sizeof(struct rte_ipv4_hdr)); > + memcpy(ipopt_frag_hdr, iph, sizeof(struct rte_ipv4_hdr)); > ipopt_frag_hdr += sizeof(struct rte_ipv4_hdr); > > uint8_t *p_opt = iph + sizeof(struct rte_ipv4_hdr); > @@ -65,7 +64,7 @@ static inline uint16_t __create_ipopt_frag_hdr(uint8_t *iph, > break; > > if (RTE_IPV4_HDR_OPT_COPIED(*p_opt)) { > - rte_memcpy(ipopt_frag_hdr + ipopt_len, > + memcpy(ipopt_frag_hdr + ipopt_len, > p_opt, p_opt[1]); > ipopt_len += p_opt[1]; > }