net/mlx5: fix validation of Rx queue number

Message ID 1543396577-60481-1-git-send-email-dekelp@mellanox.com (mailing list archive)
State Accepted, archived
Delegated to: Shahaf Shuler
Headers
Series net/mlx5: fix validation of Rx queue number |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS

Commit Message

Dekel Peled Nov. 28, 2018, 9:16 a.m. UTC
  Function mlx5_ctrl_flow_vlan() is used to set the rss rule in
MLX5 PMD, using priv->reta_idx_n as number of Rx queues.
This number is passed to mlx5_flow_validate_action_rss(), which
attempts to access the Rx queues at priv->rxqs.
In case priv->rxqs_n is 0, priv->rxqs is empty, and
mlx5_flow_validate_action_rss() will crash with segmentation fault.

priv->reta_idx_n can never be 0, even if priv->rxqs_n is set to 0.
But when priv->rxqs_n is set to 0, setting the rss rule is invalid.

This patch updates mlx5_ctrl_flow_vlan(), if priv->rxqs_n is 0 the
function will fail with EINVAL errno.

Fixes: 8086cf08b2f0 ("net/mlx5: handle RSS hash configuration in RSS flow")
Cc: nelio.laranjeiro@6wind.com

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Shahaf Shuler Dec. 6, 2018, 11:34 a.m. UTC | #1
Wednesday, November 28, 2018 11:16 AM, Dekel Peled:
> Subject: [dpdk-dev] [PATCH] net/mlx5: fix validation of Rx queue number
> 
> Function mlx5_ctrl_flow_vlan() is used to set the rss rule in
> MLX5 PMD, using priv->reta_idx_n as number of Rx queues.
> This number is passed to mlx5_flow_validate_action_rss(), which attempts
> to access the Rx queues at priv->rxqs.
> In case priv->rxqs_n is 0, priv->rxqs is empty, and
> mlx5_flow_validate_action_rss() will crash with segmentation fault.
> 
> priv->reta_idx_n can never be 0, even if priv->rxqs_n is set to 0.
> But when priv->rxqs_n is set to 0, setting the rss rule is invalid.
> 
> This patch updates mlx5_ctrl_flow_vlan(), if priv->rxqs_n is 0 the function will
> fail with EINVAL errno.
> 
> Fixes: 8086cf08b2f0 ("net/mlx5: handle RSS hash configuration in RSS flow")
> Cc: nelio.laranjeiro@6wind.com
> 
> Signed-off-by: Dekel Peled <dekelp@mellanox.com>

Applied to next-net-mlx, thanks.
  

Patch

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 97dc3e1..ee129b9 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -2314,7 +2314,7 @@  struct rte_flow *
 	struct rte_flow_error error;
 	unsigned int i;
 
-	if (!priv->reta_idx_n) {
+	if (!priv->reta_idx_n || !priv->rxqs_n) {
 		rte_errno = EINVAL;
 		return -rte_errno;
 	}