dumpcap crashes when trying to capture from af_packet devices. This is
caused by allocating interface name with
strdup (i.e. malloc). Interface name is not accessible from secondary
process and causes segmentation fault. Use rte_malloc instead of
strdup to fix the issue.

Bugzilla ID: 1786
Fixes: 1b93c2aa81b4 ("net/af_packet: add interface name to internals")
Cc: [email protected]

Reported-by: Kerem Aksu <[email protected]>
Signed-off-by: Kerem Aksu <[email protected]>
---
 .mailmap                                  | 1 +
 drivers/net/af_packet/rte_eth_af_packet.c | 9 ++++++---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/.mailmap b/.mailmap
index 73d573e400..fadf873d4f 100644
--- a/.mailmap
+++ b/.mailmap
@@ -824,6 +824,7 @@ Kefu Chai <[email protected]>
 Keiichi Watanabe <[email protected]>
 Keith Wiles <[email protected]> <[email protected]>
 Kent Wires <[email protected]>
+Kerem Aksu <[email protected]>
 Keunhong Lee <[email protected]>
 Kevin Laatz <[email protected]>
 Kevin Lampis <[email protected]>
diff --git a/drivers/net/af_packet/rte_eth_af_packet.c 
b/drivers/net/af_packet/rte_eth_af_packet.c
index 85bc1201b4..6928fc200f 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -525,7 +525,7 @@ eth_dev_close(struct rte_eth_dev *dev)
                rte_free(internals->rx_queue[q].rd);
                rte_free(internals->tx_queue[q].rd);
        }
-       free(internals->if_name);
+       rte_free(internals->if_name);
        rte_free(internals->rx_queue);
        rte_free(internals->tx_queue);
 
@@ -875,9 +875,12 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
                PMD_LOG_ERRNO(ERR, "%s: ioctl failed (SIOCGIFINDEX)", name);
                goto free_internals;
        }
-       (*internals)->if_name = strdup(pair->value);
+       (*internals)->if_name = rte_zmalloc_socket(name, ifnamelen + 1,
+                                                                       0, 
numa_node);
        if ((*internals)->if_name == NULL)
                goto free_internals;
+       memcpy((*internals)->if_name, pair->value, ifnamelen);
+       (*internals)->if_name[ifnamelen] = '\0';
        (*internals)->if_index = ifr.ifr_ifindex;
 
        if (ioctl(sockfd, SIOCGIFHWADDR, &ifr) == -1) {
@@ -1063,7 +1066,7 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
 free_internals:
        rte_free((*internals)->rx_queue);
        rte_free((*internals)->tx_queue);
-       free((*internals)->if_name);
+       rte_free((*internals)->if_name);
        rte_free(*internals);
        return -1;
 }
-- 
2.34.1


-- 
Yasal Uyarı: *Bu elektronik posta bu linki kullanarak ulaşabileceğiniz 
koşullara tabidir:** **https://i2i-systems.com/email-disclaimer/ 
<http://i2i-systems.com/about-us/email-disclaimer/>*

Reply via email to