patches for DPDK stable branches
 help / color / Atom feed
* [dpdk-stable] [PATCH] net/bonding: fix segfault using invalid port
@ 2019-10-24 20:55 Jiang JunyuX
  2019-10-28  5:42 ` Yang, Qiming
  2019-10-28 20:19 ` [dpdk-stable] [PATCH v2] " Jiang JunyuX
  0 siblings, 2 replies; 12+ messages in thread
From: Jiang JunyuX @ 2019-10-24 20:55 UTC (permalink / raw)
  To: dev; +Cc: Chas Williams, Yang Qiming, Jiang JunyuX, stable

Port validation should be prior to getting dev data
to avoid segmentation fault. This patch fixed the issue.

Fixes: 6d72657ce379 ("net/bonding: add other aggregator modes")
Fixes: 112891cd27e5 ("net/bonding: add dedicated HW queues for LACP control")
Cc: stable@dpdk.org

Signed-off-by: Jiang JunyuX <junyux.jiang@intel.com>
---
 drivers/net/bonding/rte_eth_bond_8023ad.c | 32 ++++++++++++++++-------
 1 file changed, 22 insertions(+), 10 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c
index 7d8da2b31..682854e39 100644
--- a/drivers/net/bonding/rte_eth_bond_8023ad.c
+++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
@@ -1387,11 +1387,12 @@ rte_eth_bond_8023ad_agg_selection_set(uint16_t port_id,
 	struct bond_dev_private *internals;
 	struct mode8023ad_private *mode4;
 
+	if (valid_bonded_port_id(port_id) != 0)
+		return -EINVAL;
+
 	bond_dev = &rte_eth_devices[port_id];
 	internals = bond_dev->data->dev_private;
 
-	if (valid_bonded_port_id(port_id) != 0)
-		return -EINVAL;
 	if (internals->mode != 4)
 		return -EINVAL;
 
@@ -1408,11 +1409,12 @@ int rte_eth_bond_8023ad_agg_selection_get(uint16_t port_id)
 	struct bond_dev_private *internals;
 	struct mode8023ad_private *mode4;
 
+	if (valid_bonded_port_id(port_id) != 0)
+		return -EINVAL;
+
 	bond_dev = &rte_eth_devices[port_id];
 	internals = bond_dev->data->dev_private;
 
-	if (valid_bonded_port_id(port_id) != 0)
-		return -EINVAL;
 	if (internals->mode != 4)
 		return -EINVAL;
 	mode4 = &internals->mode4;
@@ -1665,9 +1667,14 @@ int
 rte_eth_bond_8023ad_dedicated_queues_enable(uint16_t port)
 {
 	int retval = 0;
-	struct rte_eth_dev *dev = &rte_eth_devices[port];
-	struct bond_dev_private *internals = (struct bond_dev_private *)
-		dev->data->dev_private;
+	struct rte_eth_dev *dev;
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(port) != 0)
+		return -EINVAL;
+
+	dev = &rte_eth_devices[port];
+	internals = dev->data->dev_private;
 
 	if (check_for_bonded_ethdev(dev) != 0)
 		return -1;
@@ -1689,9 +1696,14 @@ int
 rte_eth_bond_8023ad_dedicated_queues_disable(uint16_t port)
 {
 	int retval = 0;
-	struct rte_eth_dev *dev = &rte_eth_devices[port];
-	struct bond_dev_private *internals = (struct bond_dev_private *)
-		dev->data->dev_private;
+	struct rte_eth_dev *dev;
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(port) != 0)
+		return -EINVAL;
+
+	dev = &rte_eth_devices[port];
+	internals = dev->data->dev_private;
 
 	if (check_for_bonded_ethdev(dev) != 0)
 		return -1;
-- 
2.17.1


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

* Re: [dpdk-stable] [PATCH] net/bonding: fix segfault using invalid port
  2019-10-24 20:55 [dpdk-stable] [PATCH] net/bonding: fix segfault using invalid port Jiang JunyuX
@ 2019-10-28  5:42 ` Yang, Qiming
  2019-10-29  3:04   ` [dpdk-stable] [dpdk-dev] " Ye Xiaolong
  2019-10-28 20:19 ` [dpdk-stable] [PATCH v2] " Jiang JunyuX
  1 sibling, 1 reply; 12+ messages in thread
From: Yang, Qiming @ 2019-10-28  5:42 UTC (permalink / raw)
  To: Jiang, JunyuX, dev; +Cc: Chas Williams, stable

Hi, Junyu

> -----Original Message-----
> From: Jiang, JunyuX
> Sent: Friday, October 25, 2019 4:56 AM
> To: dev@dpdk.org
> Cc: Chas Williams <chas3@att.com>; Yang, Qiming <qiming.yang@intel.com>;
> Jiang, JunyuX <junyux.jiang@intel.com>; stable@dpdk.org
> Subject: [PATCH] net/bonding: fix segfault using invalid port
> 
> Port validation should be prior to getting dev data to avoid segmentation
> fault. This patch fixed the issue.
> 
> Fixes: 6d72657ce379 ("net/bonding: add other aggregator modes")
> Fixes: 112891cd27e5 ("net/bonding: add dedicated HW queues for LACP
> control")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Jiang JunyuX <junyux.jiang@intel.com>
> ---
>  drivers/net/bonding/rte_eth_bond_8023ad.c | 32 ++++++++++++++++-------
>  1 file changed, 22 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c
> b/drivers/net/bonding/rte_eth_bond_8023ad.c
> index 7d8da2b31..682854e39 100644
> --- a/drivers/net/bonding/rte_eth_bond_8023ad.c
> +++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
> @@ -1387,11 +1387,12 @@
> rte_eth_bond_8023ad_agg_selection_set(uint16_t port_id,
>  	struct bond_dev_private *internals;
>  	struct mode8023ad_private *mode4;
> 
> +	if (valid_bonded_port_id(port_id) != 0)
> +		return -EINVAL;
> +
>  	bond_dev = &rte_eth_devices[port_id];
>  	internals = bond_dev->data->dev_private;
> 
> -	if (valid_bonded_port_id(port_id) != 0)
> -		return -EINVAL;
>  	if (internals->mode != 4)
>  		return -EINVAL;
> 
> @@ -1408,11 +1409,12 @@ int
> rte_eth_bond_8023ad_agg_selection_get(uint16_t port_id)
>  	struct bond_dev_private *internals;
>  	struct mode8023ad_private *mode4;
> 
> +	if (valid_bonded_port_id(port_id) != 0)
> +		return -EINVAL;
> +
>  	bond_dev = &rte_eth_devices[port_id];
>  	internals = bond_dev->data->dev_private;
> 
> -	if (valid_bonded_port_id(port_id) != 0)
> -		return -EINVAL;
>  	if (internals->mode != 4)
>  		return -EINVAL;
>  	mode4 = &internals->mode4;
> @@ -1665,9 +1667,14 @@ int
>  rte_eth_bond_8023ad_dedicated_queues_enable(uint16_t port)  {
>  	int retval = 0;
> -	struct rte_eth_dev *dev = &rte_eth_devices[port];
> -	struct bond_dev_private *internals = (struct bond_dev_private *)
> -		dev->data->dev_private;
> +	struct rte_eth_dev *dev;
> +	struct bond_dev_private *internals;
> +
> +	if (valid_bonded_port_id(port) != 0)
> +		return -EINVAL;
> +
> +	dev = &rte_eth_devices[port];
> +	internals = dev->data->dev_private;
Have you build success? I think we need to add (struct bond_dev_private *) for force transfer

> 
>  	if (check_for_bonded_ethdev(dev) != 0)
>  		return -1;
> @@ -1689,9 +1696,14 @@ int
>  rte_eth_bond_8023ad_dedicated_queues_disable(uint16_t port)  {
>  	int retval = 0;
> -	struct rte_eth_dev *dev = &rte_eth_devices[port];
> -	struct bond_dev_private *internals = (struct bond_dev_private *)
> -		dev->data->dev_private;
> +	struct rte_eth_dev *dev;
> +	struct bond_dev_private *internals;
> +
> +	if (valid_bonded_port_id(port) != 0)
> +		return -EINVAL;
> +
> +	dev = &rte_eth_devices[port];
> +	internals = dev->data->dev_private;
Same as before

> 
>  	if (check_for_bonded_ethdev(dev) != 0)
>  		return -1;
> --
> 2.17.1


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

* [dpdk-stable] [PATCH v2] net/bonding: fix segfault using invalid port
  2019-10-24 20:55 [dpdk-stable] [PATCH] net/bonding: fix segfault using invalid port Jiang JunyuX
  2019-10-28  5:42 ` Yang, Qiming
@ 2019-10-28 20:19 ` " Jiang JunyuX
  2019-10-28 20:48   ` [dpdk-stable] [PATCH v3] net/bonding: fix invalid port using Jiang JunyuX
  1 sibling, 1 reply; 12+ messages in thread
From: Jiang JunyuX @ 2019-10-28 20:19 UTC (permalink / raw)
  To: dev; +Cc: Chas Williams, Yang Qiming, Jiang JunyuX, stable

Port validation should be prior to getting dev data
to avoid segmentation fault. This patch fixed the issue.

Fixes: 6d72657ce379 ("net/bonding: add other aggregator modes")
Fixes: 112891cd27e5 ("net/bonding: add dedicated HW queues for LACP control")
Cc: stable@dpdk.org

Signed-off-by: Jiang JunyuX <junyux.jiang@intel.com>
---
 drivers/net/bonding/rte_eth_bond_8023ad.c | 32 ++++++++++++++++-------
 1 file changed, 22 insertions(+), 10 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c
index 7d8da2b31..cbab538e6 100644
--- a/drivers/net/bonding/rte_eth_bond_8023ad.c
+++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
@@ -1387,11 +1387,12 @@ rte_eth_bond_8023ad_agg_selection_set(uint16_t port_id,
 	struct bond_dev_private *internals;
 	struct mode8023ad_private *mode4;
 
+	if (valid_bonded_port_id(port_id) != 0)
+		return -EINVAL;
+
 	bond_dev = &rte_eth_devices[port_id];
 	internals = bond_dev->data->dev_private;
 
-	if (valid_bonded_port_id(port_id) != 0)
-		return -EINVAL;
 	if (internals->mode != 4)
 		return -EINVAL;
 
@@ -1408,11 +1409,12 @@ int rte_eth_bond_8023ad_agg_selection_get(uint16_t port_id)
 	struct bond_dev_private *internals;
 	struct mode8023ad_private *mode4;
 
+	if (valid_bonded_port_id(port_id) != 0)
+		return -EINVAL;
+
 	bond_dev = &rte_eth_devices[port_id];
 	internals = bond_dev->data->dev_private;
 
-	if (valid_bonded_port_id(port_id) != 0)
-		return -EINVAL;
 	if (internals->mode != 4)
 		return -EINVAL;
 	mode4 = &internals->mode4;
@@ -1665,9 +1667,14 @@ int
 rte_eth_bond_8023ad_dedicated_queues_enable(uint16_t port)
 {
 	int retval = 0;
-	struct rte_eth_dev *dev = &rte_eth_devices[port];
-	struct bond_dev_private *internals = (struct bond_dev_private *)
-		dev->data->dev_private;
+	struct rte_eth_dev *dev;
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(port) != 0)
+		return -EINVAL;
+
+	dev = &rte_eth_devices[port];
+	internals = (struct bond_dev_private *)dev->data->dev_private;
 
 	if (check_for_bonded_ethdev(dev) != 0)
 		return -1;
@@ -1689,9 +1696,14 @@ int
 rte_eth_bond_8023ad_dedicated_queues_disable(uint16_t port)
 {
 	int retval = 0;
-	struct rte_eth_dev *dev = &rte_eth_devices[port];
-	struct bond_dev_private *internals = (struct bond_dev_private *)
-		dev->data->dev_private;
+	struct rte_eth_dev *dev;
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(port) != 0)
+		return -EINVAL;
+
+	dev = &rte_eth_devices[port];
+	internals = (struct bond_dev_private *)dev->data->dev_private;
 
 	if (check_for_bonded_ethdev(dev) != 0)
 		return -1;
-- 
2.17.1


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

* [dpdk-stable] [PATCH v3] net/bonding: fix invalid port using
  2019-10-28 20:19 ` [dpdk-stable] [PATCH v2] " Jiang JunyuX
@ 2019-10-28 20:48   ` Jiang JunyuX
  2019-10-29  2:23     ` [dpdk-stable] [PATCH v4] " Jiang JunyuX
  0 siblings, 1 reply; 12+ messages in thread
From: Jiang JunyuX @ 2019-10-28 20:48 UTC (permalink / raw)
  To: dev; +Cc: Chas Williams, Yang Qiming, Jiang JunyuX, stable

Port validation should be prior to getting device data
to avoid segment fault. This patch fixed the segment fault
caused by invalid port using.

Fixes: 6d72657ce379 ("net/bonding: add other aggregator modes")
Fixes: 112891cd27e5 ("net/bonding: add dedicated HW queues for LACP control")
Cc: stable@dpdk.org

Signed-off-by: Jiang JunyuX <junyux.jiang@intel.com>
---
 drivers/net/bonding/rte_eth_bond_8023ad.c | 32 ++++++++++++++++-------
 1 file changed, 22 insertions(+), 10 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c
index 7d8da2b31..cbab538e6 100644
--- a/drivers/net/bonding/rte_eth_bond_8023ad.c
+++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
@@ -1387,11 +1387,12 @@ rte_eth_bond_8023ad_agg_selection_set(uint16_t port_id,
 	struct bond_dev_private *internals;
 	struct mode8023ad_private *mode4;
 
+	if (valid_bonded_port_id(port_id) != 0)
+		return -EINVAL;
+
 	bond_dev = &rte_eth_devices[port_id];
 	internals = bond_dev->data->dev_private;
 
-	if (valid_bonded_port_id(port_id) != 0)
-		return -EINVAL;
 	if (internals->mode != 4)
 		return -EINVAL;
 
@@ -1408,11 +1409,12 @@ int rte_eth_bond_8023ad_agg_selection_get(uint16_t port_id)
 	struct bond_dev_private *internals;
 	struct mode8023ad_private *mode4;
 
+	if (valid_bonded_port_id(port_id) != 0)
+		return -EINVAL;
+
 	bond_dev = &rte_eth_devices[port_id];
 	internals = bond_dev->data->dev_private;
 
-	if (valid_bonded_port_id(port_id) != 0)
-		return -EINVAL;
 	if (internals->mode != 4)
 		return -EINVAL;
 	mode4 = &internals->mode4;
@@ -1665,9 +1667,14 @@ int
 rte_eth_bond_8023ad_dedicated_queues_enable(uint16_t port)
 {
 	int retval = 0;
-	struct rte_eth_dev *dev = &rte_eth_devices[port];
-	struct bond_dev_private *internals = (struct bond_dev_private *)
-		dev->data->dev_private;
+	struct rte_eth_dev *dev;
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(port) != 0)
+		return -EINVAL;
+
+	dev = &rte_eth_devices[port];
+	internals = (struct bond_dev_private *)dev->data->dev_private;
 
 	if (check_for_bonded_ethdev(dev) != 0)
 		return -1;
@@ -1689,9 +1696,14 @@ int
 rte_eth_bond_8023ad_dedicated_queues_disable(uint16_t port)
 {
 	int retval = 0;
-	struct rte_eth_dev *dev = &rte_eth_devices[port];
-	struct bond_dev_private *internals = (struct bond_dev_private *)
-		dev->data->dev_private;
+	struct rte_eth_dev *dev;
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(port) != 0)
+		return -EINVAL;
+
+	dev = &rte_eth_devices[port];
+	internals = (struct bond_dev_private *)dev->data->dev_private;
 
 	if (check_for_bonded_ethdev(dev) != 0)
 		return -1;
-- 
2.17.1


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

* [dpdk-stable] [PATCH v4] net/bonding: fix invalid port using
  2019-10-28 20:48   ` [dpdk-stable] [PATCH v3] net/bonding: fix invalid port using Jiang JunyuX
@ 2019-10-29  2:23     ` " Jiang JunyuX
  2019-10-29 15:59       ` [dpdk-stable] [dpdk-dev] " Chas Williams
  2019-10-30  2:24       ` [dpdk-stable] " Yang, Qiming
  0 siblings, 2 replies; 12+ messages in thread
From: Jiang JunyuX @ 2019-10-29  2:23 UTC (permalink / raw)
  To: dev; +Cc: Chas Williams, Yang Qiming, Jiang JunyuX, stable

Port validation should be prior to getting device data
to avoid segment fault. This patch fixed the segment fault
caused by invalid port using.

Fixes: 6d72657ce379 ("net/bonding: add other aggregator modes")
Fixes: 112891cd27e5 ("net/bonding: add dedicated HW queues for LACP control")
Cc: stable@dpdk.org

Signed-off-by: Jiang JunyuX <junyux.jiang@intel.com>
---
 drivers/net/bonding/rte_eth_bond_8023ad.c | 32 ++++++++++++++++-------
 1 file changed, 22 insertions(+), 10 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c
index 7d8da2b31..682854e39 100644
--- a/drivers/net/bonding/rte_eth_bond_8023ad.c
+++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
@@ -1387,11 +1387,12 @@ rte_eth_bond_8023ad_agg_selection_set(uint16_t port_id,
 	struct bond_dev_private *internals;
 	struct mode8023ad_private *mode4;
 
+	if (valid_bonded_port_id(port_id) != 0)
+		return -EINVAL;
+
 	bond_dev = &rte_eth_devices[port_id];
 	internals = bond_dev->data->dev_private;
 
-	if (valid_bonded_port_id(port_id) != 0)
-		return -EINVAL;
 	if (internals->mode != 4)
 		return -EINVAL;
 
@@ -1408,11 +1409,12 @@ int rte_eth_bond_8023ad_agg_selection_get(uint16_t port_id)
 	struct bond_dev_private *internals;
 	struct mode8023ad_private *mode4;
 
+	if (valid_bonded_port_id(port_id) != 0)
+		return -EINVAL;
+
 	bond_dev = &rte_eth_devices[port_id];
 	internals = bond_dev->data->dev_private;
 
-	if (valid_bonded_port_id(port_id) != 0)
-		return -EINVAL;
 	if (internals->mode != 4)
 		return -EINVAL;
 	mode4 = &internals->mode4;
@@ -1665,9 +1667,14 @@ int
 rte_eth_bond_8023ad_dedicated_queues_enable(uint16_t port)
 {
 	int retval = 0;
-	struct rte_eth_dev *dev = &rte_eth_devices[port];
-	struct bond_dev_private *internals = (struct bond_dev_private *)
-		dev->data->dev_private;
+	struct rte_eth_dev *dev;
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(port) != 0)
+		return -EINVAL;
+
+	dev = &rte_eth_devices[port];
+	internals = dev->data->dev_private;
 
 	if (check_for_bonded_ethdev(dev) != 0)
 		return -1;
@@ -1689,9 +1696,14 @@ int
 rte_eth_bond_8023ad_dedicated_queues_disable(uint16_t port)
 {
 	int retval = 0;
-	struct rte_eth_dev *dev = &rte_eth_devices[port];
-	struct bond_dev_private *internals = (struct bond_dev_private *)
-		dev->data->dev_private;
+	struct rte_eth_dev *dev;
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(port) != 0)
+		return -EINVAL;
+
+	dev = &rte_eth_devices[port];
+	internals = dev->data->dev_private;
 
 	if (check_for_bonded_ethdev(dev) != 0)
 		return -1;
-- 
2.17.1


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

* Re: [dpdk-stable] [dpdk-dev] [PATCH] net/bonding: fix segfault using invalid port
  2019-10-28  5:42 ` Yang, Qiming
@ 2019-10-29  3:04   ` " Ye Xiaolong
  2019-10-29  6:15     ` Yang, Qiming
  0 siblings, 1 reply; 12+ messages in thread
From: Ye Xiaolong @ 2019-10-29  3:04 UTC (permalink / raw)
  To: Yang, Qiming; +Cc: Jiang, JunyuX, dev, Chas Williams, stable

On 10/28, Yang, Qiming wrote:
>Hi, Junyu
>
>> +	dev = &rte_eth_devices[port];
>> +	internals = dev->data->dev_private;
>Have you build success? I think we need to add (struct bond_dev_private *) for force transfer

dev_private is a void *, an explicit type conversion is not needed here.

Thanks,
Xiaolong
>
>> 
>>  	if (check_for_bonded_ethdev(dev) != 0)
>>  		return -1;
>> @@ -1689,9 +1696,14 @@ int
>>  rte_eth_bond_8023ad_dedicated_queues_disable(uint16_t port)  {
>>  	int retval = 0;
>> -	struct rte_eth_dev *dev = &rte_eth_devices[port];
>> -	struct bond_dev_private *internals = (struct bond_dev_private *)
>> -		dev->data->dev_private;
>> +	struct rte_eth_dev *dev;
>> +	struct bond_dev_private *internals;
>> +
>> +	if (valid_bonded_port_id(port) != 0)
>> +		return -EINVAL;
>> +
>> +	dev = &rte_eth_devices[port];
>> +	internals = dev->data->dev_private;
>Same as before
>
>> 
>>  	if (check_for_bonded_ethdev(dev) != 0)
>>  		return -1;
>> --
>> 2.17.1
>

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

* Re: [dpdk-stable] [dpdk-dev] [PATCH] net/bonding: fix segfault using invalid port
  2019-10-29  3:04   ` [dpdk-stable] [dpdk-dev] " Ye Xiaolong
@ 2019-10-29  6:15     ` Yang, Qiming
  2019-10-29  6:25       ` Ye Xiaolong
  0 siblings, 1 reply; 12+ messages in thread
From: Yang, Qiming @ 2019-10-29  6:15 UTC (permalink / raw)
  To: Ye, Xiaolong; +Cc: Jiang, JunyuX, dev, Chas Williams, stable

> -----Original Message-----
> From: Ye, Xiaolong
> Sent: Tuesday, October 29, 2019 11:04 AM
> To: Yang, Qiming <qiming.yang@intel.com>
> Cc: Jiang, JunyuX <junyux.jiang@intel.com>; dev@dpdk.org; Chas Williams
> <chas3@att.com>; stable@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH] net/bonding: fix segfault using invalid port
> 
> On 10/28, Yang, Qiming wrote:
> >Hi, Junyu
> >
> >> +	dev = &rte_eth_devices[port];
> >> +	internals = dev->data->dev_private;
> >Have you build success? I think we need to add (struct bond_dev_private *)
> for force transfer
> 
> dev_private is a void *, an explicit type conversion is not needed here.

OK, I saw the original code used. 
-	struct bond_dev_private *internals = (struct bond_dev_private *)
-		dev->data->dev_private; 

> 
> Thanks,
> Xiaolong
> >
> >>
> >>  	if (check_for_bonded_ethdev(dev) != 0)
> >>  		return -1;
> >> @@ -1689,9 +1696,14 @@ int
> >>  rte_eth_bond_8023ad_dedicated_queues_disable(uint16_t port)  {
> >>  	int retval = 0;
> >> -	struct rte_eth_dev *dev = &rte_eth_devices[port];
> >> -	struct bond_dev_private *internals = (struct bond_dev_private *)
> >> -		dev->data->dev_private;
> >> +	struct rte_eth_dev *dev;
> >> +	struct bond_dev_private *internals;
> >> +
> >> +	if (valid_bonded_port_id(port) != 0)
> >> +		return -EINVAL;
> >> +
> >> +	dev = &rte_eth_devices[port];
> >> +	internals = dev->data->dev_private;
> >Same as before
> >
> >>
> >>  	if (check_for_bonded_ethdev(dev) != 0)
> >>  		return -1;
> >> --
> >> 2.17.1
> >

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

* Re: [dpdk-stable] [dpdk-dev] [PATCH] net/bonding: fix segfault using invalid port
  2019-10-29  6:15     ` Yang, Qiming
@ 2019-10-29  6:25       ` Ye Xiaolong
  2019-10-29  8:32         ` Yang, Qiming
  0 siblings, 1 reply; 12+ messages in thread
From: Ye Xiaolong @ 2019-10-29  6:25 UTC (permalink / raw)
  To: Yang, Qiming; +Cc: Jiang, JunyuX, dev, Chas Williams, stable

On 10/29, Yang, Qiming wrote:
>> -----Original Message-----
>> From: Ye, Xiaolong
>> Sent: Tuesday, October 29, 2019 11:04 AM
>> To: Yang, Qiming <qiming.yang@intel.com>
>> Cc: Jiang, JunyuX <junyux.jiang@intel.com>; dev@dpdk.org; Chas Williams
>> <chas3@att.com>; stable@dpdk.org
>> Subject: Re: [dpdk-dev] [PATCH] net/bonding: fix segfault using invalid port
>> 
>> On 10/28, Yang, Qiming wrote:
>> >Hi, Junyu
>> >
>> >> +	dev = &rte_eth_devices[port];
>> >> +	internals = dev->data->dev_private;
>> >Have you build success? I think we need to add (struct bond_dev_private *)
>> for force transfer
>> 
>> dev_private is a void *, an explicit type conversion is not needed here.
>
>OK, I saw the original code used. 
>-	struct bond_dev_private *internals = (struct bond_dev_private *)
>-		dev->data->dev_private; 

The original cast is redundant, there is a patchset from Stephen before to
cleanup these unnecessary casts.

http://patches.dpdk.org/cover/53858/

Thanks,
Xiaolong


>
>> 
>> Thanks,
>> Xiaolong
>> >
>> >>
>> >>  	if (check_for_bonded_ethdev(dev) != 0)
>> >>  		return -1;
>> >> @@ -1689,9 +1696,14 @@ int
>> >>  rte_eth_bond_8023ad_dedicated_queues_disable(uint16_t port)  {
>> >>  	int retval = 0;
>> >> -	struct rte_eth_dev *dev = &rte_eth_devices[port];
>> >> -	struct bond_dev_private *internals = (struct bond_dev_private *)
>> >> -		dev->data->dev_private;
>> >> +	struct rte_eth_dev *dev;
>> >> +	struct bond_dev_private *internals;
>> >> +
>> >> +	if (valid_bonded_port_id(port) != 0)
>> >> +		return -EINVAL;
>> >> +
>> >> +	dev = &rte_eth_devices[port];
>> >> +	internals = dev->data->dev_private;
>> >Same as before
>> >
>> >>
>> >>  	if (check_for_bonded_ethdev(dev) != 0)
>> >>  		return -1;
>> >> --
>> >> 2.17.1
>> >

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

* Re: [dpdk-stable] [dpdk-dev] [PATCH] net/bonding: fix segfault using invalid port
  2019-10-29  6:25       ` Ye Xiaolong
@ 2019-10-29  8:32         ` Yang, Qiming
  0 siblings, 0 replies; 12+ messages in thread
From: Yang, Qiming @ 2019-10-29  8:32 UTC (permalink / raw)
  To: Ye, Xiaolong; +Cc: Jiang, JunyuX, dev, Chas Williams, stable

Thanks for the information, got it.

Qiming
> -----Original Message-----
> From: Ye, Xiaolong
> Sent: Tuesday, October 29, 2019 2:26 PM
> To: Yang, Qiming <qiming.yang@intel.com>
> Cc: Jiang, JunyuX <junyux.jiang@intel.com>; dev@dpdk.org; Chas Williams
> <chas3@att.com>; stable@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH] net/bonding: fix segfault using invalid port
> 
> On 10/29, Yang, Qiming wrote:
> >> -----Original Message-----
> >> From: Ye, Xiaolong
> >> Sent: Tuesday, October 29, 2019 11:04 AM
> >> To: Yang, Qiming <qiming.yang@intel.com>
> >> Cc: Jiang, JunyuX <junyux.jiang@intel.com>; dev@dpdk.org; Chas
> >> Williams <chas3@att.com>; stable@dpdk.org
> >> Subject: Re: [dpdk-dev] [PATCH] net/bonding: fix segfault using
> >> invalid port
> >>
> >> On 10/28, Yang, Qiming wrote:
> >> >Hi, Junyu
> >> >
> >> >> +	dev = &rte_eth_devices[port];
> >> >> +	internals = dev->data->dev_private;
> >> >Have you build success? I think we need to add (struct
> >> >bond_dev_private *)
> >> for force transfer
> >>
> >> dev_private is a void *, an explicit type conversion is not needed here.
> >
> >OK, I saw the original code used.
> >-	struct bond_dev_private *internals = (struct bond_dev_private *)
> >-		dev->data->dev_private;
> 
> The original cast is redundant, there is a patchset from Stephen before to
> cleanup these unnecessary casts.
> 
> http://patches.dpdk.org/cover/53858/
> 
> Thanks,
> Xiaolong
> 
> 
> >
> >>
> >> Thanks,
> >> Xiaolong
> >> >
> >> >>
> >> >>  	if (check_for_bonded_ethdev(dev) != 0)
> >> >>  		return -1;
> >> >> @@ -1689,9 +1696,14 @@ int
> >> >>  rte_eth_bond_8023ad_dedicated_queues_disable(uint16_t port)  {
> >> >>  	int retval = 0;
> >> >> -	struct rte_eth_dev *dev = &rte_eth_devices[port];
> >> >> -	struct bond_dev_private *internals = (struct bond_dev_private *)
> >> >> -		dev->data->dev_private;
> >> >> +	struct rte_eth_dev *dev;
> >> >> +	struct bond_dev_private *internals;
> >> >> +
> >> >> +	if (valid_bonded_port_id(port) != 0)
> >> >> +		return -EINVAL;
> >> >> +
> >> >> +	dev = &rte_eth_devices[port];
> >> >> +	internals = dev->data->dev_private;
> >> >Same as before
> >> >
> >> >>
> >> >>  	if (check_for_bonded_ethdev(dev) != 0)
> >> >>  		return -1;
> >> >> --
> >> >> 2.17.1
> >> >

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

* Re: [dpdk-stable] [dpdk-dev] [PATCH v4] net/bonding: fix invalid port using
  2019-10-29  2:23     ` [dpdk-stable] [PATCH v4] " Jiang JunyuX
@ 2019-10-29 15:59       ` " Chas Williams
  2019-10-30  8:48         ` Ferruh Yigit
  2019-10-30  2:24       ` [dpdk-stable] " Yang, Qiming
  1 sibling, 1 reply; 12+ messages in thread
From: Chas Williams @ 2019-10-29 15:59 UTC (permalink / raw)
  To: Jiang JunyuX, dev; +Cc: Chas Williams, Yang Qiming, stable

On 10/28/19 10:23 PM, Jiang JunyuX wrote:
> Port validation should be prior to getting device data
> to avoid segment fault. This patch fixed the segment fault
> caused by invalid port using.
> 
> Fixes: 6d72657ce379 ("net/bonding: add other aggregator modes")
> Fixes: 112891cd27e5 ("net/bonding: add dedicated HW queues for LACP control")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Jiang JunyuX <junyux.jiang@intel.com>

Acked-by: Chas Williams <chas3@att.com>

Patchwork says that there is a build error but it doesn't seem to
be related to this change.

> ---
>   drivers/net/bonding/rte_eth_bond_8023ad.c | 32 ++++++++++++++++-------
>   1 file changed, 22 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c
> index 7d8da2b31..682854e39 100644
> --- a/drivers/net/bonding/rte_eth_bond_8023ad.c
> +++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
> @@ -1387,11 +1387,12 @@ rte_eth_bond_8023ad_agg_selection_set(uint16_t port_id,
>   	struct bond_dev_private *internals;
>   	struct mode8023ad_private *mode4;
>   
> +	if (valid_bonded_port_id(port_id) != 0)
> +		return -EINVAL;
> +
>   	bond_dev = &rte_eth_devices[port_id];
>   	internals = bond_dev->data->dev_private;
>   
> -	if (valid_bonded_port_id(port_id) != 0)
> -		return -EINVAL;
>   	if (internals->mode != 4)
>   		return -EINVAL;
>   
> @@ -1408,11 +1409,12 @@ int rte_eth_bond_8023ad_agg_selection_get(uint16_t port_id)
>   	struct bond_dev_private *internals;
>   	struct mode8023ad_private *mode4;
>   
> +	if (valid_bonded_port_id(port_id) != 0)
> +		return -EINVAL;
> +
>   	bond_dev = &rte_eth_devices[port_id];
>   	internals = bond_dev->data->dev_private;
>   
> -	if (valid_bonded_port_id(port_id) != 0)
> -		return -EINVAL;
>   	if (internals->mode != 4)
>   		return -EINVAL;
>   	mode4 = &internals->mode4;
> @@ -1665,9 +1667,14 @@ int
>   rte_eth_bond_8023ad_dedicated_queues_enable(uint16_t port)
>   {
>   	int retval = 0;
> -	struct rte_eth_dev *dev = &rte_eth_devices[port];
> -	struct bond_dev_private *internals = (struct bond_dev_private *)
> -		dev->data->dev_private;
> +	struct rte_eth_dev *dev;
> +	struct bond_dev_private *internals;
> +
> +	if (valid_bonded_port_id(port) != 0)
> +		return -EINVAL;
> +
> +	dev = &rte_eth_devices[port];
> +	internals = dev->data->dev_private;
>   
>   	if (check_for_bonded_ethdev(dev) != 0)
>   		return -1;
> @@ -1689,9 +1696,14 @@ int
>   rte_eth_bond_8023ad_dedicated_queues_disable(uint16_t port)
>   {
>   	int retval = 0;
> -	struct rte_eth_dev *dev = &rte_eth_devices[port];
> -	struct bond_dev_private *internals = (struct bond_dev_private *)
> -		dev->data->dev_private;
> +	struct rte_eth_dev *dev;
> +	struct bond_dev_private *internals;
> +
> +	if (valid_bonded_port_id(port) != 0)
> +		return -EINVAL;
> +
> +	dev = &rte_eth_devices[port];
> +	internals = dev->data->dev_private;
>   
>   	if (check_for_bonded_ethdev(dev) != 0)
>   		return -1;
> 

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

* Re: [dpdk-stable] [PATCH v4] net/bonding: fix invalid port using
  2019-10-29  2:23     ` [dpdk-stable] [PATCH v4] " Jiang JunyuX
  2019-10-29 15:59       ` [dpdk-stable] [dpdk-dev] " Chas Williams
@ 2019-10-30  2:24       ` " Yang, Qiming
  1 sibling, 0 replies; 12+ messages in thread
From: Yang, Qiming @ 2019-10-30  2:24 UTC (permalink / raw)
  To: Jiang, JunyuX, dev; +Cc: Chas Williams, stable


> -----Original Message-----
> From: Jiang, JunyuX
> Sent: Tuesday, October 29, 2019 10:24 AM
> To: dev@dpdk.org
> Cc: Chas Williams <chas3@att.com>; Yang, Qiming <qiming.yang@intel.com>;
> Jiang, JunyuX <junyux.jiang@intel.com>; stable@dpdk.org
> Subject: [PATCH v4] net/bonding: fix invalid port using
> 
> Port validation should be prior to getting device data to avoid segment fault.
> This patch fixed the segment fault caused by invalid port using.
> 
> Fixes: 6d72657ce379 ("net/bonding: add other aggregator modes")
> Fixes: 112891cd27e5 ("net/bonding: add dedicated HW queues for LACP
> control")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Jiang JunyuX <junyux.jiang@intel.com>
> ---
>  drivers/net/bonding/rte_eth_bond_8023ad.c | 32 ++++++++++++++++-------
>  1 file changed, 22 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c
> b/drivers/net/bonding/rte_eth_bond_8023ad.c
> index 7d8da2b31..682854e39 100644
> --- a/drivers/net/bonding/rte_eth_bond_8023ad.c
> +++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
> @@ -1387,11 +1387,12 @@
> rte_eth_bond_8023ad_agg_selection_set(uint16_t port_id,
>  	struct bond_dev_private *internals;
>  	struct mode8023ad_private *mode4;
> 
> +	if (valid_bonded_port_id(port_id) != 0)
> +		return -EINVAL;
> +
>  	bond_dev = &rte_eth_devices[port_id];
>  	internals = bond_dev->data->dev_private;
> 
> -	if (valid_bonded_port_id(port_id) != 0)
> -		return -EINVAL;
>  	if (internals->mode != 4)
>  		return -EINVAL;
> 
> @@ -1408,11 +1409,12 @@ int
> rte_eth_bond_8023ad_agg_selection_get(uint16_t port_id)
>  	struct bond_dev_private *internals;
>  	struct mode8023ad_private *mode4;
> 
> +	if (valid_bonded_port_id(port_id) != 0)
> +		return -EINVAL;
> +
>  	bond_dev = &rte_eth_devices[port_id];
>  	internals = bond_dev->data->dev_private;
> 
> -	if (valid_bonded_port_id(port_id) != 0)
> -		return -EINVAL;
>  	if (internals->mode != 4)
>  		return -EINVAL;
>  	mode4 = &internals->mode4;
> @@ -1665,9 +1667,14 @@ int
>  rte_eth_bond_8023ad_dedicated_queues_enable(uint16_t port)  {
>  	int retval = 0;
> -	struct rte_eth_dev *dev = &rte_eth_devices[port];
> -	struct bond_dev_private *internals = (struct bond_dev_private *)
> -		dev->data->dev_private;
> +	struct rte_eth_dev *dev;
> +	struct bond_dev_private *internals;
> +
> +	if (valid_bonded_port_id(port) != 0)
> +		return -EINVAL;
> +
> +	dev = &rte_eth_devices[port];
> +	internals = dev->data->dev_private;
> 
>  	if (check_for_bonded_ethdev(dev) != 0)
>  		return -1;
> @@ -1689,9 +1696,14 @@ int
>  rte_eth_bond_8023ad_dedicated_queues_disable(uint16_t port)  {
>  	int retval = 0;
> -	struct rte_eth_dev *dev = &rte_eth_devices[port];
> -	struct bond_dev_private *internals = (struct bond_dev_private *)
> -		dev->data->dev_private;
> +	struct rte_eth_dev *dev;
> +	struct bond_dev_private *internals;
> +
> +	if (valid_bonded_port_id(port) != 0)
> +		return -EINVAL;
> +
> +	dev = &rte_eth_devices[port];
> +	internals = dev->data->dev_private;
> 
>  	if (check_for_bonded_ethdev(dev) != 0)
>  		return -1;
> --
> 2.17.1 

Reviewed-by: Qiming Yang <qiming.yang@intel.com>

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

* Re: [dpdk-stable] [dpdk-dev] [PATCH v4] net/bonding: fix invalid port using
  2019-10-29 15:59       ` [dpdk-stable] [dpdk-dev] " Chas Williams
@ 2019-10-30  8:48         ` Ferruh Yigit
  0 siblings, 0 replies; 12+ messages in thread
From: Ferruh Yigit @ 2019-10-30  8:48 UTC (permalink / raw)
  To: Chas Williams, Jiang JunyuX, dev; +Cc: Chas Williams, Yang Qiming, stable

On 10/29/2019 3:59 PM, Chas Williams wrote:
> On 10/28/19 10:23 PM, Jiang JunyuX wrote:
>> Port validation should be prior to getting device data
>> to avoid segment fault. This patch fixed the segment fault
>> caused by invalid port using.
>>
>> Fixes: 6d72657ce379 ("net/bonding: add other aggregator modes")
>> Fixes: 112891cd27e5 ("net/bonding: add dedicated HW queues for LACP control")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Jiang JunyuX <junyux.jiang@intel.com>
> 
> Acked-by: Chas Williams <chas3@att.com>

Applied to dpdk-next-net/master, thanks.

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

end of thread, back to index

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-24 20:55 [dpdk-stable] [PATCH] net/bonding: fix segfault using invalid port Jiang JunyuX
2019-10-28  5:42 ` Yang, Qiming
2019-10-29  3:04   ` [dpdk-stable] [dpdk-dev] " Ye Xiaolong
2019-10-29  6:15     ` Yang, Qiming
2019-10-29  6:25       ` Ye Xiaolong
2019-10-29  8:32         ` Yang, Qiming
2019-10-28 20:19 ` [dpdk-stable] [PATCH v2] " Jiang JunyuX
2019-10-28 20:48   ` [dpdk-stable] [PATCH v3] net/bonding: fix invalid port using Jiang JunyuX
2019-10-29  2:23     ` [dpdk-stable] [PATCH v4] " Jiang JunyuX
2019-10-29 15:59       ` [dpdk-stable] [dpdk-dev] " Chas Williams
2019-10-30  8:48         ` Ferruh Yigit
2019-10-30  2:24       ` [dpdk-stable] " Yang, Qiming

patches for DPDK stable branches

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/stable/0 stable/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 stable stable/ http://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


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