patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH] net/af_packet: fix crash in secondary process
@ 2025-09-12  8:47 Kerem Aksu
  2025-09-12  9:32 ` Thomas Monjalon
  2025-09-12 11:35 ` [PATCH v2] " Kerem Aksu
  0 siblings, 2 replies; 5+ messages in thread
From: Kerem Aksu @ 2025-09-12  8:47 UTC (permalink / raw)
  To: linville; +Cc: dev, thomas, ciwillia, stephen, Kerem Aksu, stable

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: stable@dpdk.org

Reported-by: Kerem Aksu <kerem.aksu@i2i-systems.com>
Signed-off-by: Kerem Aksu <kerem.aksu@i2i-systems.com>
---
 .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 <tchaikov@gmail.com>
 Keiichi Watanabe <keiichiw@chromium.org>
 Keith Wiles <keith.wiles@intel.com> <keith.wiles@windriver.com>
 Kent Wires <kent.wires@intel.com>
+Kerem Aksu <kerem.aksu@i2i-systems.com>
 Keunhong Lee <dlrmsghd@gmail.com>
 Kevin Laatz <kevin.laatz@intel.com>
 Kevin Lampis <klampis@solarflare.com>
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/>*

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-09-12 15:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-12  8:47 [PATCH] net/af_packet: fix crash in secondary process Kerem Aksu
2025-09-12  9:32 ` Thomas Monjalon
2025-09-12 11:14   ` Kerem Aksu
2025-09-12 11:35 ` [PATCH v2] " Kerem Aksu
2025-09-12 15:29   ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).