net/mlx5: prevent querying aged flows on uninit port

Message ID 20240221032322.297332-1-bingz@nvidia.com (mailing list archive)
State Accepted, archived
Delegated to: Raslan Darawsheh
Headers
Series net/mlx5: prevent querying aged flows on uninit port |

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

Commit Message

Bing Zhao Feb. 21, 2024, 3:23 a.m. UTC
  In HWS template API, the aging mechanism doesn't support shared host
mode now. When the guest's counter is set to 0, the aging won't be
initialized.

The current implementation didn't prevent the user from querying the
aged flows on the uninitialized port. The access of invalid pointers
would cause a crash.

With this commit, the flag of the per port aging initialization will
be checked. This would help to get rid of the invalid accessing.

Fixes: 04a4de756e14 ("net/mlx5: support flow age action with HWS")
Cc: michaelba@nvidia.com
Cc: stable@dpdk.org

Signed-off-by: Bing Zhao <bingz@nvidia.com>
Acked-by: Suanming Mou <suanmingm@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_hw.c | 4 ++++
 1 file changed, 4 insertions(+)
  

Comments

Raslan Darawsheh Feb. 27, 2024, 4:17 p.m. UTC | #1
Hi,

> -----Original Message-----
> From: Bing Zhao <bingz@nvidia.com>
> Sent: Wednesday, February 21, 2024 5:23 AM
> To: Suanming Mou <suanmingm@nvidia.com>; Raslan Darawsheh
> <rasland@nvidia.com>; dev@dpdk.org
> Cc: Matan Azrad <matan@nvidia.com>; Slava Ovsiienko
> <viacheslavo@nvidia.com>; Ori Kam <orika@nvidia.com>; Dariusz Sosnowski
> <dsosnowski@nvidia.com>; stable@dpdk.org; Michael Baum
> <michaelba@nvidia.com>
> Subject: [PATCH] net/mlx5: prevent querying aged flows on uninit port
> 
> In HWS template API, the aging mechanism doesn't support shared host mode
> now. When the guest's counter is set to 0, the aging won't be initialized.
> 
> The current implementation didn't prevent the user from querying the aged
> flows on the uninitialized port. The access of invalid pointers would cause a
> crash.
> 
> With this commit, the flag of the per port aging initialization will be checked.
> This would help to get rid of the invalid accessing.
> 
> Fixes: 04a4de756e14 ("net/mlx5: support flow age action with HWS")
> Cc: michaelba@nvidia.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Bing Zhao <bingz@nvidia.com>
> Acked-by: Suanming Mou <suanmingm@nvidia.com>
> ---[Raslan Darawsheh] 

Patch applied to next-net-mlx

Kindest regards,
Raslan Darawsheh
  

Patch

diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index 3bb3a9a178..0e6d6e02dd 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -10937,6 +10937,10 @@  flow_hw_get_q_aged_flows(struct rte_eth_dev *dev, uint32_t queue_id,
 		return rte_flow_error_set(error, EINVAL,
 					  RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
 					  NULL, "empty context");
+	if (!priv->hws_age_req)
+		return rte_flow_error_set(error, ENOENT,
+					  RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+					  NULL, "No aging initialized");
 	if (priv->hws_strict_queue) {
 		if (queue_id >= age_info->hw_q_age->nb_rings)
 			return rte_flow_error_set(error, EINVAL,