Skip to content

Commit

Permalink
ethdev: fix 32-bit build with GCC 13
Browse files Browse the repository at this point in the history
[ upstream commit 3d67012ab70252190fcfea12c122567a4d010228 ]

aarch32 build with gcc-13.0.1 generated following warning:

In function 'memcpy',
 inlined from 'rte_memcpy' at .../eal/arm/include/rte_memcpy_32.h:296:9,
 inlined from 'rte_flow_conv_action_conf' at .../rte_flow.c:726:20,
 inlined from 'rte_flow_conv_actions' at .../ethdev/rte_flow.c:936:10:
warning: '__builtin_memcpy' specified bound 4294967264 exceeds maximum
         object size 2147483647 [-Wstringop-overflow=]

The issue is due to possible wrapping in unsigned arithmetic.
The 'size' can be 0. 'off' is 32. When 'tmp' is equal to (unsigned)-32,
the copy length is more than half the address space. Hence the warning.

Cast variables to 64-bit to avoid wrapping.

Fixes: 063911e ("ethdev: add flow API object converter")

Reported-by: Luca Boccassi <bluca@debian.org>
Signed-off-by: Ruifeng Wang <ruifeng.wang@arm.com>
Acked-by: Ori Kam <orika@nvidia.com>
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
  • Loading branch information
Ruifeng Wang authored and bluca committed Nov 8, 2023
1 parent 4cac7f3 commit 6cdc038
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/librte_ethdev/rte_flow.c
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ rte_flow_conv_action_conf(void *buf, const size_t size,
if (src.rss->key_len && src.rss->key) {
off = RTE_ALIGN_CEIL(off, sizeof(*dst.rss->key));
tmp = sizeof(*src.rss->key) * src.rss->key_len;
if (size >= off + tmp)
if (size >= (uint64_t)off + (uint64_t)tmp)
dst.rss->key = rte_memcpy
((void *)((uintptr_t)dst.rss + off),
src.rss->key, tmp);
Expand All @@ -589,7 +589,7 @@ rte_flow_conv_action_conf(void *buf, const size_t size,
if (src.rss->queue_num) {
off = RTE_ALIGN_CEIL(off, sizeof(*dst.rss->queue));
tmp = sizeof(*src.rss->queue) * src.rss->queue_num;
if (size >= off + tmp)
if (size >= (uint64_t)off + (uint64_t)tmp)
dst.rss->queue = rte_memcpy
((void *)((uintptr_t)dst.rss + off),
src.rss->queue, tmp);
Expand Down

0 comments on commit 6cdc038

Please sign in to comment.