[v2] net/bonding: fix illegal memory accesses
Checks
Commit Message
From: Long Wu <long.wu@corigine.com>
CI found that overrunning array of 32 2-byte elements at
element index 65535 (byte offset 131071) by dereferencing
pointer "members + agg_new_idx".
Coverity issue: 403099
Fixes: 6d72657 ("net/bonding: add other aggregator modes")
Cc: danielx.t.mrzyglod@intel.com
Cc: stable@dpdk.org
Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
v2:
* Modify the logic of 'max_index()'.
---
drivers/net/bonding/rte_eth_bond_8023ad.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
Comments
On 11/1/2023 2:19 AM, Chaoyong He wrote:
> From: Long Wu <long.wu@corigine.com>
>
> CI found that overrunning array of 32 2-byte elements at
> element index 65535 (byte offset 131071) by dereferencing
> pointer "members + agg_new_idx".
>
> Coverity issue: 403099
> Fixes: 6d72657 ("net/bonding: add other aggregator modes")
> Cc: danielx.t.mrzyglod@intel.com
> Cc: stable@dpdk.org
>
> Signed-off-by: Long Wu <long.wu@corigine.com>
> Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
> Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
>
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
Applied to dpdk-next-net/main, thanks.
@@ -654,12 +654,9 @@ tx_machine(struct bond_dev_private *internals, uint16_t member_id)
}
static uint16_t
-max_index(uint64_t *a, int n)
+max_index(uint64_t *a, uint16_t n)
{
- if (n <= 0)
- return -1;
-
- int i, max_i = 0;
+ uint16_t i, max_i = 0;
uint64_t max = a[0];
for (i = 1; i < n; ++i) {