Skip to contentSkip to conversation

net/bonding:fix balance-xor link down stack overflow

PATCH In review jilei 5 participants 6 messages Aug 10, 2021 – Aug 25, 2022

Subsystems (2)
lore
Share & tools
lore

jilei

author
#0 lore raw

PATCH 1/1 net/bonding:fix balance-xor link down stack overflow

When slave link down, deactivate_slave will internals->active_slaves and internals->active_slave_count.Active_slave in bond_ethdev_rx_burst may out of range in internals->active_slaves.It will get bond's port_id cause stack overflow

---
 drivers/net/bonding/rte_eth_bond_pmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bonding/rte_eth_bond_pmd.c +1 -1
index a6755661c4..46f2c42d60 100644
@@ -82,7 +82,7 @@ bond_ethdev_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 					 bufs + num_rx_total, nb_pkts);
 		num_rx_total += num_rx_slave;
 		nb_pkts -= num_rx_slave;
-		if (++active_slave == slave_count)
+		if (++active_slave >= slave_count)
 			active_slave = 0;
 	}
 
Signature · 1 line
2.23.0
#1 lore raw

Hi,
Your patch is OK, but the description is misleading and has
syntax errors. Please fix it ,thanks.

Quoted 25 lines · jilei

When slave link down, deactivate_slave will internals->active_slaves and internals->active_slave_count.Active_slave in bond_ethdev_rx_burst may out of range in internals->active_slaves.It will get bond's port_id cause stack overflow

---
  drivers/net/bonding/rte_eth_bond_pmd.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bonding/rte_eth_bond_pmd.c +1 -1
index a6755661c4..46f2c42d60 100644
@@ -82,7 +82,7 @@ bond_ethdev_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
  					 bufs + num_rx_total, nb_pkts);
  		num_rx_total += num_rx_slave;
  		nb_pkts -= num_rx_slave;
-		if (++active_slave == slave_count)
+		if (++active_slave >= slave_count)
  			active_slave = 0;
  	}
 
#2 lore raw
Quoted 22 lines · Min Hu (Connor)
Quoted 21 lines · jilei

When slave link down, deactivate_slave will internals->active_slaves and internals->active_slave_count.Active_slave in bond_ethdev_rx_burst may out of range in internals->active_slaves.It will get bond's port_id cause stack overflow

---
  drivers/net/bonding/rte_eth_bond_pmd.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bonding/rte_eth_bond_pmd.c +0 -1
index a6755661c4..46f2c42d60 100644
@@ -82,7 +82,7 @@ bond_ethdev_rx_burst(void *queue, struct rte_mbuf 
 **bufs, uint16_t nb_pkts)
                        bufs + num_rx_total, nb_pkts);
           num_rx_total += num_rx_slave;
           nb_pkts -= num_rx_slave;
-        if (++active_slave == slave_count)
Quoted 9 lines

drivers/net/bonding/rte_eth_bond_pmd.c bond_ethdev_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) · line 87

Quoted 4 lines
drivers/net/bonding/rte_eth_bond_pmd.c +1 -0
+        if (++active_slave >= slave_count)
               active_slave = 0;
       }

Hi,
Your patch is OK, but the description is misleading and has
syntax errors. Please fix it ,thanks.

Hi jilei,

The patch is waiting for a minor update from you, can you please send a new version with the requested change?

Btw, please add your sign off in following format:

Thanks,
ferruh

#3 lore raw

PATCH 1/1 net/bonding: fix array overflow in Rx burst

In reply to jilei

In bond_ethdev_rx_burst() function, we check the validity of the 'active_slave' as this code:
if (++active_slave == slave_count)

	active_slave = 0;

However, the value of 'active_slave' maybe equal to 'slave_count', when a slave is down. This is wrong and it can cause buffer overflow. This patch fixes the issue by using '>=' instead of '=='.

Fixes e1110e977648 ("net/bonding: fix Rx slave fairness")
---
 drivers/net/bonding/rte_eth_bond_pmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bonding/rte_eth_bond_pmd.c +1 -1
index 73e6972035..6f8a6da108 100644
@@ -82,7 +82,7 @@ bond_ethdev_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 					 bufs + num_rx_total, nb_pkts);
 		num_rx_total += num_rx_slave;
 		nb_pkts -= num_rx_slave;
-		if (++active_slave == slave_count)
+		if (++active_slave >= slave_count)
 			active_slave = 0;
 	}
 
Signature · 1 line
2.27.0
Acked-by on v1 1/1
#4 lore raw

答复: [dpdk-dev] [PATCH] net/bonding: fix array overflow in Rx burst

-----邮件原件-----
发件人: wangyunjian <[email protected]>
发送时间: 2022年7月18日 21:09
收件人: [email protected]
抄送: [email protected]; humin (Q) <[email protected]>; Huangshaozhang <[email protected]>; jilei (F) <[email protected]>; wangyunjian <[email protected]>; [email protected] 主题: [dpdk-dev] [PATCH] net/bonding: fix array overflow in Rx burst

In bond_ethdev_rx_burst() function, we check the validity of the 'active_slave' as this code:
if (++active_slave == slave_count)

	active_slave = 0;

However, the value of 'active_slave' maybe equal to 'slave_count', when a slave is down. This is wrong and it can cause buffer overflow. This patch fixes the issue by using '>=' instead of '=='.

Fixes e1110e977648 ("net/bonding: fix Rx slave fairness")
---
 drivers/net/bonding/rte_eth_bond_pmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bonding/rte_eth_bond_pmd.c +1 -1
index 73e6972035..6f8a6da108 100644
@@ -82,7 +82,7 @@ bond_ethdev_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 					 bufs + num_rx_total, nb_pkts);
 		num_rx_total += num_rx_slave;
 		nb_pkts -= num_rx_slave;
-		if (++active_slave == slave_count)
+		if (++active_slave >= slave_count)
 			active_slave = 0;
 	}
 

--
2.27.0

Applied
#5 lore raw

Re: 答复: [dpdk-dev] [PATCH] net/bonding: fix array overflow in Rx burst

Quoted 13 lines · humin (Q)

-----邮件原件-----
发件人: wangyunjian <[email protected]>
发送时间: 2022年7月18日 21:09
收件人: [email protected]
抄送: [email protected]; humin (Q) <[email protected]>; Huangshaozhang <[email protected]>; jilei (F) <[email protected]>; wangyunjian <[email protected]>; [email protected] 主题: [dpdk-dev] [PATCH] net/bonding: fix array overflow in Rx burst

In bond_ethdev_rx_burst() function, we check the validity of the 'active_slave' as this code:
if (++active_slave == slave_count)

	active_slave = 0;

However, the value of 'active_slave' maybe equal to 'slave_count', when a slave is down. This is wrong and it can cause buffer overflow. This patch fixes the issue by using '>=' instead of '=='.

Quoted 8 lines
Fixes e1110e977648 ("net/bonding: fix Rx slave fairness")

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