DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/mlx5: fix crash on deleting flow drop queue
@ 2017-05-01 21:05 Yongseok Koh
  2017-05-02  6:45 ` Nélio Laranjeiro
  0 siblings, 1 reply; 3+ messages in thread
From: Yongseok Koh @ 2017-05-01 21:05 UTC (permalink / raw)
  To: ferruh.yigit; +Cc: dev, adrien.mazarguil, nelio.laranjeiro, Yongseok Koh

If mlx5_dev_start() fails, it tries to rollback data structures related to
rte_flow including drop queue. The destruction code doesn't assume the
structures are created but priv_flow_delete_drop_queue() never does sanity
check. This can cause a crash.

Fixes: 028761059aeb ("net/mlx5: use an RSS drop queue")

Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index cd3e5daf3..adcbe3f52 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -1465,13 +1465,18 @@ priv_flow_delete_drop_queue(struct priv *priv)
 	struct rte_flow_drop *fdq = priv->flow_drop_queue;
 	unsigned int i;
 
-	claim_zero(ibv_destroy_qp(fdq->qp));
-	claim_zero(ibv_exp_destroy_rwq_ind_table(fdq->ind_table));
+	if (!fdq)
+		return;
+	if (fdq->qp)
+		claim_zero(ibv_destroy_qp(fdq->qp));
+	if (fdq->ind_table)
+		claim_zero(ibv_exp_destroy_rwq_ind_table(fdq->ind_table));
 	for (i = 0; i != MLX5_DROP_WQ_N; ++i) {
-		assert(fdq->wqs[i]);
-		claim_zero(ibv_exp_destroy_wq(fdq->wqs[i]));
+		if (fdq->wqs[i])
+			claim_zero(ibv_exp_destroy_wq(fdq->wqs[i]));
 	}
-	claim_zero(ibv_destroy_cq(fdq->cq));
+	if (fdq->cq)
+		claim_zero(ibv_destroy_cq(fdq->cq));
 	rte_free(fdq);
 	priv->flow_drop_queue = NULL;
 }
-- 
2.11.0

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

* Re: [dpdk-dev] [PATCH] net/mlx5: fix crash on deleting flow drop queue
  2017-05-01 21:05 [dpdk-dev] [PATCH] net/mlx5: fix crash on deleting flow drop queue Yongseok Koh
@ 2017-05-02  6:45 ` Nélio Laranjeiro
  2017-05-05 15:48   ` Thomas Monjalon
  0 siblings, 1 reply; 3+ messages in thread
From: Nélio Laranjeiro @ 2017-05-02  6:45 UTC (permalink / raw)
  To: Yongseok Koh; +Cc: ferruh.yigit, dev, adrien.mazarguil

On Mon, May 01, 2017 at 02:05:42PM -0700, Yongseok Koh wrote:
> If mlx5_dev_start() fails, it tries to rollback data structures related to
> rte_flow including drop queue. The destruction code doesn't assume the
> structures are created but priv_flow_delete_drop_queue() never does sanity
> check. This can cause a crash.
> 
> Fixes: 028761059aeb ("net/mlx5: use an RSS drop queue")
> 
> Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
> ---
>  drivers/net/mlx5/mlx5_flow.c | 15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
> index cd3e5daf3..adcbe3f52 100644
> --- a/drivers/net/mlx5/mlx5_flow.c
> +++ b/drivers/net/mlx5/mlx5_flow.c
> @@ -1465,13 +1465,18 @@ priv_flow_delete_drop_queue(struct priv *priv)
>  	struct rte_flow_drop *fdq = priv->flow_drop_queue;
>  	unsigned int i;
>  
> -	claim_zero(ibv_destroy_qp(fdq->qp));
> -	claim_zero(ibv_exp_destroy_rwq_ind_table(fdq->ind_table));
> +	if (!fdq)
> +		return;
> +	if (fdq->qp)
> +		claim_zero(ibv_destroy_qp(fdq->qp));
> +	if (fdq->ind_table)
> +		claim_zero(ibv_exp_destroy_rwq_ind_table(fdq->ind_table));
>  	for (i = 0; i != MLX5_DROP_WQ_N; ++i) {
> -		assert(fdq->wqs[i]);
> -		claim_zero(ibv_exp_destroy_wq(fdq->wqs[i]));
> +		if (fdq->wqs[i])
> +			claim_zero(ibv_exp_destroy_wq(fdq->wqs[i]));
>  	}
> -	claim_zero(ibv_destroy_cq(fdq->cq));
> +	if (fdq->cq)
> +		claim_zero(ibv_destroy_cq(fdq->cq));
>  	rte_free(fdq);
>  	priv->flow_drop_queue = NULL;
>  }
> -- 
> 2.11.0
 

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

-- 
Nélio Laranjeiro
6WIND

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

* Re: [dpdk-dev] [PATCH] net/mlx5: fix crash on deleting flow drop queue
  2017-05-02  6:45 ` Nélio Laranjeiro
@ 2017-05-05 15:48   ` Thomas Monjalon
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2017-05-05 15:48 UTC (permalink / raw)
  To: Yongseok Koh; +Cc: dev, Nélio Laranjeiro, ferruh.yigit, adrien.mazarguil

02/05/2017 08:45, Nélio Laranjeiro:
> On Mon, May 01, 2017 at 02:05:42PM -0700, Yongseok Koh wrote:
> > If mlx5_dev_start() fails, it tries to rollback data structures related to
> > rte_flow including drop queue. The destruction code doesn't assume the
> > structures are created but priv_flow_delete_drop_queue() never does sanity
> > check. This can cause a crash.
> > 
> > Fixes: 028761059aeb ("net/mlx5: use an RSS drop queue")
> > 
> > Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
> 
> Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>

Applied, thanks

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

end of thread, other threads:[~2017-05-05 15:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-01 21:05 [dpdk-dev] [PATCH] net/mlx5: fix crash on deleting flow drop queue Yongseok Koh
2017-05-02  6:45 ` Nélio Laranjeiro
2017-05-05 15:48   ` Thomas Monjalon

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