All of lore.kernel.org
 help / color / mirror / Atom feed
*  [PATCH] net/bonding: fix Segfault when eal thread executing nic‘s lsc event for mode 4
@ 2019-03-06  3:42 Zhaohui (zhaohui, Polestar)
  2019-03-19 17:37 ` Ferruh Yigit
  0 siblings, 1 reply; 6+ messages in thread
From: Zhaohui (zhaohui, Polestar) @ 2019-03-06  3:42 UTC (permalink / raw)
  To: dev, Chas Williams, ferruh.yigit; +Cc: chenchanghu, wangyunjian, stable


When the number of slave slave devices exceeds 8, it will cause the array subscript to cross the boundary.

---
drivers/net/bonding/rte_eth_bond_8023ad.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c
index f6f8b28..b5589c7 100644
--- a/drivers/net/bonding/rte_eth_bond_8023ad.c
+++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
@@ -920,8 +920,8 @@ static void selection_logic (struct bond_dev_private *internals, uint8_t slave_id
       struct port *agg, *port;
       uint16_t slaves_count, new_agg_id, i, j = 0;
       uint16_t *slaves;
-        uint64_t agg_bandwidth[8] = {0};
-        uint64_t agg_count[8] = {0};
+       uint64_t agg_bandwidth[RTE_MAX_ETHPORTS] = {0};
+       uint64_t agg_count[RTE_MAX_ETHPORTS] = {0};
       uint16_t default_slave = 0;
       uint8_t mode_count_id, mode_band_id;
       struct rte_eth_link link_info;
--

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

* Re: [PATCH] net/bonding: fix Segfault when eal thread executing nic‘s lsc event for mode 4
  2019-03-06  3:42 [PATCH] net/bonding: fix Segfault when eal thread executing nic‘s lsc event for mode 4 Zhaohui (zhaohui, Polestar)
@ 2019-03-19 17:37 ` Ferruh Yigit
  2019-03-19 18:00   ` Chas Williams
  0 siblings, 1 reply; 6+ messages in thread
From: Ferruh Yigit @ 2019-03-19 17:37 UTC (permalink / raw)
  To: Zhaohui (zhaohui, Polestar), dev, Chas Williams
  Cc: chenchanghu, wangyunjian, stable, Mrzyglod, Daniel T,
	Declan Doherty, Nicolau, Radu

On 3/6/2019 3:42 AM, Zhaohui (zhaohui, Polestar) wrote:
> When the number of slave slave devices exceeds 8, it will cause the array
> subscript to cross the boundary.
> 
> ---
> drivers/net/bonding/rte_eth_bond_8023ad.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>  
> diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c
> b/drivers/net/bonding/rte_eth_bond_8023ad.c
> index f6f8b28..b5589c7 100644
> --- a/drivers/net/bonding/rte_eth_bond_8023ad.c
> +++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
> @@ -920,8 +920,8 @@ static void selection_logic (struct bond_dev_private
> *internals, uint8_t slave_id
>        struct port *agg, *port;
>        uint16_t slaves_count, new_agg_id, i, j = 0;
>        uint16_t *slaves;
> -        uint64_t agg_bandwidth[8] = {0};
> -        uint64_t agg_count[8] = {0};
> +       uint64_t agg_bandwidth[RTE_MAX_ETHPORTS] = {0};
> +       uint64_t agg_count[RTE_MAX_ETHPORTS] = {0};

Patch doesn't apply clearly but I think the intention in the fix is clear.

Is there any specific reason to pick the number '8'?
Also this function gets 'uint8_t slave_id' as argument, if this is port_is,
should it be uint16_t?

>        uint16_t default_slave = 0;
>        uint8_t mode_count_id, mode_band_id;
>        struct rte_eth_link link_info;
> --

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

* Re: [PATCH] net/bonding: fix Segfault when eal thread executing nic‘s lsc event for mode 4
  2019-03-19 17:37 ` Ferruh Yigit
@ 2019-03-19 18:00   ` Chas Williams
  0 siblings, 0 replies; 6+ messages in thread
From: Chas Williams @ 2019-03-19 18:00 UTC (permalink / raw)
  To: Ferruh Yigit, Zhaohui (zhaohui, Polestar), dev
  Cc: chenchanghu, wangyunjian, stable, Mrzyglod, Daniel T,
	Declan Doherty, Nicolau, Radu

On 3/19/19 1:37 PM, Ferruh Yigit wrote:
> On 3/6/2019 3:42 AM, Zhaohui (zhaohui, Polestar) wrote:
>> When the number of slave slave devices exceeds 8, it will cause the array
>> subscript to cross the boundary.
>>
>> ---
>> drivers/net/bonding/rte_eth_bond_8023ad.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>   
>> diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c
>> b/drivers/net/bonding/rte_eth_bond_8023ad.c
>> index f6f8b28..b5589c7 100644
>> --- a/drivers/net/bonding/rte_eth_bond_8023ad.c
>> +++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
>> @@ -920,8 +920,8 @@ static void selection_logic (struct bond_dev_private
>> *internals, uint8_t slave_id
>>         struct port *agg, *port;
>>         uint16_t slaves_count, new_agg_id, i, j = 0;
>>         uint16_t *slaves;
>> -        uint64_t agg_bandwidth[8] = {0};
>> -        uint64_t agg_count[8] = {0};
>> +       uint64_t agg_bandwidth[RTE_MAX_ETHPORTS] = {0};
>> +       uint64_t agg_count[RTE_MAX_ETHPORTS] = {0};
> 
> Patch doesn't apply clearly but I think the intention in the fix is clear.

Zhaohui,

Has this been an actual problem in practice? I ask because the number
of possible slaves for the bonding drivers appears to be RTE_MAX_ETHPORTS.
I suspect people typically have far fewer slaves on a bonding device in
practice.

> Is there any specific reason to pick the number '8'?

I suspect someone guessed this was the maximum reasonable number of
slaves.

> Also this function gets 'uint8_t slave_id' as argument, if this is port_is,
> should it be uint16_t?

It probably was never completely changed when the DPDK port id changed
from uint8 to uint16.

> 
>>         uint16_t default_slave = 0;
>>         uint8_t mode_count_id, mode_band_id;
>>         struct rte_eth_link link_info;
>> --
> 

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

* Re: [PATCH] net/bonding: fix Segfault when eal thread executing nic‘s lsc event for mode 4
  2019-03-20 13:54   ` 答复: " Zhaohui (zhaohui, Polestar)
@ 2019-03-20 14:21     ` David Marchand
  0 siblings, 0 replies; 6+ messages in thread
From: David Marchand @ 2019-03-20 14:21 UTC (permalink / raw)
  To: Zhaohui (zhaohui, Polestar)
  Cc: dev, Chas Williams, Ferruh Yigit, chenchanghu, stable, wangyunjian

Hello Zhaohui,

On Wed, Mar 20, 2019 at 2:54 PM Zhaohui (zhaohui, Polestar) <
zhaohui8@huawei.com> wrote:

> Well done, Can you fix it?
>
>                               thanks
>
>                             by zhaohui
>

I can take it as part of my series yes.
I will keep your SoB on this part.

Is your name okay like this ?
Zhaohui Polestar <zhaohui8@huawei.com>


-- 
David Marchand

>

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

* Re: [PATCH] net/bonding: fix Segfault when eal thread executing nic‘s lsc event for mode 4
  2019-03-20 13:11 Zhaohui (zhaohui, Polestar)
@ 2019-03-20 13:39 ` David Marchand
  2019-03-20 13:54   ` 答复: " Zhaohui (zhaohui, Polestar)
  0 siblings, 1 reply; 6+ messages in thread
From: David Marchand @ 2019-03-20 13:39 UTC (permalink / raw)
  To: Zhaohui (zhaohui, Polestar)
  Cc: dev, Chas Williams, Ferruh Yigit, chenchanghu, stable, wangyunjian

On Wed, Mar 20, 2019 at 2:26 PM Zhaohui (zhaohui, Polestar) <
zhaohui8@huawei.com> wrote:

> Hi:
>          When the number of slave slave devices exceeds 8, it will cause
> the array subscript to cross the boundary.
>          According to the suggestions, Modified array subscript to
> RTE_MAX_ETHPORTS, and Changed uint8_t to uint16_t. Something like this:
>
> From 51a081ea88cca1599d458d8d1c7d9605a6eb3352 Mon Sep 17 00:00:00 2001
> From: zhaohui8 <zhaohui8@huawei.com>
> Date: Wed, 20 Mar 2019 20:17:27 +0800
> Subject: [PATCH] net/bonding: fix Segfault when eal thread executing nic‘s
> lsc event for mode 4
>
> Change-Id: I6d800a3adf5ca51f295b607de879bcb0ccc20004
> ---
> drivers/net/bonding/rte_eth_bond_8023ad.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c
> b/drivers/net/bonding/rte_eth_bond_8023ad.c
> index dd847c6..4d99239 100644
> --- a/drivers/net/bonding/rte_eth_bond_8023ad.c
> +++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
> @@ -638,7 +638,7 @@
>        SM_FLAG_CLR(port, NTT);
> }
> -static uint8_t
> +static uint16_t
> max_index(uint64_t *a, int n)
> {
>        if (n <= 0)
> @@ -664,15 +664,15 @@
>   * @param port_pos                       Port to assign.
>   */
> static void
> -selection_logic(struct bond_dev_private *internals, uint8_t slave_id)
> +selection_logic(struct bond_dev_private *internals, uint16_t slave_id)
> {
>        struct port *agg, *port;
>        uint16_t slaves_count, new_agg_id, i, j = 0;
>        uint16_t *slaves;
> -        uint64_t agg_bandwidth[8] = {0};
> -        uint64_t agg_count[8] = {0};
> +       uint64_t agg_bandwidth[RTE_MAX_ETHPORTS] = {0};
> +       uint64_t agg_count[RTE_MAX_ETHPORTS] = {0};
>        uint16_t default_slave = 0;
> -        uint8_t mode_count_id, mode_band_id;
> +       uint16_t mode_count_id, mode_band_id;
>        struct rte_eth_link link_info;
>         slaves = internals->active_slaves;
> @@ -806,7 +806,7 @@
>        struct ether_addr slave_addr;
>        struct rte_mbuf *lacp_pkt = NULL;
> -        uint8_t i, slave_id;
> +       uint16_t i, slave_id;
>
>         /* Update link status on each port */
> --
> 1.9.5.msysgit.0
>
>
Oh, I had missed this [8] array, good catch.
For the slave id on 16bits, I sent this earlier:
http://patchwork.dpdk.org/patch/51387/

And I have other fixes for 802.3ad that I will send once properly tested.


-- 
David Marchand

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

*  [PATCH] net/bonding: fix Segfault when eal thread executing nic‘s lsc event for mode 4
@ 2019-03-20 13:11 Zhaohui (zhaohui, Polestar)
  2019-03-20 13:39 ` David Marchand
  0 siblings, 1 reply; 6+ messages in thread
From: Zhaohui (zhaohui, Polestar) @ 2019-03-20 13:11 UTC (permalink / raw)
  To: dev, Chas Williams, Ferruh Yigit; +Cc: chenchanghu, stable, wangyunjian

Hi:
         When the number of slave slave devices exceeds 8, it will cause the array subscript to cross the boundary.
         According to the suggestions, Modified array subscript to RTE_MAX_ETHPORTS, and Changed uint8_t to uint16_t. Something like this:

From 51a081ea88cca1599d458d8d1c7d9605a6eb3352 Mon Sep 17 00:00:00 2001
From: zhaohui8 <zhaohui8@huawei.com>
Date: Wed, 20 Mar 2019 20:17:27 +0800
Subject: [PATCH] net/bonding: fix Segfault when eal thread executing nic‘s lsc event for mode 4

Change-Id: I6d800a3adf5ca51f295b607de879bcb0ccc20004
---
drivers/net/bonding/rte_eth_bond_8023ad.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c
index dd847c6..4d99239 100644
--- a/drivers/net/bonding/rte_eth_bond_8023ad.c
+++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
@@ -638,7 +638,7 @@
       SM_FLAG_CLR(port, NTT);
}
-static uint8_t
+static uint16_t
max_index(uint64_t *a, int n)
{
       if (n <= 0)
@@ -664,15 +664,15 @@
  * @param port_pos                       Port to assign.
  */
static void
-selection_logic(struct bond_dev_private *internals, uint8_t slave_id)
+selection_logic(struct bond_dev_private *internals, uint16_t slave_id)
{
       struct port *agg, *port;
       uint16_t slaves_count, new_agg_id, i, j = 0;
       uint16_t *slaves;
-        uint64_t agg_bandwidth[8] = {0};
-        uint64_t agg_count[8] = {0};
+       uint64_t agg_bandwidth[RTE_MAX_ETHPORTS] = {0};
+       uint64_t agg_count[RTE_MAX_ETHPORTS] = {0};
       uint16_t default_slave = 0;
-        uint8_t mode_count_id, mode_band_id;
+       uint16_t mode_count_id, mode_band_id;
       struct rte_eth_link link_info;
        slaves = internals->active_slaves;
@@ -806,7 +806,7 @@
       struct ether_addr slave_addr;
       struct rte_mbuf *lacp_pkt = NULL;
-        uint8_t i, slave_id;
+       uint16_t i, slave_id;

        /* Update link status on each port */
--
1.9.5.msysgit.0


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

end of thread, other threads:[~2019-03-20 14:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-06  3:42 [PATCH] net/bonding: fix Segfault when eal thread executing nic‘s lsc event for mode 4 Zhaohui (zhaohui, Polestar)
2019-03-19 17:37 ` Ferruh Yigit
2019-03-19 18:00   ` Chas Williams
2019-03-20 13:11 Zhaohui (zhaohui, Polestar)
2019-03-20 13:39 ` David Marchand
2019-03-20 13:54   ` 答复: " Zhaohui (zhaohui, Polestar)
2019-03-20 14:21     ` David Marchand

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.