patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH] net/mlx5: fix RSS validation for meter hierarchy
@ 2021-11-23 16:00 Bing Zhao
  2021-11-23 16:05 ` [PATCH v2] " Bing Zhao
  0 siblings, 1 reply; 3+ messages in thread
From: Bing Zhao @ 2021-11-23 16:00 UTC (permalink / raw)
  To: viacheslavo, matan; +Cc: dev, rasland, stable, Li Zhang, Shun Hao

In a meter hierarchy, all the meters are marked with having RSS if
the final meter's termination action is RSS.

When validating a flow rule with meter hierarchy, the RSS action
should not be fetched from the current meter if it is not the final
one.

The fate action union is next meter ID instead of the pointer to the
RSS action. By using the final meter in the hierarchy, the flow rule
validation will succeed without any crash caused by the invalide RSS
action pointer access.

Fixes: 1ce19ab1f43b ("net/mlx5: fix RSS validation with meter policy")
Cc: stable@dpdk.org

Signed-off-by: Bing Zhao <bingz@nvidia.com>
Reviewed-by: Li Zhang <lizh@nvidia.com>
Reviewed-by: Shun Hao <shunh@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_dv.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 2f03e59f9c..f5356418fa 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -5254,13 +5254,21 @@ mlx5_flow_validate_action_meter(struct rte_eth_dev *dev,
 						"Flow and meter policy "
 						"have different src port.");
 		} else if (mtr_policy->is_rss) {
-			struct mlx5_meter_policy_action_container *acg =
-				&mtr_policy->act_cnt[RTE_COLOR_GREEN];
-			struct mlx5_meter_policy_action_container *acy =
-				&mtr_policy->act_cnt[RTE_COLOR_YELLOW];
+			struct mlx5_flow_meter_policy *fp;
+			struct mlx5_meter_policy_action_container *acg;
+			struct mlx5_meter_policy_action_container *acy;
 			const struct rte_flow_action *rss_act;
 			int ret;
 
+			fp = mlx5_flow_meter_hierarchy_get_final_policy(dev,
+								mtr_policy);
+			if (fp == NULL)
+				return rte_flow_error_set(error, EINVAL,
+					RTE_FLOW_ERROR_TYPE_ACTION, NULL,
+						  "Unable to get the final "
+						  "policy in the hierarchy");
+			acg = &fp->act_cnt[RTE_COLOR_GREEN];
+			acy = &fp->act_cnt[RTE_COLOR_YELLOW];
 			MLX5_ASSERT(acg->fate_action ==
 				    MLX5_FLOW_FATE_SHARED_RSS ||
 				    acy->fate_action ==
-- 
2.26.2


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

* [PATCH v2] net/mlx5: fix RSS validation for meter hierarchy
  2021-11-23 16:00 [PATCH] net/mlx5: fix RSS validation for meter hierarchy Bing Zhao
@ 2021-11-23 16:05 ` Bing Zhao
  2021-11-23 20:34   ` Raslan Darawsheh
  0 siblings, 1 reply; 3+ messages in thread
From: Bing Zhao @ 2021-11-23 16:05 UTC (permalink / raw)
  To: viacheslavo, matan; +Cc: dev, rasland, stable, Li Zhang, Shun Hao

In a meter hierarchy, all the meters are marked with having RSS if
the final meter's termination action is RSS.

When validating a flow rule with meter hierarchy, the RSS action
should not be fetched from the current meter if it is not the final
one.

The fate action union is next meter ID instead of the pointer to the
RSS action. By using the final meter in the hierarchy, the flow rule
validation will succeed without any crash caused by the invalid RSS
action pointer access.

Fixes: 1ce19ab1f43b ("net/mlx5: fix RSS validation with meter policy")
Cc: stable@dpdk.org

Signed-off-by: Bing Zhao <bingz@nvidia.com>
Reviewed-by: Li Zhang <lizh@nvidia.com>
Reviewed-by: Shun Hao <shunh@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
v2: fix typo in the commit message
---
 drivers/net/mlx5/mlx5_flow_dv.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 2f03e59f9c..f5356418fa 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -5254,13 +5254,21 @@ mlx5_flow_validate_action_meter(struct rte_eth_dev *dev,
 						"Flow and meter policy "
 						"have different src port.");
 		} else if (mtr_policy->is_rss) {
-			struct mlx5_meter_policy_action_container *acg =
-				&mtr_policy->act_cnt[RTE_COLOR_GREEN];
-			struct mlx5_meter_policy_action_container *acy =
-				&mtr_policy->act_cnt[RTE_COLOR_YELLOW];
+			struct mlx5_flow_meter_policy *fp;
+			struct mlx5_meter_policy_action_container *acg;
+			struct mlx5_meter_policy_action_container *acy;
 			const struct rte_flow_action *rss_act;
 			int ret;
 
+			fp = mlx5_flow_meter_hierarchy_get_final_policy(dev,
+								mtr_policy);
+			if (fp == NULL)
+				return rte_flow_error_set(error, EINVAL,
+					RTE_FLOW_ERROR_TYPE_ACTION, NULL,
+						  "Unable to get the final "
+						  "policy in the hierarchy");
+			acg = &fp->act_cnt[RTE_COLOR_GREEN];
+			acy = &fp->act_cnt[RTE_COLOR_YELLOW];
 			MLX5_ASSERT(acg->fate_action ==
 				    MLX5_FLOW_FATE_SHARED_RSS ||
 				    acy->fate_action ==
-- 
2.26.3


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

* RE: [PATCH v2] net/mlx5: fix RSS validation for meter hierarchy
  2021-11-23 16:05 ` [PATCH v2] " Bing Zhao
@ 2021-11-23 20:34   ` Raslan Darawsheh
  0 siblings, 0 replies; 3+ messages in thread
From: Raslan Darawsheh @ 2021-11-23 20:34 UTC (permalink / raw)
  To: Bing Zhao, Slava Ovsiienko, Matan Azrad; +Cc: dev, stable, Li Zhang, Shun Hao

Hi,


> -----Original Message-----
> From: Bing Zhao <bingz@nvidia.com>
> Sent: Tuesday, November 23, 2021 6:05 PM
> To: Slava Ovsiienko <viacheslavo@nvidia.com>; Matan Azrad
> <matan@nvidia.com>
> Cc: dev@dpdk.org; Raslan Darawsheh <rasland@nvidia.com>;
> stable@dpdk.org; Li Zhang <lizh@nvidia.com>; Shun Hao
> <shunh@nvidia.com>
> Subject: [PATCH v2] net/mlx5: fix RSS validation for meter hierarchy
> 
> In a meter hierarchy, all the meters are marked with having RSS if
> the final meter's termination action is RSS.
> 
> When validating a flow rule with meter hierarchy, the RSS action
> should not be fetched from the current meter if it is not the final
> one.
> 
> The fate action union is next meter ID instead of the pointer to the
> RSS action. By using the final meter in the hierarchy, the flow rule
> validation will succeed without any crash caused by the invalid RSS
> action pointer access.
> 
> Fixes: 1ce19ab1f43b ("net/mlx5: fix RSS validation with meter policy")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Bing Zhao <bingz@nvidia.com>
> Reviewed-by: Li Zhang <lizh@nvidia.com>
> Reviewed-by: Shun Hao <shunh@nvidia.com>
> Acked-by: Matan Azrad <matan@nvidia.com>

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh

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

end of thread, other threads:[~2021-11-23 20:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-23 16:00 [PATCH] net/mlx5: fix RSS validation for meter hierarchy Bing Zhao
2021-11-23 16:05 ` [PATCH v2] " Bing Zhao
2021-11-23 20:34   ` Raslan Darawsheh

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).