All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net/mlx5: fix RSS flow configuration crash
@ 2018-08-01 10:43 Moti Haimovsky
  2018-08-01 11:01 ` Adrien Mazarguil
  2018-08-01 13:40 ` [PATCH v1] " Moti Haimovsky
  0 siblings, 2 replies; 8+ messages in thread
From: Moti Haimovsky @ 2018-08-01 10:43 UTC (permalink / raw)
  To: shahafs; +Cc: dev, Moti Haimovsky, nelio.laranjeiro

This commit fixes a segmentation fault observed when configuring
mlx5 with RSS flow rule containing invalid queues indices such as
negative numbers or numbers bigger than the number Rx queues the PMD
is configured with.

Fixes: 592f05b29a25 ("net/mlx5: add RSS flow action")
Cc: nelio.laranjeiro@6wind.com

Signed-off-by: Moti Haimovsky <motih@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 6c3021a..0b55366 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -2077,6 +2077,12 @@ struct mlx5_flow_tunnel_info {
 					  "some RSS protocols are not"
 					  " supported");
 	for (i = 0; i != rss->queue_num; ++i) {
+		if (rss->queue[i] >= priv->rxqs_n)
+			return rte_flow_error_set
+				(error, EINVAL,
+				 RTE_FLOW_ERROR_TYPE_ACTION_CONF,
+				 &rss->queue[i],
+				 "queue index out of range");
 		if (!(*priv->rxqs)[rss->queue[i]])
 			return rte_flow_error_set
 				(error, EINVAL,
-- 
1.8.3.1

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

* Re: [PATCH] net/mlx5: fix RSS flow configuration crash
  2018-08-01 10:43 [PATCH] net/mlx5: fix RSS flow configuration crash Moti Haimovsky
@ 2018-08-01 11:01 ` Adrien Mazarguil
  2018-08-01 13:40 ` [PATCH v1] " Moti Haimovsky
  1 sibling, 0 replies; 8+ messages in thread
From: Adrien Mazarguil @ 2018-08-01 11:01 UTC (permalink / raw)
  To: Moti Haimovsky; +Cc: shahafs, dev, nelio.laranjeiro

On Wed, Aug 01, 2018 at 01:43:38PM +0300, Moti Haimovsky wrote:
> This commit fixes a segmentation fault observed when configuring
> mlx5 with RSS flow rule containing invalid queues indices such as
> negative numbers or numbers bigger than the number Rx queues the PMD
> is configured with.
> 
> Fixes: 592f05b29a25 ("net/mlx5: add RSS flow action")
> Cc: nelio.laranjeiro@6wind.com
> 
> Signed-off-by: Moti Haimovsky <motih@mellanox.com>
> ---
>  drivers/net/mlx5/mlx5_flow.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
> index 6c3021a..0b55366 100644
> --- a/drivers/net/mlx5/mlx5_flow.c
> +++ b/drivers/net/mlx5/mlx5_flow.c
> @@ -2077,6 +2077,12 @@ struct mlx5_flow_tunnel_info {
>  					  "some RSS protocols are not"
>  					  " supported");
>  	for (i = 0; i != rss->queue_num; ++i) {
> +		if (rss->queue[i] >= priv->rxqs_n)
> +			return rte_flow_error_set
> +				(error, EINVAL,
> +				 RTE_FLOW_ERROR_TYPE_ACTION_CONF,
> +				 &rss->queue[i],

When specified, the object associated with RTE_FLOW_TYPE_ACTION_CONF is the
configuration structure itself, not the data of an inner field. This type is
that of the the pointed object; the caller may attempt to dereference it
accordingly.

In short, use either "action->conf" or "rss" instead of "&rss->queue[i]"
here.

-- 
Adrien Mazarguil
6WIND

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

* [PATCH v1] net/mlx5: fix RSS flow configuration crash
  2018-08-01 10:43 [PATCH] net/mlx5: fix RSS flow configuration crash Moti Haimovsky
  2018-08-01 11:01 ` Adrien Mazarguil
@ 2018-08-01 13:40 ` Moti Haimovsky
  2018-08-01 14:13   ` Adrien Mazarguil
  2018-08-02  8:41   ` [PATCH v2] " Moti Haimovsky
  1 sibling, 2 replies; 8+ messages in thread
From: Moti Haimovsky @ 2018-08-01 13:40 UTC (permalink / raw)
  To: shahafs; +Cc: dev, Moti Haimovsky, nelio.laranjeiro

This commit fixes a segmentation fault observed when configuring
mlx5 with RSS flow rule containing invalid queues indices such as
negative numbers, queue numbers bigger than the number Rx queues the
PMD or has no queues at all.

Fixes: 592f05b29a25 ("net/mlx5: add RSS flow action")
Cc: nelio.laranjeiro@6wind.com

Signed-off-by: Moti Haimovsky <motih@mellanox.com>
---
v1:
* Added check for zero queues.
---
 drivers/net/mlx5/mlx5_flow.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 6c3021a..d32b86d 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -2065,6 +2065,11 @@ struct mlx5_flow_tunnel_info {
 					  RTE_FLOW_ERROR_TYPE_ACTION_CONF,
 					  &rss->key_len,
 					  "RSS hash key too large");
+	if (!rss->queue_num)
+		return rte_flow_error_set(error, ENOTSUP,
+					  RTE_FLOW_ERROR_TYPE_ACTION_CONF,
+					  &rss->queue_num,
+					  "no queues were provided for RSS");
 	if (rss->queue_num > priv->config.ind_table_max_size)
 		return rte_flow_error_set(error, ENOTSUP,
 					  RTE_FLOW_ERROR_TYPE_ACTION_CONF,
@@ -2077,6 +2082,12 @@ struct mlx5_flow_tunnel_info {
 					  "some RSS protocols are not"
 					  " supported");
 	for (i = 0; i != rss->queue_num; ++i) {
+		if (rss->queue[i] >= priv->rxqs_n)
+			return rte_flow_error_set
+				(error, EINVAL,
+				 RTE_FLOW_ERROR_TYPE_ACTION_CONF,
+				 &rss->queue[i],
+				 "queue index out of range");
 		if (!(*priv->rxqs)[rss->queue[i]])
 			return rte_flow_error_set
 				(error, EINVAL,
-- 
1.8.3.1

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

* Re: [PATCH v1] net/mlx5: fix RSS flow configuration crash
  2018-08-01 13:40 ` [PATCH v1] " Moti Haimovsky
@ 2018-08-01 14:13   ` Adrien Mazarguil
  2018-08-02  8:41   ` [PATCH v2] " Moti Haimovsky
  1 sibling, 0 replies; 8+ messages in thread
From: Adrien Mazarguil @ 2018-08-01 14:13 UTC (permalink / raw)
  To: Moti Haimovsky; +Cc: shahafs, dev, nelio.laranjeiro

On Wed, Aug 01, 2018 at 04:40:07PM +0300, Moti Haimovsky wrote:
> This commit fixes a segmentation fault observed when configuring
> mlx5 with RSS flow rule containing invalid queues indices such as
> negative numbers, queue numbers bigger than the number Rx queues the
> PMD or has no queues at all.
> 
> Fixes: 592f05b29a25 ("net/mlx5: add RSS flow action")
> Cc: nelio.laranjeiro@6wind.com
> 
> Signed-off-by: Moti Haimovsky <motih@mellanox.com>
> ---
> v1:
> * Added check for zero queues.

NACK until my previous comment regarding RTE_FLOW_ERROR_TYPE_ACTION_CONF is
taken into account.

-- 
Adrien Mazarguil
6WIND

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

* [PATCH v2] net/mlx5: fix RSS flow configuration crash
  2018-08-01 13:40 ` [PATCH v1] " Moti Haimovsky
  2018-08-01 14:13   ` Adrien Mazarguil
@ 2018-08-02  8:41   ` Moti Haimovsky
  2018-08-02 11:17     ` Shahaf Shuler
  2018-08-02 11:18     ` Adrien Mazarguil
  1 sibling, 2 replies; 8+ messages in thread
From: Moti Haimovsky @ 2018-08-02  8:41 UTC (permalink / raw)
  To: shahafs, adrien.mazarguil; +Cc: dev, Moti Haimovsky, nelio.laranjeiro

This commit fixes a segmentation fault observed when configuring
mlx5 with RSS flow rule containing invalid queues indices such as
negative numbers, queue numbers bigger than the number Rx queues the
PMD or has no queues at all.

Fixes: 592f05b29a25 ("net/mlx5: add RSS flow action")
Cc: nelio.laranjeiro@6wind.com

Signed-off-by: Moti Haimovsky <motih@mellanox.com>
---
v2:
* Modifications according to review by Adrien Mazarguil.
  in reply to 1533130807-9183-1-git-send-email-motih@mellanox.com
v1:
* Added check for zero queues.
---
 drivers/net/mlx5/mlx5_flow.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 6c3021a..5576044 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -2065,6 +2065,11 @@ struct mlx5_flow_tunnel_info {
 					  RTE_FLOW_ERROR_TYPE_ACTION_CONF,
 					  &rss->key_len,
 					  "RSS hash key too large");
+	if (!rss->queue_num)
+		return rte_flow_error_set(error, ENOTSUP,
+					  RTE_FLOW_ERROR_TYPE_ACTION_CONF,
+					  &rss->queue_num,
+					  "no queues were provided for RSS");
 	if (rss->queue_num > priv->config.ind_table_max_size)
 		return rte_flow_error_set(error, ENOTSUP,
 					  RTE_FLOW_ERROR_TYPE_ACTION_CONF,
@@ -2077,6 +2082,12 @@ struct mlx5_flow_tunnel_info {
 					  "some RSS protocols are not"
 					  " supported");
 	for (i = 0; i != rss->queue_num; ++i) {
+		if (rss->queue[i] >= priv->rxqs_n)
+			return rte_flow_error_set
+				(error, EINVAL,
+				 RTE_FLOW_ERROR_TYPE_ACTION_CONF,
+				 rss,
+				 "queue index out of range");
 		if (!(*priv->rxqs)[rss->queue[i]])
 			return rte_flow_error_set
 				(error, EINVAL,
-- 
1.8.3.1

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

* Re: [PATCH v2] net/mlx5: fix RSS flow configuration crash
  2018-08-02  8:41   ` [PATCH v2] " Moti Haimovsky
@ 2018-08-02 11:17     ` Shahaf Shuler
  2018-08-02 11:18     ` Adrien Mazarguil
  1 sibling, 0 replies; 8+ messages in thread
From: Shahaf Shuler @ 2018-08-02 11:17 UTC (permalink / raw)
  To: Mordechay Haimovsky, Adrien Mazarguil; +Cc: dev, Nélio Laranjeiro

Thursday, August 2, 2018 11:41 AM, Mordechay Haimovsky:
> Subject: [PATCH v2] net/mlx5: fix RSS flow configuration crash
> 
> This commit fixes a segmentation fault observed when configuring
> mlx5 with RSS flow rule containing invalid queues indices such as negative
> numbers, queue numbers bigger than the number Rx queues the PMD or
> has no queues at all.
> 
> Fixes: 592f05b29a25 ("net/mlx5: add RSS flow action")
> Cc: nelio.laranjeiro@6wind.com
> 
> Signed-off-by: Moti Haimovsky <motih@mellanox.com>

Applied to next-net-mlx, thanks. 

> ---
> v2:
> * Modifications according to review by Adrien Mazarguil.
>   in reply to 1533130807-9183-1-git-send-email-motih@mellanox.com
> v1:
> * Added check for zero queues.
> ---
>  drivers/net/mlx5/mlx5_flow.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
> index 6c3021a..5576044 100644
> --- a/drivers/net/mlx5/mlx5_flow.c
> +++ b/drivers/net/mlx5/mlx5_flow.c
> @@ -2065,6 +2065,11 @@ struct mlx5_flow_tunnel_info {
> 
> RTE_FLOW_ERROR_TYPE_ACTION_CONF,
>  					  &rss->key_len,
>  					  "RSS hash key too large");
> +	if (!rss->queue_num)
> +		return rte_flow_error_set(error, ENOTSUP,
> +
> RTE_FLOW_ERROR_TYPE_ACTION_CONF,
> +					  &rss->queue_num,
> +	
				  "no queues were provided for

This is OK as a temporary fix. We should plan to support better OOB experience by using all the queues instead. 

> RSS");
>  	if (rss->queue_num > priv->config.ind_table_max_size)
>  		return rte_flow_error_set(error, ENOTSUP,
> 
> RTE_FLOW_ERROR_TYPE_ACTION_CONF, @@ -2077,6 +2082,12 @@ struct
> mlx5_flow_tunnel_info {
>  					  "some RSS protocols are not"
>  					  " supported");
>  	for (i = 0; i != rss->queue_num; ++i) {
> +		if (rss->queue[i] >= priv->rxqs_n)
> +			return rte_flow_error_set
> +				(error, EINVAL,
> +				 RTE_FLOW_ERROR_TYPE_ACTION_CONF,
> +				 rss,
> +				 "queue index out of range");
>  		if (!(*priv->rxqs)[rss->queue[i]])
>  			return rte_flow_error_set
>  				(error, EINVAL,
> --
> 1.8.3.1

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

* Re: [PATCH v2] net/mlx5: fix RSS flow configuration crash
  2018-08-02  8:41   ` [PATCH v2] " Moti Haimovsky
  2018-08-02 11:17     ` Shahaf Shuler
@ 2018-08-02 11:18     ` Adrien Mazarguil
  2018-08-02 11:20       ` Shahaf Shuler
  1 sibling, 1 reply; 8+ messages in thread
From: Adrien Mazarguil @ 2018-08-02 11:18 UTC (permalink / raw)
  To: Moti Haimovsky; +Cc: shahafs, dev, nelio.laranjeiro

On Thu, Aug 02, 2018 at 11:41:07AM +0300, Moti Haimovsky wrote:
> This commit fixes a segmentation fault observed when configuring
> mlx5 with RSS flow rule containing invalid queues indices such as
> negative numbers, queue numbers bigger than the number Rx queues the
> PMD or has no queues at all.
> 
> Fixes: 592f05b29a25 ("net/mlx5: add RSS flow action")
> Cc: nelio.laranjeiro@6wind.com
> 
> Signed-off-by: Moti Haimovsky <motih@mellanox.com>
> ---
> v2:
> * Modifications according to review by Adrien Mazarguil.
>   in reply to 1533130807-9183-1-git-send-email-motih@mellanox.com

Almost, there is one new occurrence with the same issue, see below.

By the way, like for "types" and "level" fields, a zero value in "queue_num"
could be interpreted as default in order to target all configured queues,
for the convenience of applications that do not care.

This is not explicitly documented so it's just a recommendation though.

> v1:
> * Added check for zero queues.
> ---
>  drivers/net/mlx5/mlx5_flow.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
> index 6c3021a..5576044 100644
> --- a/drivers/net/mlx5/mlx5_flow.c
> +++ b/drivers/net/mlx5/mlx5_flow.c
> @@ -2065,6 +2065,11 @@ struct mlx5_flow_tunnel_info {
>  					  RTE_FLOW_ERROR_TYPE_ACTION_CONF,
>  					  &rss->key_len,
>  					  "RSS hash key too large");
> +	if (!rss->queue_num)
> +		return rte_flow_error_set(error, ENOTSUP,
> +					  RTE_FLOW_ERROR_TYPE_ACTION_CONF,
> +					  &rss->queue_num,

Here ^^

> +					  "no queues were provided for RSS");
>  	if (rss->queue_num > priv->config.ind_table_max_size)
>  		return rte_flow_error_set(error, ENOTSUP,
>  					  RTE_FLOW_ERROR_TYPE_ACTION_CONF,
> @@ -2077,6 +2082,12 @@ struct mlx5_flow_tunnel_info {
>  					  "some RSS protocols are not"
>  					  " supported");
>  	for (i = 0; i != rss->queue_num; ++i) {
> +		if (rss->queue[i] >= priv->rxqs_n)
> +			return rte_flow_error_set
> +				(error, EINVAL,
> +				 RTE_FLOW_ERROR_TYPE_ACTION_CONF,
> +				 rss,
> +				 "queue index out of range");
>  		if (!(*priv->rxqs)[rss->queue[i]])
>  			return rte_flow_error_set
>  				(error, EINVAL,
> -- 
> 1.8.3.1
> 

-- 
Adrien Mazarguil
6WIND

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

* Re: [PATCH v2] net/mlx5: fix RSS flow configuration crash
  2018-08-02 11:18     ` Adrien Mazarguil
@ 2018-08-02 11:20       ` Shahaf Shuler
  0 siblings, 0 replies; 8+ messages in thread
From: Shahaf Shuler @ 2018-08-02 11:20 UTC (permalink / raw)
  To: Adrien Mazarguil, Mordechay Haimovsky; +Cc: dev, Nélio Laranjeiro

Thursday, August 2, 2018 2:19 PM, Adrien Mazarguil:
> Subject: Re: [PATCH v2] net/mlx5: fix RSS flow configuration crash
> 
> On Thu, Aug 02, 2018 at 11:41:07AM +0300, Moti Haimovsky wrote:
> > This commit fixes a segmentation fault observed when configuring
> > mlx5 with RSS flow rule containing invalid queues indices such as
> > negative numbers, queue numbers bigger than the number Rx queues the
> > PMD or has no queues at all.
> >
> > Fixes: 592f05b29a25 ("net/mlx5: add RSS flow action")
> > Cc: nelio.laranjeiro@6wind.com
> >
> > Signed-off-by: Moti Haimovsky <motih@mellanox.com>
> > ---
> > v2:
> > * Modifications according to review by Adrien Mazarguil.
> >   in reply to 1533130807-9183-1-git-send-email-motih@mellanox.com
> 
> Almost, there is one new occurrence with the same issue, see below.
> 
> By the way, like for "types" and "level" fields, a zero value in "queue_num"
> could be interpreted as default in order to target all configured queues, for
> the convenience of applications that do not care.
> 
> This is not explicitly documented so it's just a recommendation though.
> 
> > v1:
> > * Added check for zero queues.
> > ---
> >  drivers/net/mlx5/mlx5_flow.c | 11 +++++++++++
> >  1 file changed, 11 insertions(+)
> >
> > diff --git a/drivers/net/mlx5/mlx5_flow.c
> > b/drivers/net/mlx5/mlx5_flow.c index 6c3021a..5576044 100644
> > --- a/drivers/net/mlx5/mlx5_flow.c
> > +++ b/drivers/net/mlx5/mlx5_flow.c
> > @@ -2065,6 +2065,11 @@ struct mlx5_flow_tunnel_info {
> >
> RTE_FLOW_ERROR_TYPE_ACTION_CONF,
> >  					  &rss->key_len,
> >  					  "RSS hash key too large");
> > +	if (!rss->queue_num)
> > +		return rte_flow_error_set(error, ENOTSUP,
> > +
> RTE_FLOW_ERROR_TYPE_ACTION_CONF,
> > +					  &rss->queue_num,

Will fix locally. No need for new version. 

> 
> Here ^^
> 
> > +					  "no queues were provided for
> RSS");
> >  	if (rss->queue_num > priv->config.ind_table_max_size)
> >  		return rte_flow_error_set(error, ENOTSUP,
> >
> RTE_FLOW_ERROR_TYPE_ACTION_CONF, @@ -2077,6 +2082,12 @@ struct
> > mlx5_flow_tunnel_info {
> >  					  "some RSS protocols are not"
> >  					  " supported");
> >  	for (i = 0; i != rss->queue_num; ++i) {
> > +		if (rss->queue[i] >= priv->rxqs_n)
> > +			return rte_flow_error_set
> > +				(error, EINVAL,
> > +				 RTE_FLOW_ERROR_TYPE_ACTION_CONF,
> > +				 rss,
> > +				 "queue index out of range");
> >  		if (!(*priv->rxqs)[rss->queue[i]])
> >  			return rte_flow_error_set
> >  				(error, EINVAL,
> > --
> > 1.8.3.1
> >
> 
> --
> Adrien Mazarguil
> 6WIND

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

end of thread, other threads:[~2018-08-02 11:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-01 10:43 [PATCH] net/mlx5: fix RSS flow configuration crash Moti Haimovsky
2018-08-01 11:01 ` Adrien Mazarguil
2018-08-01 13:40 ` [PATCH v1] " Moti Haimovsky
2018-08-01 14:13   ` Adrien Mazarguil
2018-08-02  8:41   ` [PATCH v2] " Moti Haimovsky
2018-08-02 11:17     ` Shahaf Shuler
2018-08-02 11:18     ` Adrien Mazarguil
2018-08-02 11:20       ` Shahaf Shuler

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.