[v1] net/mlx5: fix secondary process query stats segfault

Message ID 20240122074405.1391570-1-rongweil@nvidia.com (mailing list archive)
State Accepted, archived
Delegated to: Raslan Darawsheh
Headers
Series [v1] net/mlx5: fix secondary process query stats segfault |

Checks

Context Check Description
ci/checkpatch warning coding style issues
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/iol-broadcom-Performance success Performance Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/github-robot: build success github build: passed

Commit Message

Rongwei Liu Jan. 22, 2024, 7:44 a.m. UTC
  The "outer_of_buffer" counter is owned by the primary process devx
object and it is pointer by pointer in mlx5_priv structure. Actually,
there are 4 levels' pointers in this piece of code.

The secondary process can't access this part directly since it belongs
to another process' heap.

Return ENOTSUP as workaround.

Signed-off-by: Rongwei Liu <rongweil@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
Fixes: 750e48c7d ("common/mlx5: add DevX commands for queue counters")
Cc: matan@nvidia.com
Cc: stable@dpdk.org
---
 drivers/net/mlx5/linux/mlx5_os.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
  

Comments

Raslan Darawsheh Jan. 29, 2024, 1:21 p.m. UTC | #1
Hi,
> -----Original Message-----
> From: Rongwei Liu <rongweil@nvidia.com>
> Sent: Monday, January 22, 2024 9:44 AM
> To: dev@dpdk.org; Matan Azrad <matan@nvidia.com>; Slava Ovsiienko
> <viacheslavo@nvidia.com>; Ori Kam <orika@nvidia.com>; Suanming Mou
> <suanmingm@nvidia.com>; NBU-Contact-Thomas Monjalon (EXTERNAL)
> <thomas@monjalon.net>
> Cc: stable@dpdk.org; Anatoly Burakov <anatoly.burakov@intel.com>
> Subject: [PATCH v1] net/mlx5: fix secondary process query stats segfault
> 
> The "outer_of_buffer" counter is owned by the primary process devx object
> and it is pointer by pointer in mlx5_priv structure. Actually, there are 4 levels'
> pointers in this piece of code.
> 
> The secondary process can't access this part directly since it belongs to another
> process' heap.
[Fixed] typo = process' => process's 
> 
> Return ENOTSUP as workaround.
> 
> Signed-off-by: Rongwei Liu <rongweil@nvidia.com>
> Acked-by: Matan Azrad <matan@nvidia.com>
> Fixes: 750e48c7d ("common/mlx5: add DevX commands for queue counters")
> Cc: matan@nvidia.com
> Cc: stable@dpdk.org[
[Fixed] fixes tag and CC should be before signed-off by tag.

Patch applied to next-net-mlx,

Kindest regards
Raslan Darawsheh
  

Patch

diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 8682899735..dc854ebb64 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -3192,9 +3192,15 @@  mlx5_os_read_dev_stat(struct mlx5_priv *priv, const char *ctr_name,
 
 	if (priv->sh) {
 		if (priv->q_counters != NULL &&
-		    strcmp(ctr_name, "out_of_buffer") == 0)
+		    strcmp(ctr_name, "out_of_buffer") == 0) {
+			if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
+				DRV_LOG(WARNING, "Devx out_of_buffer counter is not supported in the secondary process");
+				rte_errno = ENOTSUP;
+				return 1;
+			}
 			return mlx5_devx_cmd_queue_counter_query
 					(priv->q_counters, 0, (uint32_t *)stat);
+		}
 		MKSTR(path, "%s/ports/%d/hw_counters/%s",
 		      priv->sh->ibdev_path,
 		      priv->dev_port,