DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@amd.com>
To: Chaoyong He <chaoyong.he@corigine.com>, dev@dpdk.org
Cc: oss-drivers@corigine.com, Long Wu <long.wu@corigine.com>,
	danielx.t.mrzyglod@intel.com, stable@dpdk.org,
	Peng Zhang <peng.zhang@corigine.com>
Subject: Re: [PATCH 2/3] net/bonding: fix illegal memory accesses
Date: Tue, 31 Oct 2023 14:51:19 +0000	[thread overview]
Message-ID: <7e63b131-ba4a-42af-8654-2bef7445b01b@amd.com> (raw)
In-Reply-To: <20231010062304.205933-3-chaoyong.he@corigine.com>

On 10/10/2023 7:23 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: 6d72657ce379 ("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>
> ---
>  drivers/net/bonding/rte_eth_bond_8023ad.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c
> index 677067870f..0be33f61e3 100644
> --- a/drivers/net/bonding/rte_eth_bond_8023ad.c
> +++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
> @@ -732,10 +732,14 @@ selection_logic(struct bond_dev_private *internals, uint16_t member_id)
>  	switch (internals->mode4.agg_selection) {
>  	case AGG_COUNT:
>  		agg_new_idx = max_index(agg_count, members_count);
> +		if (agg_new_idx >= members_count)
> +			agg_new_idx = default_member;
>  		new_agg_id = members[agg_new_idx];
>

Overrun may happen when 'max_index()' returns error, '-1', which becomes
'UINT16_MAX' as function returns 'uint16_t'.

And 'max_index()' returns error only if "members_count <= 0", but as far
as I can see 'members_count' can't be "<= 0" anyway.

What do you think to remove check in the 'max_index()', or add a check
in 'selection_logic()' for 'members_count == 0', but not sure what to do
'max_index()'in this case, so updating 'max_index()' is simpler.


  reply	other threads:[~2023-10-31 14:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-10  6:23 [PATCH 0/3] Fix three coverity issues of bond PMD Chaoyong He
2023-10-10  6:23 ` [PATCH 1/3] app/test: fix control flow issue Chaoyong He
2023-10-31 14:51   ` Ferruh Yigit
2023-10-10  6:23 ` [PATCH 2/3] net/bonding: fix illegal memory accesses Chaoyong He
2023-10-31 14:51   ` Ferruh Yigit [this message]
2023-11-01  2:19   ` [PATCH v2] " Chaoyong He
2023-11-01 15:38     ` Ferruh Yigit
2023-10-10  6:23 ` [PATCH 3/3] app/test: fix checking return value Chaoyong He
2023-10-31 14:52   ` Ferruh Yigit
2023-10-31 14:52 ` [PATCH 0/3] Fix three coverity issues of bond PMD Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7e63b131-ba4a-42af-8654-2bef7445b01b@amd.com \
    --to=ferruh.yigit@amd.com \
    --cc=chaoyong.he@corigine.com \
    --cc=danielx.t.mrzyglod@intel.com \
    --cc=dev@dpdk.org \
    --cc=long.wu@corigine.com \
    --cc=oss-drivers@corigine.com \
    --cc=peng.zhang@corigine.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).