DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v1] net/softnic: fix out of bound access
@ 2020-10-19 10:50 Savinay Dharmappa
  2020-10-19 10:55 ` Dumitrescu, Cristian
  2020-10-19 11:52 ` [dpdk-dev] [PATCH v2] " Savinay Dharmappa
  0 siblings, 2 replies; 5+ messages in thread
From: Savinay Dharmappa @ 2020-10-19 10:50 UTC (permalink / raw)
  To: cristian.dumitrescu, jasvinder.singh, dev; +Cc: savinay.dharmappa

This patch fixes out of bound access of an array.

Coverity issue: 363466, 363459
Fixes: b5dfa6703d49 ("net/softnic: update subport rate dynamically")

Signed-off-by: Savinay Dharmappa <savinay.dharmappa@intel.com>
---
 drivers/net/softnic/rte_eth_softnic_tm.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/net/softnic/rte_eth_softnic_tm.c b/drivers/net/softnic/rte_eth_softnic_tm.c
index 725b0231ae..df09d62d70 100644
--- a/drivers/net/softnic/rte_eth_softnic_tm.c
+++ b/drivers/net/softnic/rte_eth_softnic_tm.c
@@ -1147,10 +1147,15 @@ update_subport_tc_rate(struct rte_eth_dev *dev,
 	struct tm_node *ns = np->parent_node;
 	uint32_t subport_id = tm_node_subport_id(dev, ns);
 	struct tm_params *t = &p->soft.tm.params;
-	uint32_t subport_profile_id = t->subport_to_profile[subport_id];
+	uint32_t subport_profile_id;
 	struct tm_shaper_profile *sp_old = tm_shaper_profile_search(dev,
 		ss->shaper_profile_id);
 
+	if (subport_id < TM_MAX_SUBPORT_PROFILE)
+		subport_profile_id = t->subport_to_profile[subport_id];
+	else
+		return -1;
+
 	/* Derive new subport configuration. */
 	memcpy(&subport_profile,
 		&p->soft.tm.params.subport_profile[subport_profile_id],
@@ -2370,7 +2375,10 @@ subport_profile_get(struct rte_eth_dev *dev, struct tm_node *np)
 	struct tm_params *t = &p->soft.tm.params;
 	uint32_t subport_id = tm_node_subport_id(dev, np->parent_node);
 
-	return &t->subport_profile[subport_id];
+	if (subport_id < TM_MAX_SUBPORT_PROFILE)
+		return &t->subport_profile[subport_id];
+	else
+		return NULL;
 }
 
 static void
@@ -3024,6 +3032,9 @@ update_subport_rate(struct rte_eth_dev *dev,
 	struct rte_sched_subport_profile_params profile1;
 	uint32_t subport_profile_id;
 
+	if (profile0 == NULL)
+		return -1;
+
 	/* Derive new pipe profile. */
 	memcpy(&profile1, profile0, sizeof(profile1));
 	profile1.tb_rate = sp->params.peak.rate;
-- 
2.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH v1] net/softnic: fix out of bound access
  2020-10-19 10:50 [dpdk-dev] [PATCH v1] net/softnic: fix out of bound access Savinay Dharmappa
@ 2020-10-19 10:55 ` Dumitrescu, Cristian
  2020-10-19 11:52 ` [dpdk-dev] [PATCH v2] " Savinay Dharmappa
  1 sibling, 0 replies; 5+ messages in thread
From: Dumitrescu, Cristian @ 2020-10-19 10:55 UTC (permalink / raw)
  To: Dharmappa, Savinay, Singh, Jasvinder, dev



> -----Original Message-----
> From: Dharmappa, Savinay <savinay.dharmappa@intel.com>
> Sent: Monday, October 19, 2020 11:50 AM
> To: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>; Singh, Jasvinder
> <jasvinder.singh@intel.com>; dev@dpdk.org
> Cc: Dharmappa, Savinay <savinay.dharmappa@intel.com>
> Subject: [PATCH v1] net/softnic: fix out of bound access
> 
> This patch fixes out of bound access of an array.
> 
> Coverity issue: 363466, 363459
> Fixes: b5dfa6703d49 ("net/softnic: update subport rate dynamically")
> 
> Signed-off-by: Savinay Dharmappa <savinay.dharmappa@intel.com>
> ---
>  drivers/net/softnic/rte_eth_softnic_tm.c | 15 +++++++++++++--
>  1 file changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/softnic/rte_eth_softnic_tm.c
> b/drivers/net/softnic/rte_eth_softnic_tm.c
> index 725b0231ae..df09d62d70 100644
> --- a/drivers/net/softnic/rte_eth_softnic_tm.c
> +++ b/drivers/net/softnic/rte_eth_softnic_tm.c
> @@ -1147,10 +1147,15 @@ update_subport_tc_rate(struct rte_eth_dev
> *dev,
>  	struct tm_node *ns = np->parent_node;
>  	uint32_t subport_id = tm_node_subport_id(dev, ns);
>  	struct tm_params *t = &p->soft.tm.params;
> -	uint32_t subport_profile_id = t->subport_to_profile[subport_id];
> +	uint32_t subport_profile_id;
>  	struct tm_shaper_profile *sp_old = tm_shaper_profile_search(dev,
>  		ss->shaper_profile_id);
> 
> +	if (subport_id < TM_MAX_SUBPORT_PROFILE)
> +		subport_profile_id = t->subport_to_profile[subport_id];
> +	else
> +		return -1;
> +


For readability purpose, please use our typical way to handle checks, which is:

	if (subport_id >= TM_MAX_SUBPORT_PROFILE)
		return -1;

	subport_profile_id = t->subport_to_profile[subport_id];


>  	/* Derive new subport configuration. */
>  	memcpy(&subport_profile,
>  		&p->soft.tm.params.subport_profile[subport_profile_id],
> @@ -2370,7 +2375,10 @@ subport_profile_get(struct rte_eth_dev *dev,
> struct tm_node *np)
>  	struct tm_params *t = &p->soft.tm.params;
>  	uint32_t subport_id = tm_node_subport_id(dev, np->parent_node);
> 
> -	return &t->subport_profile[subport_id];
> +	if (subport_id < TM_MAX_SUBPORT_PROFILE)
> +		return &t->subport_profile[subport_id];
> +	else
> +		return NULL;
>  }

Same comment here.

> 
>  static void
> @@ -3024,6 +3032,9 @@ update_subport_rate(struct rte_eth_dev *dev,
>  	struct rte_sched_subport_profile_params profile1;
>  	uint32_t subport_profile_id;
> 
> +	if (profile0 == NULL)
> +		return -1;
> +
>  	/* Derive new pipe profile. */
>  	memcpy(&profile1, profile0, sizeof(profile1));
>  	profile1.tb_rate = sp->params.peak.rate;
> --
> 2.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [dpdk-dev] [PATCH v2] net/softnic: fix out of bound access
  2020-10-19 10:50 [dpdk-dev] [PATCH v1] net/softnic: fix out of bound access Savinay Dharmappa
  2020-10-19 10:55 ` Dumitrescu, Cristian
@ 2020-10-19 11:52 ` Savinay Dharmappa
  2020-10-19 13:16   ` Dumitrescu, Cristian
  1 sibling, 1 reply; 5+ messages in thread
From: Savinay Dharmappa @ 2020-10-19 11:52 UTC (permalink / raw)
  To: cristian.dumitrescu, jasvinder.singh, dev; +Cc: savinay.dharmappa

This patch fixes out of bound access of an array.

Coverity issue: 363466, 363459
Fixes: b5dfa6703d49 ("net/softnic: update subport rate dynamically")

Signed-off-by: Savinay Dharmappa <savinay.dharmappa@intel.com>
---
v2: addressed review comments of v1
---
 drivers/net/softnic/rte_eth_softnic_tm.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/net/softnic/rte_eth_softnic_tm.c b/drivers/net/softnic/rte_eth_softnic_tm.c
index 725b0231ae..90baba15ce 100644
--- a/drivers/net/softnic/rte_eth_softnic_tm.c
+++ b/drivers/net/softnic/rte_eth_softnic_tm.c
@@ -1147,10 +1147,15 @@ update_subport_tc_rate(struct rte_eth_dev *dev,
 	struct tm_node *ns = np->parent_node;
 	uint32_t subport_id = tm_node_subport_id(dev, ns);
 	struct tm_params *t = &p->soft.tm.params;
-	uint32_t subport_profile_id = t->subport_to_profile[subport_id];
+	uint32_t subport_profile_id;
 	struct tm_shaper_profile *sp_old = tm_shaper_profile_search(dev,
 		ss->shaper_profile_id);
 
+	if (subport_id >= TM_MAX_SUBPORT_PROFILE)
+		return -1;
+
+	subport_profile_id = t->subport_to_profile[subport_id];
+
 	/* Derive new subport configuration. */
 	memcpy(&subport_profile,
 		&p->soft.tm.params.subport_profile[subport_profile_id],
@@ -2370,6 +2375,9 @@ subport_profile_get(struct rte_eth_dev *dev, struct tm_node *np)
 	struct tm_params *t = &p->soft.tm.params;
 	uint32_t subport_id = tm_node_subport_id(dev, np->parent_node);
 
+	if (subport_id >= TM_MAX_SUBPORT_PROFILE)
+		return NULL;
+
 	return &t->subport_profile[subport_id];
 }
 
@@ -3024,6 +3032,9 @@ update_subport_rate(struct rte_eth_dev *dev,
 	struct rte_sched_subport_profile_params profile1;
 	uint32_t subport_profile_id;
 
+	if (profile0 == NULL)
+		return -1;
+
 	/* Derive new pipe profile. */
 	memcpy(&profile1, profile0, sizeof(profile1));
 	profile1.tb_rate = sp->params.peak.rate;
-- 
2.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH v2] net/softnic: fix out of bound access
  2020-10-19 11:52 ` [dpdk-dev] [PATCH v2] " Savinay Dharmappa
@ 2020-10-19 13:16   ` Dumitrescu, Cristian
  2020-10-20 15:48     ` Ferruh Yigit
  0 siblings, 1 reply; 5+ messages in thread
From: Dumitrescu, Cristian @ 2020-10-19 13:16 UTC (permalink / raw)
  To: Dharmappa, Savinay, Singh, Jasvinder, dev



> -----Original Message-----
> From: Dharmappa, Savinay <savinay.dharmappa@intel.com>
> Sent: Monday, October 19, 2020 12:52 PM
> To: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>; Singh, Jasvinder
> <jasvinder.singh@intel.com>; dev@dpdk.org
> Cc: Dharmappa, Savinay <savinay.dharmappa@intel.com>
> Subject: [PATCH v2] net/softnic: fix out of bound access
> 
> This patch fixes out of bound access of an array.
> 
> Coverity issue: 363466, 363459
> Fixes: b5dfa6703d49 ("net/softnic: update subport rate dynamically")
> 
> Signed-off-by: Savinay Dharmappa <savinay.dharmappa@intel.com>
> ---
> v2: addressed review comments of v1
> ---
>  drivers/net/softnic/rte_eth_softnic_tm.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/softnic/rte_eth_softnic_tm.c
> b/drivers/net/softnic/rte_eth_softnic_tm.c
> index 725b0231ae..90baba15ce 100644
> --- a/drivers/net/softnic/rte_eth_softnic_tm.c
> +++ b/drivers/net/softnic/rte_eth_softnic_tm.c
> @@ -1147,10 +1147,15 @@ update_subport_tc_rate(struct rte_eth_dev
> *dev,
>  	struct tm_node *ns = np->parent_node;
>  	uint32_t subport_id = tm_node_subport_id(dev, ns);
>  	struct tm_params *t = &p->soft.tm.params;
> -	uint32_t subport_profile_id = t->subport_to_profile[subport_id];
> +	uint32_t subport_profile_id;
>  	struct tm_shaper_profile *sp_old = tm_shaper_profile_search(dev,
>  		ss->shaper_profile_id);
> 
> +	if (subport_id >= TM_MAX_SUBPORT_PROFILE)
> +		return -1;
> +
> +	subport_profile_id = t->subport_to_profile[subport_id];
> +
>  	/* Derive new subport configuration. */
>  	memcpy(&subport_profile,
>  		&p->soft.tm.params.subport_profile[subport_profile_id],
> @@ -2370,6 +2375,9 @@ subport_profile_get(struct rte_eth_dev *dev,
> struct tm_node *np)
>  	struct tm_params *t = &p->soft.tm.params;
>  	uint32_t subport_id = tm_node_subport_id(dev, np->parent_node);
> 
> +	if (subport_id >= TM_MAX_SUBPORT_PROFILE)
> +		return NULL;
> +
>  	return &t->subport_profile[subport_id];
>  }
> 
> @@ -3024,6 +3032,9 @@ update_subport_rate(struct rte_eth_dev *dev,
>  	struct rte_sched_subport_profile_params profile1;
>  	uint32_t subport_profile_id;
> 
> +	if (profile0 == NULL)
> +		return -1;
> +
>  	/* Derive new pipe profile. */
>  	memcpy(&profile1, profile0, sizeof(profile1));
>  	profile1.tb_rate = sp->params.peak.rate;
> --
> 2.17.1

Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH v2] net/softnic: fix out of bound access
  2020-10-19 13:16   ` Dumitrescu, Cristian
@ 2020-10-20 15:48     ` Ferruh Yigit
  0 siblings, 0 replies; 5+ messages in thread
From: Ferruh Yigit @ 2020-10-20 15:48 UTC (permalink / raw)
  To: Dumitrescu, Cristian, Dharmappa, Savinay, Singh, Jasvinder, dev

On 10/19/2020 2:16 PM, Dumitrescu, Cristian wrote:
> 
> 
>> -----Original Message-----
>> From: Dharmappa, Savinay <savinay.dharmappa@intel.com>
>> Sent: Monday, October 19, 2020 12:52 PM
>> To: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>; Singh, Jasvinder
>> <jasvinder.singh@intel.com>; dev@dpdk.org
>> Cc: Dharmappa, Savinay <savinay.dharmappa@intel.com>
>> Subject: [PATCH v2] net/softnic: fix out of bound access
>>
>> This patch fixes out of bound access of an array.
>>
>> Coverity issue: 363466, 363459
>> Fixes: b5dfa6703d49 ("net/softnic: update subport rate dynamically")
>>
>> Signed-off-by: Savinay Dharmappa <savinay.dharmappa@intel.com> >
> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
> 

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-10-20 15:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-19 10:50 [dpdk-dev] [PATCH v1] net/softnic: fix out of bound access Savinay Dharmappa
2020-10-19 10:55 ` Dumitrescu, Cristian
2020-10-19 11:52 ` [dpdk-dev] [PATCH v2] " Savinay Dharmappa
2020-10-19 13:16   ` Dumitrescu, Cristian
2020-10-20 15:48     ` Ferruh Yigit

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git