On Wed, 8 Jun 2022 09:19:20 +0100 Konstantin Ananyev <konstantin.v.anan...@yandex.ru> wrote:
> 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. 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 ‘_mm256_storeu_si256’, inlined from ‘rte_mov32’ at ../lib/eal/x86/include/rte_memcpy.h:347:2, inlined from ‘rte_mov128’ at ../lib/eal/x86/include/rte_memcpy.h:369:2, inlined from ‘rte_memcpy_generic’ at ../lib/eal/x86/include/rte_memcpy.h:445:4, inlined from ‘rte_memcpy’ at ../lib/eal/x86/include/rte_memcpy.h:853:10, inlined from ‘__create_ipopt_frag_hdr’ at ../lib/ip_frag/rte_ipv4_fragmentation.c:68:4, inlined from ‘rte_ipv4_fragment_packet’ at ../lib/ip_frag/rte_ipv4_fragmentation.c:242:16: /usr/lib/gcc/x86_64-linux-gnu/12/include/avxintrin.h:935:8: warning: array subscript ‘__m256i_u[1]’ is partly outside array bounds of ‘uint8_t[60]’ {aka ‘unsigned char[60]’} [-Warray-bounds] 935 | *__P = __A; | ~~~~~^~~~~ ../lib/ip_frag/rte_ipv4_fragmentation.c: In function ‘rte_ipv4_fragment_packet’: ../lib/ip_frag/rte_ipv4_fragmentation.c:122:17: note: at offset [52, 60] into object ‘ipopt_frag_hdr’ of size 60 122 | uint8_t ipopt_frag_hdr[IPV4_HDR_MAX_LEN]; | ^~~~~~~~~~~~~~ In function ‘_mm256_storeu_si256’, inlined from ‘rte_mov32’ at ../lib/eal/x86/include/rte_memcpy.h:347:2, inlined from ‘rte_mov128’ at ../lib/eal/x86/include/rte_memcpy.h:370:2, inlined from ‘rte_memcpy_generic’ at ../lib/eal/x86/include/rte_memcpy.h:445:4, inlined from ‘rte_memcpy’ at ../lib/eal/x86/include/rte_memcpy.h:853:10, inlined from ‘__create_ipopt_frag_hdr’ at ../lib/ip_frag/rte_ipv4_fragmentation.c:68:4, inlined from ‘rte_ipv4_fragment_packet’ at ../lib/ip_frag/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 ‘uint8_t[60]’ {aka ‘unsigned char[60]’} [-Warray-bounds] 935 | *__P = __A; | ~~~~~^~~~~ ../lib/ip_frag/rte_ipv4_fragmentation.c: In function ‘rte_ipv4_fragment_packet’: ../lib/ip_frag/rte_ipv4_fragmentation.c:122:17: note: at offset [84, 124] into object ‘ipopt_frag_hdr’ of size 60 122 | uint8_t ipopt_frag_hdr[IPV4_HDR_MAX_LEN]; | ^~~~~~~~~~~~~~ In function ‘_mm256_storeu_si256’, inlined from ‘rte_mov32’ at ../lib/eal/x86/include/rte_memcpy.h:347:2, inlined from ‘rte_mov128’ at ../lib/eal/x86/include/rte_memcpy.h:371:2, inlined from ‘rte_memcpy_generic’ at ../lib/eal/x86/include/rte_memcpy.h:445:4, inlined from ‘rte_memcpy’ at ../lib/eal/x86/include/rte_memcpy.h:853:10, inlined from ‘__create_ipopt_frag_hdr’ at ../lib/ip_frag/rte_ipv4_fragmentation.c:68:4, inlined from ‘rte_ipv4_fragment_packet’ at ../lib/ip_frag/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 ‘uint8_t[60]’ {aka ‘unsigned char[60]’} [-Warray-bounds] 935 | *__P = __A; | ~~~~~^~~~~ ../lib/ip_frag/rte_ipv4_fragmentation.c: In function ‘rte_ipv4_fragment_packet’: ../lib/ip_frag/rte_ipv4_fragmentation.c:122:17: note: at offset [116, 156] into object ‘ipopt_frag_hdr’ of size 60 122 | uint8_t ipopt_frag_hdr[IPV4_HDR_MAX_LEN]; | ^~~~~~~~~~~~~~ In function ‘_mm256_storeu_si256’, inlined from ‘rte_mov32’ at ../lib/eal/x86/include/rte_memcpy.h:347:2, inlined from ‘rte_mov64’ at ../lib/eal/x86/include/rte_memcpy.h:358:2, inlined from ‘rte_memcpy_generic’ at ../lib/eal/x86/include/rte_memcpy.h:452:4, inlined from ‘rte_memcpy’ at ../lib/eal/x86/include/rte_memcpy.h:853:10, inlined from ‘__create_ipopt_frag_hdr’ at ../lib/ip_frag/rte_ipv4_fragmentation.c:68:4, inlined from ‘rte_ipv4_fragment_packet’ at ../lib/ip_frag/rte_ipv4_fragmentation.c:242:16: /usr/lib/gcc/x86_64-linux-gnu/12/include/avxintrin.h:935:8: warning: array subscript ‘__m256i_u[1]’ is partly outside array bounds of ‘void[60]’ [-Warray-bounds] 935 | *__P = __A; | ~~~~~^~~~~ ../lib/ip_frag/rte_ipv4_fragmentation.c: In function ‘rte_ipv4_fragment_packet’: ../lib/ip_frag/rte_ipv4_fragmentation.c:122:17: note: at offset [180, 240] into object ‘ipopt_frag_hdr’ 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] into object ‘ipopt_frag_hdr’ of size 60 In function ‘_mm256_storeu_si256’, inlined from ‘rte_mov32’ at ../lib/eal/x86/include/rte_memcpy.h:347:2, inlined from ‘rte_memcpy_generic’ at ../lib/eal/x86/include/rte_memcpy.h:457:4, inlined from ‘rte_memcpy’ at ../lib/eal/x86/include/rte_memcpy.h:853:10, inlined from ‘__create_ipopt_frag_hdr’ at ../lib/ip_frag/rte_ipv4_fragmentation.c:68:4, inlined from ‘rte_ipv4_fragment_packet’ at ../lib/ip_frag/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 ‘void[60]’ [-Warray-bounds] 935 | *__P = __A; | ~~~~~^~~~~ ../lib/ip_frag/rte_ipv4_fragmentation.c: In function ‘rte_ipv4_fragment_packet’: ../lib/ip_frag/rte_ipv4_fragmentation.c:122:17: note: at offset [148, 272] into object ‘ipopt_frag_hdr’ 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 ‘ipopt_frag_hdr’ of size 60 ../lib/ip_frag/rte_ipv4_fragmentation.c:122:17: note: at offset [20, 60] into object ‘ipopt_frag_hdr’ of size 60 In function ‘_mm256_storeu_si256’, inlined from ‘rte_mov32’ at ../lib/eal/x86/include/rte_memcpy.h:347:2, inlined from ‘rte_memcpy_generic’ at ../lib/eal/x86/include/rte_memcpy.h:458:4, inlined from ‘rte_memcpy’ at ../lib/eal/x86/include/rte_memcpy.h:853:10, inlined from ‘__create_ipopt_frag_hdr’ at ../lib/ip_frag/rte_ipv4_fragmentation.c:68:4, inlined from ‘rte_ipv4_fragment_packet’ at ../lib/ip_frag/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 ‘void[60]’ [-Warray-bounds] 935 | *__P = __A; | ~~~~~^~~~~ ../lib/ip_frag/rte_ipv4_fragmentation.c: In function ‘rte_ipv4_fragment_packet’: ../lib/ip_frag/rte_ipv4_fragmentation.c:122:17: note: at offset [149, 273] into object ‘ipopt_frag_hdr’ 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 ‘ipopt_frag_hdr’ of size 60 ../lib/ip_frag/rte_ipv4_fragmentation.c:122:17: note: at offset [21, 60] into object ‘ipopt_frag_hdr’ of size 60 In function ‘_mm256_storeu_si256’, inlined from ‘rte_mov32’ at ../lib/eal/x86/include/rte_memcpy.h:347:2, inlined from ‘rte_memcpy_generic’ at ../lib/eal/x86/include/rte_memcpy.h:438:3, inlined from ‘rte_memcpy’ at ../lib/eal/x86/include/rte_memcpy.h:853:10, inlined from ‘__create_ipopt_frag_hdr’ at ../lib/ip_frag/rte_ipv4_fragmentation.c:68:4, inlined from ‘rte_ipv4_fragment_packet’ at ../lib/ip_frag/rte_ipv4_fragmentation.c:242:16: /usr/lib/gcc/x86_64-linux-gnu/12/include/avxintrin.h:935:8: warning: array subscript ‘__m256i_u[1]’ is partly outside array bounds of ‘uint8_t[60]’ {aka ‘unsigned char[60]’} [-Warray-bounds] 935 | *__P = __A; | ~~~~~^~~~~ ../lib/ip_frag/rte_ipv4_fragmentation.c: In function ‘rte_ipv4_fragment_packet’: ../lib/ip_frag/rte_ipv4_fragmentation.c:122:17: note: at offset [37, 60] into object ‘ipopt_frag_hdr’ of size 60 122 | uint8_t ipopt_frag_hdr[IPV4_HDR_MAX_LEN];