DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/mlx5: fix flow descriptor allocation in Direct Verbs mode.
@ 2020-12-07 14:27 Gregory Etelson
  2020-12-08  2:58 ` Xueming(Steven) Li
  2020-12-08  8:17 ` [dpdk-dev] [PATCH v2] " Gregory Etelson
  0 siblings, 2 replies; 5+ messages in thread
From: Gregory Etelson @ 2020-12-07 14:27 UTC (permalink / raw)
  To: dev
  Cc: getelson, matan, rasland, Viacheslav Ovsiienko, Shahaf Shuler,
	Xueming Li

Initialize flow descriptor tunnel member during flow creation.
Prevent access to stale data and pointers when flow descriptor is
reallocated after relase.

Fixes: 8bb81f2649b1 ("net/mlx5: use thread specific flow workspace")

Signed-off-by: Gregory Etelson <getelson@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_dv.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index aa21ff9613..c72f97e05f 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -6232,8 +6232,9 @@ flow_dv_prepare(struct rte_eth_dev *dev,
 				   "not enough memory to create flow handle");
 		return NULL;
 	}
-	MLX5_ASSERT(wks->flow_idx + 1 < RTE_DIM(wks->flows));
+	MLX5_ASSERT(wks->flow_idx - 1 < RTE_DIM(wks->flows));
 	dev_flow = &wks->flows[wks->flow_idx++];
+	memset(dev_flow, 0, sizeof(*dev_flow));
 	dev_flow->handle = dev_handle;
 	dev_flow->handle_idx = handle_idx;
 	/*
@@ -6245,12 +6246,6 @@ flow_dv_prepare(struct rte_eth_dev *dev,
 	 */
 	dev_flow->dv.value.size = MLX5_ST_SZ_BYTES(fte_match_param) -
 				  MLX5_ST_SZ_BYTES(fte_match_set_misc4);
-	/*
-	 * The matching value needs to be cleared to 0 before using. In the
-	 * past, it will be automatically cleared when using rte_*alloc
-	 * API. The time consumption will be almost the same as before.
-	 */
-	memset(dev_flow->dv.value.buf, 0, MLX5_ST_SZ_BYTES(fte_match_param));
 	dev_flow->ingress = attr->ingress;
 	dev_flow->dv.transfer = attr->transfer;
 	return dev_flow;
-- 
2.29.2


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

* Re: [dpdk-dev] [PATCH] net/mlx5: fix flow descriptor allocation in Direct Verbs mode.
  2020-12-07 14:27 [dpdk-dev] [PATCH] net/mlx5: fix flow descriptor allocation in Direct Verbs mode Gregory Etelson
@ 2020-12-08  2:58 ` Xueming(Steven) Li
  2020-12-08  8:17 ` [dpdk-dev] [PATCH v2] " Gregory Etelson
  1 sibling, 0 replies; 5+ messages in thread
From: Xueming(Steven) Li @ 2020-12-08  2:58 UTC (permalink / raw)
  To: Gregory Etelson, dev
  Cc: Matan Azrad, Raslan Darawsheh, Slava Ovsiienko, Shahaf Shuler

Hi Gregory,

>-----Original Message-----
>From: Gregory Etelson <getelson@nvidia.com>
>Sent: Monday, December 7, 2020 10:28 PM
>To: dev@dpdk.org
>Cc: Gregory Etelson <getelson@nvidia.com>; Matan Azrad
><matan@nvidia.com>; Raslan Darawsheh <rasland@nvidia.com>; Slava
>Ovsiienko <viacheslavo@nvidia.com>; Shahaf Shuler <shahafs@nvidia.com>;
>Xueming(Steven) Li <xuemingl@nvidia.com>
>Subject: [PATCH] net/mlx5: fix flow descriptor allocation in Direct Verbs mode.
>
>Initialize flow descriptor tunnel member during flow creation.
>Prevent access to stale data and pointers when flow descriptor is reallocated
>after relase.
>
>Fixes: 8bb81f2649b1 ("net/mlx5: use thread specific flow workspace")
The initialization issue is introduced in earlier patch.

>
>Signed-off-by: Gregory Etelson <getelson@nvidia.com>
>Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
>---
> drivers/net/mlx5/mlx5_flow_dv.c | 9 ++-------
> 1 file changed, 2 insertions(+), 7 deletions(-)
>
>diff --git a/drivers/net/mlx5/mlx5_flow_dv.c
>b/drivers/net/mlx5/mlx5_flow_dv.c index aa21ff9613..c72f97e05f 100644
>--- a/drivers/net/mlx5/mlx5_flow_dv.c
>+++ b/drivers/net/mlx5/mlx5_flow_dv.c
>@@ -6232,8 +6232,9 @@ flow_dv_prepare(struct rte_eth_dev *dev,
> 				   "not enough memory to create flow handle");
> 		return NULL;
> 	}
>-	MLX5_ASSERT(wks->flow_idx + 1 < RTE_DIM(wks->flows));
>+	MLX5_ASSERT(wks->flow_idx - 1 < RTE_DIM(wks->flows));
wks->flow_idx is used as "next available index", should it be "wks->flow_idx < RTE_DIM(...)"?

> 	dev_flow = &wks->flows[wks->flow_idx++];
>+	memset(dev_flow, 0, sizeof(*dev_flow));
> 	dev_flow->handle = dev_handle;
> 	dev_flow->handle_idx = handle_idx;
> 	/*
>@@ -6245,12 +6246,6 @@ flow_dv_prepare(struct rte_eth_dev *dev,
> 	 */
> 	dev_flow->dv.value.size = MLX5_ST_SZ_BYTES(fte_match_param) -
> 				  MLX5_ST_SZ_BYTES(fte_match_set_misc4);
>-	/*
>-	 * The matching value needs to be cleared to 0 before using. In the
>-	 * past, it will be automatically cleared when using rte_*alloc
>-	 * API. The time consumption will be almost the same as before.
>-	 */
>-	memset(dev_flow->dv.value.buf, 0,
>MLX5_ST_SZ_BYTES(fte_match_param));
> 	dev_flow->ingress = attr->ingress;
> 	dev_flow->dv.transfer = attr->transfer;
> 	return dev_flow;
>--
>2.29.2


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

* [dpdk-dev] [PATCH v2] net/mlx5: fix flow descriptor allocation in Direct Verbs mode.
  2020-12-07 14:27 [dpdk-dev] [PATCH] net/mlx5: fix flow descriptor allocation in Direct Verbs mode Gregory Etelson
  2020-12-08  2:58 ` Xueming(Steven) Li
@ 2020-12-08  8:17 ` Gregory Etelson
  2020-12-08  8:40   ` Xueming(Steven) Li
  2020-12-15 11:10   ` Raslan Darawsheh
  1 sibling, 2 replies; 5+ messages in thread
From: Gregory Etelson @ 2020-12-08  8:17 UTC (permalink / raw)
  To: dev
  Cc: getelson, matan, rasland, Viacheslav Ovsiienko, Shahaf Shuler,
	Bing Zhao, Xueming Li

Initialize flow descriptor tunnel member during flow creation.
Prevent access to stale data and pointers when flow descriptor is
reallocated after release.
Fix flow index validation.

Fixes: e7bfa3596a0a ("net/mlx5: separate the flow handle resource")
Fixes: 8bb81f2649b1 ("net/mlx5: use thread specific flow workspace")

Signed-off-by: Gregory Etelson <getelson@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_dv.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index aa21ff9613..8f7085c951 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -6232,8 +6232,9 @@ flow_dv_prepare(struct rte_eth_dev *dev,
 				   "not enough memory to create flow handle");
 		return NULL;
 	}
-	MLX5_ASSERT(wks->flow_idx + 1 < RTE_DIM(wks->flows));
+	MLX5_ASSERT(wks->flow_idx < RTE_DIM(wks->flows));
 	dev_flow = &wks->flows[wks->flow_idx++];
+	memset(dev_flow, 0, sizeof(*dev_flow));
 	dev_flow->handle = dev_handle;
 	dev_flow->handle_idx = handle_idx;
 	/*
@@ -6245,12 +6246,6 @@ flow_dv_prepare(struct rte_eth_dev *dev,
 	 */
 	dev_flow->dv.value.size = MLX5_ST_SZ_BYTES(fte_match_param) -
 				  MLX5_ST_SZ_BYTES(fte_match_set_misc4);
-	/*
-	 * The matching value needs to be cleared to 0 before using. In the
-	 * past, it will be automatically cleared when using rte_*alloc
-	 * API. The time consumption will be almost the same as before.
-	 */
-	memset(dev_flow->dv.value.buf, 0, MLX5_ST_SZ_BYTES(fte_match_param));
 	dev_flow->ingress = attr->ingress;
 	dev_flow->dv.transfer = attr->transfer;
 	return dev_flow;
-- 
2.29.2


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

* Re: [dpdk-dev] [PATCH v2] net/mlx5: fix flow descriptor allocation in Direct Verbs mode.
  2020-12-08  8:17 ` [dpdk-dev] [PATCH v2] " Gregory Etelson
@ 2020-12-08  8:40   ` Xueming(Steven) Li
  2020-12-15 11:10   ` Raslan Darawsheh
  1 sibling, 0 replies; 5+ messages in thread
From: Xueming(Steven) Li @ 2020-12-08  8:40 UTC (permalink / raw)
  To: Gregory Etelson, dev
  Cc: Matan Azrad, Raslan Darawsheh, Slava Ovsiienko, Shahaf Shuler, Bing Zhao



>-----Original Message-----
>From: Gregory Etelson <getelson@nvidia.com>
>Sent: Tuesday, December 8, 2020 4:17 PM
>To: dev@dpdk.org
>Cc: Gregory Etelson <getelson@nvidia.com>; Matan Azrad
><matan@nvidia.com>; Raslan Darawsheh <rasland@nvidia.com>; Slava
>Ovsiienko <viacheslavo@nvidia.com>; Shahaf Shuler <shahafs@nvidia.com>;
>Bing Zhao <bingz@mellanox.com>; Xueming(Steven) Li
><xuemingl@nvidia.com>
>Subject: [PATCH v2] net/mlx5: fix flow descriptor allocation in Direct Verbs
>mode.
>
>Initialize flow descriptor tunnel member during flow creation.
>Prevent access to stale data and pointers when flow descriptor is reallocated
>after release.
>Fix flow index validation.
>
>Fixes: e7bfa3596a0a ("net/mlx5: separate the flow handle resource")
>Fixes: 8bb81f2649b1 ("net/mlx5: use thread specific flow workspace")
>
>Signed-off-by: Gregory Etelson <getelson@nvidia.com>
>Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
>---
> drivers/net/mlx5/mlx5_flow_dv.c | 9 ++-------
> 1 file changed, 2 insertions(+), 7 deletions(-)
>
>diff --git a/drivers/net/mlx5/mlx5_flow_dv.c
>b/drivers/net/mlx5/mlx5_flow_dv.c index aa21ff9613..8f7085c951 100644
>--- a/drivers/net/mlx5/mlx5_flow_dv.c
>+++ b/drivers/net/mlx5/mlx5_flow_dv.c
>@@ -6232,8 +6232,9 @@ flow_dv_prepare(struct rte_eth_dev *dev,
> 				   "not enough memory to create flow handle");
> 		return NULL;
> 	}
>-	MLX5_ASSERT(wks->flow_idx + 1 < RTE_DIM(wks->flows));
>+	MLX5_ASSERT(wks->flow_idx < RTE_DIM(wks->flows));
> 	dev_flow = &wks->flows[wks->flow_idx++];
>+	memset(dev_flow, 0, sizeof(*dev_flow));
> 	dev_flow->handle = dev_handle;
> 	dev_flow->handle_idx = handle_idx;
> 	/*
>@@ -6245,12 +6246,6 @@ flow_dv_prepare(struct rte_eth_dev *dev,
> 	 */
> 	dev_flow->dv.value.size = MLX5_ST_SZ_BYTES(fte_match_param) -
> 				  MLX5_ST_SZ_BYTES(fte_match_set_misc4);
>-	/*
>-	 * The matching value needs to be cleared to 0 before using. In the
>-	 * past, it will be automatically cleared when using rte_*alloc
>-	 * API. The time consumption will be almost the same as before.
>-	 */
>-	memset(dev_flow->dv.value.buf, 0,
>MLX5_ST_SZ_BYTES(fte_match_param));
> 	dev_flow->ingress = attr->ingress;
> 	dev_flow->dv.transfer = attr->transfer;
> 	return dev_flow;
>--
>2.29.2
Reviwed by: Xueming(Steven) Li <xuemingl@nvidia.com>

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

* Re: [dpdk-dev] [PATCH v2] net/mlx5: fix flow descriptor allocation in Direct Verbs mode.
  2020-12-08  8:17 ` [dpdk-dev] [PATCH v2] " Gregory Etelson
  2020-12-08  8:40   ` Xueming(Steven) Li
@ 2020-12-15 11:10   ` Raslan Darawsheh
  1 sibling, 0 replies; 5+ messages in thread
From: Raslan Darawsheh @ 2020-12-15 11:10 UTC (permalink / raw)
  To: Gregory Etelson, dev
  Cc: Matan Azrad, Slava Ovsiienko, Shahaf Shuler, Bing Zhao,
	Xueming(Steven) Li

Hi,

> -----Original Message-----
> From: Gregory Etelson <getelson@nvidia.com>
> Sent: Tuesday, December 8, 2020 10:17 AM
> To: dev@dpdk.org
> Cc: Gregory Etelson <getelson@nvidia.com>; Matan Azrad
> <matan@nvidia.com>; Raslan Darawsheh <rasland@nvidia.com>; Slava
> Ovsiienko <viacheslavo@nvidia.com>; Shahaf Shuler <shahafs@nvidia.com>;
> Bing Zhao <bingz@mellanox.com>; Xueming(Steven) Li
> <xuemingl@nvidia.com>
> Subject: [PATCH v2] net/mlx5: fix flow descriptor allocation in Direct Verbs
> mode.
Fix wrong headline in commit title.
Used DV instead of Direct verbs for fixing too long line commit title.

> 
> Initialize flow descriptor tunnel member during flow creation.
> Prevent access to stale data and pointers when flow descriptor is
> reallocated after release.
> Fix flow index validation.
> 
> Fixes: e7bfa3596a0a ("net/mlx5: separate the flow handle resource")
> Fixes: 8bb81f2649b1 ("net/mlx5: use thread specific flow workspace")
> 
Cc: stable@dpdk.org

> Signed-off-by: Gregory Etelson <getelson@nvidia.com>
> Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
> ---
Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh

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

end of thread, other threads:[~2020-12-15 11:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-07 14:27 [dpdk-dev] [PATCH] net/mlx5: fix flow descriptor allocation in Direct Verbs mode Gregory Etelson
2020-12-08  2:58 ` Xueming(Steven) Li
2020-12-08  8:17 ` [dpdk-dev] [PATCH v2] " Gregory Etelson
2020-12-08  8:40   ` Xueming(Steven) Li
2020-12-15 11:10   ` Raslan Darawsheh

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git