The mvneta_ifnames_get() function will save 'iface' value to ifnames,
it will out-of-bounds write if passed many iface pairs (e.g.
'iface=xxx,iface=xxx,...').

Fixes: 4ccc8d770d3b ("net/mvneta: add PMD skeleton")
Cc: sta...@dpdk.org

Signed-off-by: Chengwen Feng <fengcheng...@huawei.com>
Acked-by: Ferruh Yigit <ferruh.yi...@amd.com>

---
v3: fix compile error, and change err log which address Stephen's
    comment.
v2: add error log which address Stephen's comment.

---
 drivers/net/mvneta/mvneta_ethdev.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/mvneta/mvneta_ethdev.c 
b/drivers/net/mvneta/mvneta_ethdev.c
index 3841c1ebe9..f99f9e6289 100644
--- a/drivers/net/mvneta/mvneta_ethdev.c
+++ b/drivers/net/mvneta/mvneta_ethdev.c
@@ -91,6 +91,12 @@ mvneta_ifnames_get(const char *key __rte_unused, const char 
*value,
 {
        struct mvneta_ifnames *ifnames = extra_args;
 
+       if (ifnames->idx >= NETA_NUM_ETH_PPIO) {
+               MVNETA_LOG(ERR, "Too many ifnames specified (max %u)",
+                          NETA_NUM_ETH_PPIO);
+               return -EINVAL;
+       }
+
        ifnames->names[ifnames->idx++] = value;
 
        return 0;
-- 
2.17.1

Reply via email to