<div dir="ltr">Please check v3 of this patch.</div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Wed, Jul 23, 2025 at 5:19 PM Khadem Ullah <<a href="mailto:14pwcse1224@uetpeshawar.edu.pk">14pwcse1224@uetpeshawar.edu.pk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><pre>Secondary application not only breaking on device closing,<br>it's also getting segfault when we do "show device info all" from secondary<br>after primary closes:<br><br>testpmd> show device info all<br><br>********************* Infos for device 0000:03:00.0 *********************<br>Bus name: pci<br>Bus information: vendor_id=15b3, device_id=101d<br>Driver name: mlx5_pci<br>Devargs:<br>Connect to socket: 0<br><br>Segmentation fault (core dumped)<br><br>This patch prevents these crashes and it seems that these fixes should be in PMD along with the ethdev layer. Some more checks will be added in the next version to prevent "show device info all" crash.</pre><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jul 23, 2025 at 9:50 AM Khadem Ullah <<a href="mailto:14pwcse1224@uetpeshawar.edu.pk" target="_blank">14pwcse1224@uetpeshawar.edu.pk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">In secondary processes, directly accessing 'dev->data->dev_private' can<br>
cause a segmentation fault if the primary process has exited or if the<br>
shared memory is no longer accessible.<br>
<br>
This patch adds a safety check using rte_mem_virt2phy(), with an<br>
unlikely() branch hint to minimize performance impact in the fast path.<br>
This ensures 'dev_private' is still valid before accessing it.<br>
<br>
Fixes: bdad90d12ec8 ("ethdev: change device info get callback to return int")<br>
Cc: <a href="mailto:stable@dpdk.org" target="_blank">stable@dpdk.org</a><br>
<br>
Signed-off-by: Khadem Ullah <<a href="mailto:14pwcse1224@uetpeshawar.edu.pk" target="_blank">14pwcse1224@uetpeshawar.edu.pk</a>><br>
---<br>
 lib/ethdev/rte_ethdev.c | 7 +++++++<br>
 1 file changed, 7 insertions(+)<br>
<br>
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c<br>
index dd7c00bc94..ef5dc55f2e 100644<br>
--- a/lib/ethdev/rte_ethdev.c<br>
+++ b/lib/ethdev/rte_ethdev.c<br>
@@ -4079,6 +4079,13 @@ rte_eth_dev_info_get(uint16_t port_id, struct rte_eth_dev_info *dev_info)<br>
<br>
        if (dev->dev_ops->dev_infos_get == NULL)<br>
                return -ENOTSUP;<br>
+       if (rte_eal_process_type() == RTE_PROC_SECONDARY &&<br>
+               unlikely(rte_mem_virt2phy(dev->data->dev_private) == RTE_BAD_PHYS_ADDR)) {<br>
+                       RTE_ETHDEV_LOG_LINE(ERR,<br>
+                       "Secondary: dev_private not accessible (primary exited?)");<br>
+                       rte_errno = ENODEV;<br>
+                       return -rte_errno;<br>
+       }<br>
        diag = dev->dev_ops->dev_infos_get(dev, dev_info);<br>
        if (diag != 0) {<br>
                /* Cleanup already filled in device information */<br>
-- <br>
2.43.0<br>
<br>
</blockquote></div><div><br clear="all"></div><br><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)"><span style="color:rgb(12,100,192)">Engr. Khadem Ullah, </span><br></div><div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)"><span style="color:rgb(12,100,192)">Software Engineer, </span><br></div><span style="color:rgb(12,100,192)">Dreambig Semiconductor Inc <br></span></div><div dir="ltr"><span style="color:rgb(12,100,192)"><a href="https://dreambigsemi.com/" target="_blank">https://dreambigsemi.com/</a><br></span></div></div></div></div>
</blockquote></div><div><br clear="all"></div><br><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)"><span style="color:rgb(12,100,192)">Engr. Khadem Ullah, </span><br></div><div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)"><span style="color:rgb(12,100,192)">Software Engineer, </span><br></div><span style="color:rgb(12,100,192)">Dreambig Semiconductor Inc <br></span></div><div dir="ltr"><span style="color:rgb(12,100,192)"><a href="https://dreambigsemi.com/" target="_blank">https://dreambigsemi.com/</a><br></span></div></div></div></div>