RTE flow API defines two flow items and actions types - common
and PMD private. Common RTE flow types are defined in rte_flow.h
while PMD private types restricted to specific PMD only.
RTE flow API allows PMD private types in flow rule,
but it must not try to interpret private item or acton properties.

Current implementation tried to locate PMD private element, item or
action, in common flow elements records.

The patch restricts access to common flow elements records for
non-private PMD types only.

Fixes: 6cf72047332b ("ethdev: support flow elements with variable length")

Signed-off-by: Gregory Etelson <getel...@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viachesl...@nvidia.com>
---
 lib/ethdev/rte_flow.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c
index d268784532..a93f68abbc 100644
--- a/lib/ethdev/rte_flow.c
+++ b/lib/ethdev/rte_flow.c
@@ -54,11 +54,13 @@ rte_flow_conv_copy(void *buf, const void *data, const 
size_t size,
        /**
         * Allow PMD private flow item
         */
-       size_t sz = type >= 0 ? desc[type].size : sizeof(void *);
+       bool rte_type = type >= 0;
+
+       size_t sz = rte_type ? desc[type].size : sizeof(void *);
        if (buf == NULL || data == NULL)
                return 0;
        rte_memcpy(buf, data, (size > sz ? sz : size));
-       if (desc[type].desc_fn)
+       if (rte_type && desc[type].desc_fn)
                sz += desc[type].desc_fn(size > 0 ? buf : NULL, data);
        return sz;
 }
-- 
2.33.1

Reply via email to