DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Lipiec, Herakliusz" <herakliusz.lipiec@intel.com>
To: "Yigit, Ferruh" <ferruh.yigit@intel.com>,
	"Lu, Wenzhuo" <wenzhuo.lu@intel.com>,
	"Wu, Jingjing" <jingjing.wu@intel.com>,
	"Iremonger, Bernard" <bernard.iremonger@intel.com>,
	"Govindharajan, Hariprasad" <hariprasad.govindharajan@intel.com>,
	"Burakov, Anatoly" <anatoly.burakov@intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH] app/testpmd: guarantee that array access is in range
Date: Wed, 19 Feb 2020 13:30:47 +0000	[thread overview]
Message-ID: <BYAPR11MB29522D343EFEEBE2C09773CEF7100@BYAPR11MB2952.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20200219124003.1025267-1-ferruh.yigit@intel.com>

> -----Original Message-----
> From: Yigit, Ferruh <ferruh.yigit@intel.com>
> Sent: Wednesday, February 19, 2020 12:40 PM
> To: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Wu, Jingjing
> <jingjing.wu@intel.com>; Iremonger, Bernard
> <bernard.iremonger@intel.com>; Lipiec, Herakliusz
> <herakliusz.lipiec@intel.com>; Govindharajan, Hariprasad
> <hariprasad.govindharajan@intel.com>; Burakov, Anatoly
> <anatoly.burakov@intel.com>
> Cc: dev@dpdk.org; Yigit, Ferruh <ferruh.yigit@intel.com>
> Subject: [PATCH] app/testpmd: guarantee that array access is in range
> 
> Coverity complains about out of bound access, which is a false positive.
> 
> The return value of the 'parse_port_list()' can't be bigger than 'maxsize'
> because of the logic in the function. ('value >= (int)maxsize'
> check and 'marked[]' usage.)
> 
> But this is not explicitly clear, causing coverity warning and same question can
> be rise by reviews later.
> 
> Adding a redundant check to highlight the access is in range, this is done by
> replacing existing redundant check.
> 
> This is also good to protect against out out bound access in case
> 'parse_port_list()' behaviour changes later unexpectedly.
> 
> Coverity issue: 354229
> Fixes: 2df00d562d20 ("app/testpmd: add --portlist option")
> 
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
> ---
>  app/test-pmd/config.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index
> 9d9520223..d93941f03 100644
> --- a/app/test-pmd/config.c
> +++ b/app/test-pmd/config.c
> @@ -2703,7 +2703,7 @@ parse_fwd_portlist(const char *portlist)
>  	 * and thereby calculate the total number of
>  	 * valid ports
>  	 */
> -	for (i = 0; i < portcount && valid_port_count < portcount; i++) {
> +	for (i = 0; i < portcount && i < RTE_DIM(portindex); i++) {
>  		if (rte_eth_dev_is_valid_port(portindex[i])) {
>  			portindex[valid_port_count] = portindex[i];
>  			valid_port_count++;
> --
> 2.24.1

Reviewed-by: Herakliusz Lipiec <herakliusz.lipiec@intel.com>

  reply	other threads:[~2020-02-19 13:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-19 12:40 Ferruh Yigit
2020-02-19 13:30 ` Lipiec, Herakliusz [this message]
2020-02-19 14:02 ` Iremonger, Bernard
2020-02-19 14:41   ` 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=BYAPR11MB29522D343EFEEBE2C09773CEF7100@BYAPR11MB2952.namprd11.prod.outlook.com \
    --to=herakliusz.lipiec@intel.com \
    --cc=anatoly.burakov@intel.com \
    --cc=bernard.iremonger@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=hariprasad.govindharajan@intel.com \
    --cc=jingjing.wu@intel.com \
    --cc=wenzhuo.lu@intel.com \
    /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).