[dpdk-dev,v2,03/13] net/mlx5: fix RSS flow action bounds check

Message ID 20180404144805.11966-4-adrien.mazarguil@6wind.com (mailing list archive)
State Superseded, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail apply issues

Commit Message

Adrien Mazarguil April 4, 2018, 2:57 p.m. UTC
  The number of queues provided by the application is not checked against
parser's supported maximum.

Fixes: 3d821d6fea40 ("net/mlx5: support RSS action flow rule")
Cc: stable@dpdk.org
Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
 drivers/net/mlx5/mlx5_flow.c | 9 +++++++++
 1 file changed, 9 insertions(+)
  

Comments

Nélio Laranjeiro April 5, 2018, 6:57 a.m. UTC | #1
On Wed, Apr 04, 2018 at 04:57:50PM +0200, Adrien Mazarguil wrote:
> The number of queues provided by the application is not checked against
> parser's supported maximum.
> 
> Fixes: 3d821d6fea40 ("net/mlx5: support RSS action flow rule")
> Cc: stable@dpdk.org
> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
> 
> Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>

Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>

> ---
>  drivers/net/mlx5/mlx5_flow.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
> index e6af3243d..f051fbef5 100644
> --- a/drivers/net/mlx5/mlx5_flow.c
> +++ b/drivers/net/mlx5/mlx5_flow.c
> @@ -16,6 +16,7 @@
>  #pragma GCC diagnostic error "-Wpedantic"
>  #endif
>  
> +#include <rte_common.h>
>  #include <rte_ethdev_driver.h>
>  #include <rte_flow.h>
>  #include <rte_flow_driver.h>
> @@ -713,6 +714,14 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev,
>  					return -rte_errno;
>  				}
>  			}
> +			if (rss->num > RTE_DIM(parser->queues)) {
> +				rte_flow_error_set(error, EINVAL,
> +						   RTE_FLOW_ERROR_TYPE_ACTION,
> +						   actions,
> +						   "too many queues for RSS"
> +						   " context");
> +				return -rte_errno;
> +			}
>  			for (n = 0; n < rss->num; ++n) {
>  				if (rss->queue[n] >= priv->rxqs_n) {
>  					rte_flow_error_set(error, EINVAL,
> -- 
> 2.11.0
  

Patch

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index e6af3243d..f051fbef5 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -16,6 +16,7 @@ 
 #pragma GCC diagnostic error "-Wpedantic"
 #endif
 
+#include <rte_common.h>
 #include <rte_ethdev_driver.h>
 #include <rte_flow.h>
 #include <rte_flow_driver.h>
@@ -713,6 +714,14 @@  mlx5_flow_convert_actions(struct rte_eth_dev *dev,
 					return -rte_errno;
 				}
 			}
+			if (rss->num > RTE_DIM(parser->queues)) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_ACTION,
+						   actions,
+						   "too many queues for RSS"
+						   " context");
+				return -rte_errno;
+			}
 			for (n = 0; n < rss->num; ++n) {
 				if (rss->queue[n] >= priv->rxqs_n) {
 					rte_flow_error_set(error, EINVAL,