[v2] net/vdev: fix insert vdev core dump

Message ID 20240716095328.1820597-1-mingjinx.ye@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series [v2] net/vdev: fix insert vdev core dump |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS

Commit Message

Mingjin Ye July 16, 2024, 9:53 a.m. UTC
In secondary processes, insert_vdev() may be called multiple times on the
same device due to multi-process hot-plugging of the vdev bus and EAL
parameters to add the same vdev.

In this case, when rte_devargs_insert() is called, the devargs->name
reference will be invalidated because rte_devargs_insert() destroys the
just-allocated devargs and replaces the pointer from the devargs list.
As a result, the reference to devargs->name stored in dev->device.name
will be invalid.

This patch fixes the issue by setting the device name after calling
rte_devargs_insert().

Fixes: cdb068f031c6 ("bus/vdev: scan by multi-process channel")
Cc: stable@dpdk.org

Signed-off-by: Mingjin Ye <mingjinx.ye@intel.com>
---
v2: Modify commit log.
---
 drivers/bus/vdev/vdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Burakov, Anatoly July 22, 2024, 12:39 p.m. UTC | #1
On 7/16/2024 11:53 AM, Mingjin Ye wrote:
> In secondary processes, insert_vdev() may be called multiple times on the
> same device due to multi-process hot-plugging of the vdev bus and EAL
> parameters to add the same vdev.
> 
> In this case, when rte_devargs_insert() is called, the devargs->name
> reference will be invalidated because rte_devargs_insert() destroys the
> just-allocated devargs and replaces the pointer from the devargs list.
> As a result, the reference to devargs->name stored in dev->device.name
> will be invalid.
> 
> This patch fixes the issue by setting the device name after calling
> rte_devargs_insert().
> 
> Fixes: cdb068f031c6 ("bus/vdev: scan by multi-process channel")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Mingjin Ye <mingjinx.ye@intel.com>
> ---
> v2: Modify commit log.
> ---

Forgot to add my review tag:

Reviewed-by: Anatoly Burakov <anatoly.burakov@intel.com>
  
Thomas Monjalon July 23, 2024, 3:25 p.m. UTC | #2
22/07/2024 14:39, Burakov, Anatoly:
> On 7/16/2024 11:53 AM, Mingjin Ye wrote:
> > In secondary processes, insert_vdev() may be called multiple times on the
> > same device due to multi-process hot-plugging of the vdev bus and EAL
> > parameters to add the same vdev.
> > 
> > In this case, when rte_devargs_insert() is called, the devargs->name
> > reference will be invalidated because rte_devargs_insert() destroys the
> > just-allocated devargs and replaces the pointer from the devargs list.
> > As a result, the reference to devargs->name stored in dev->device.name
> > will be invalid.
> > 
> > This patch fixes the issue by setting the device name after calling
> > rte_devargs_insert().
> > 
> > Fixes: cdb068f031c6 ("bus/vdev: scan by multi-process channel")
> > Cc: stable@dpdk.org
> > 
> > Signed-off-by: Mingjin Ye <mingjinx.ye@intel.com>
> > ---
> > v2: Modify commit log.
> > ---
> 
> Forgot to add my review tag:
> 
> Reviewed-by: Anatoly Burakov <anatoly.burakov@intel.com>

Applied, thanks.
  

Patch

diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
index 38d05a9fe9..ec7abe7cda 100644
--- a/drivers/bus/vdev/vdev.c
+++ b/drivers/bus/vdev/vdev.c
@@ -288,7 +288,6 @@  insert_vdev(const char *name, const char *args,
 
 	dev->device.bus = &rte_vdev_bus;
 	dev->device.numa_node = SOCKET_ID_ANY;
-	dev->device.name = devargs->name;
 
 	if (find_vdev(name)) {
 		/*
@@ -303,6 +302,7 @@  insert_vdev(const char *name, const char *args,
 	if (init)
 		rte_devargs_insert(&devargs);
 	dev->device.devargs = devargs;
+	dev->device.name = devargs->name;
 	TAILQ_INSERT_TAIL(&vdev_device_list, dev, next);
 
 	if (p_dev)