Skip to content

Commit

Permalink
net/bonding: fix array overflow in Rx burst
Browse files Browse the repository at this point in the history
[ upstream commit 007c5450dfa094f7e07ebee3610bcb3494ef842c ]

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: e1110e9 ("net/bonding: fix Rx slave fairness")

Signed-off-by: Lei Ji <jilei8@huawei.com>
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Acked-by: Min Hu (Connor) <humin29@huawei.com>
  • Loading branch information
wyjwang authored and cpaelzer committed Nov 11, 2022
1 parent 6ba278a commit 10754b6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/net/bonding/rte_eth_bond_pmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 10754b6

Please sign in to comment.