DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] raw/ifpga: fix unintentional integer overflow
@ 2019-05-22  6:42 Andy Pei
  2019-05-23  2:11 ` Xu, Rosen
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Andy Pei @ 2019-05-22  6:42 UTC (permalink / raw)
  To: dev; +Cc: andy.pei, rosen.xu, stable

cast unsigned int ports_per_retimer, unsigned int nums_retimer,
unsigned int nums_fvl and unsigned int ports_per_fvl to uint64_t
before multiply operation, to avoid Unintentional integer overflow.

Coverity issue: 337924, 337926
Fixes: d1cd4eb2d48e ("raw/ifpga: support ipn3ke")
Cc: rosen.xu@intel.com
Cc: stable@dpdk.org

Signed-off-by: Andy Pei <andy.pei@intel.com>
---
 drivers/raw/ifpga_rawdev/ifpga_rawdev.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/raw/ifpga_rawdev/ifpga_rawdev.c b/drivers/raw/ifpga_rawdev/ifpga_rawdev.c
index 41be1a2..9c68666 100644
--- a/drivers/raw/ifpga_rawdev/ifpga_rawdev.c
+++ b/drivers/raw/ifpga_rawdev/ifpga_rawdev.c
@@ -494,8 +494,8 @@
 	if (!strcmp(attr_name, "LineSideLinkPortNum")) {
 		if (opae_manager_get_retimer_info(mgr, &opae_rtm_info))
 			return -1;
-		uint64_t tmp = opae_rtm_info.ports_per_retimer *
-			opae_rtm_info.nums_retimer;
+		uint64_t tmp = (uint64_t)opae_rtm_info.ports_per_retimer *
+					(uint64_t)opae_rtm_info.nums_retimer;
 		*attr_value = tmp;
 		return 0;
 	}
@@ -547,8 +547,8 @@
 	if (!strcmp(attr_name, "NICSideLinkPortNum")) {
 		if (opae_manager_get_retimer_info(mgr, &opae_rtm_info))
 			return -1;
-		uint64_t tmp = opae_rtm_info.nums_fvl *
-					opae_rtm_info.ports_per_fvl;
+		uint64_t tmp = (uint64_t)opae_rtm_info.nums_fvl *
+					(uint64_t)opae_rtm_info.ports_per_fvl;
 		*attr_value = tmp;
 		return 0;
 	}
-- 
1.8.3.1


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

* Re: [dpdk-dev] [PATCH] raw/ifpga: fix unintentional integer overflow
  2019-05-22  6:42 [dpdk-dev] [PATCH] raw/ifpga: fix unintentional integer overflow Andy Pei
@ 2019-05-23  2:11 ` Xu, Rosen
  2019-05-23  2:52   ` Pei, Andy
  2019-05-23  3:00 ` Xu, Rosen
  2019-07-04  7:16 ` Pei, Andy
  2 siblings, 1 reply; 5+ messages in thread
From: Xu, Rosen @ 2019-05-23  2:11 UTC (permalink / raw)
  To: Pei, Andy, dev; +Cc: stable

Hi Andy,

Why you sent this patch two times?

> -----Original Message-----
> From: Pei, Andy
> Sent: Wednesday, May 22, 2019 14:43
> To: dev@dpdk.org
> Cc: Pei, Andy <andy.pei@intel.com>; Xu, Rosen <rosen.xu@intel.com>;
> stable@dpdk.org
> Subject: [PATCH] raw/ifpga: fix unintentional integer overflow
> 
> cast unsigned int ports_per_retimer, unsigned int nums_retimer, unsigned
> int nums_fvl and unsigned int ports_per_fvl to uint64_t before multiply
> operation, to avoid Unintentional integer overflow.
> 
> Coverity issue: 337924, 337926
> Fixes: d1cd4eb2d48e ("raw/ifpga: support ipn3ke")
> Cc: rosen.xu@intel.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Andy Pei <andy.pei@intel.com>
> ---
>  drivers/raw/ifpga_rawdev/ifpga_rawdev.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/raw/ifpga_rawdev/ifpga_rawdev.c
> b/drivers/raw/ifpga_rawdev/ifpga_rawdev.c
> index 41be1a2..9c68666 100644
> --- a/drivers/raw/ifpga_rawdev/ifpga_rawdev.c
> +++ b/drivers/raw/ifpga_rawdev/ifpga_rawdev.c
> @@ -494,8 +494,8 @@
>  	if (!strcmp(attr_name, "LineSideLinkPortNum")) {
>  		if (opae_manager_get_retimer_info(mgr, &opae_rtm_info))
>  			return -1;
> -		uint64_t tmp = opae_rtm_info.ports_per_retimer *
> -			opae_rtm_info.nums_retimer;
> +		uint64_t tmp = (uint64_t)opae_rtm_info.ports_per_retimer *
> +
> 	(uint64_t)opae_rtm_info.nums_retimer;
>  		*attr_value = tmp;
>  		return 0;
>  	}
> @@ -547,8 +547,8 @@
>  	if (!strcmp(attr_name, "NICSideLinkPortNum")) {
>  		if (opae_manager_get_retimer_info(mgr, &opae_rtm_info))
>  			return -1;
> -		uint64_t tmp = opae_rtm_info.nums_fvl *
> -					opae_rtm_info.ports_per_fvl;
> +		uint64_t tmp = (uint64_t)opae_rtm_info.nums_fvl *
> +
> 	(uint64_t)opae_rtm_info.ports_per_fvl;
>  		*attr_value = tmp;
>  		return 0;
>  	}
> --
> 1.8.3.1


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

* Re: [dpdk-dev] [PATCH] raw/ifpga: fix unintentional integer overflow
  2019-05-23  2:11 ` Xu, Rosen
@ 2019-05-23  2:52   ` Pei, Andy
  0 siblings, 0 replies; 5+ messages in thread
From: Pei, Andy @ 2019-05-23  2:52 UTC (permalink / raw)
  To: Xu, Rosen, dev; +Cc: stable

Hi Rosen,

I use git send-email for internal check, I seems I should not cc you and stable@dpdk.

-----Original Message-----
From: Xu, Rosen 
Sent: Thursday, May 23, 2019 10:11 AM
To: Pei, Andy <andy.pei@intel.com>; dev@dpdk.org
Cc: stable@dpdk.org
Subject: RE: [PATCH] raw/ifpga: fix unintentional integer overflow

Hi Andy,

Why you sent this patch two times?

> -----Original Message-----
> From: Pei, Andy
> Sent: Wednesday, May 22, 2019 14:43
> To: dev@dpdk.org
> Cc: Pei, Andy <andy.pei@intel.com>; Xu, Rosen <rosen.xu@intel.com>; 
> stable@dpdk.org
> Subject: [PATCH] raw/ifpga: fix unintentional integer overflow
> 
> cast unsigned int ports_per_retimer, unsigned int nums_retimer, 
> unsigned int nums_fvl and unsigned int ports_per_fvl to uint64_t 
> before multiply operation, to avoid Unintentional integer overflow.
> 
> Coverity issue: 337924, 337926
> Fixes: d1cd4eb2d48e ("raw/ifpga: support ipn3ke")
> Cc: rosen.xu@intel.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Andy Pei <andy.pei@intel.com>
> ---
>  drivers/raw/ifpga_rawdev/ifpga_rawdev.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/raw/ifpga_rawdev/ifpga_rawdev.c
> b/drivers/raw/ifpga_rawdev/ifpga_rawdev.c
> index 41be1a2..9c68666 100644
> --- a/drivers/raw/ifpga_rawdev/ifpga_rawdev.c
> +++ b/drivers/raw/ifpga_rawdev/ifpga_rawdev.c
> @@ -494,8 +494,8 @@
>  	if (!strcmp(attr_name, "LineSideLinkPortNum")) {
>  		if (opae_manager_get_retimer_info(mgr, &opae_rtm_info))
>  			return -1;
> -		uint64_t tmp = opae_rtm_info.ports_per_retimer *
> -			opae_rtm_info.nums_retimer;
> +		uint64_t tmp = (uint64_t)opae_rtm_info.ports_per_retimer *
> +
> 	(uint64_t)opae_rtm_info.nums_retimer;
>  		*attr_value = tmp;
>  		return 0;
>  	}
> @@ -547,8 +547,8 @@
>  	if (!strcmp(attr_name, "NICSideLinkPortNum")) {
>  		if (opae_manager_get_retimer_info(mgr, &opae_rtm_info))
>  			return -1;
> -		uint64_t tmp = opae_rtm_info.nums_fvl *
> -					opae_rtm_info.ports_per_fvl;
> +		uint64_t tmp = (uint64_t)opae_rtm_info.nums_fvl *
> +
> 	(uint64_t)opae_rtm_info.ports_per_fvl;
>  		*attr_value = tmp;
>  		return 0;
>  	}
> --
> 1.8.3.1


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

* Re: [dpdk-dev] [PATCH] raw/ifpga: fix unintentional integer overflow
  2019-05-22  6:42 [dpdk-dev] [PATCH] raw/ifpga: fix unintentional integer overflow Andy Pei
  2019-05-23  2:11 ` Xu, Rosen
@ 2019-05-23  3:00 ` Xu, Rosen
  2019-07-04  7:16 ` Pei, Andy
  2 siblings, 0 replies; 5+ messages in thread
From: Xu, Rosen @ 2019-05-23  3:00 UTC (permalink / raw)
  To: Pei, Andy, dev; +Cc: stable

Hi,

> -----Original Message-----
> From: Pei, Andy
> Sent: Wednesday, May 22, 2019 14:43
> To: dev@dpdk.org
> Cc: Pei, Andy <andy.pei@intel.com>; Xu, Rosen <rosen.xu@intel.com>;
> stable@dpdk.org
> Subject: [PATCH] raw/ifpga: fix unintentional integer overflow
> 
> cast unsigned int ports_per_retimer, unsigned int nums_retimer, unsigned
> int nums_fvl and unsigned int ports_per_fvl to uint64_t before multiply
> operation, to avoid Unintentional integer overflow.
> 
> Coverity issue: 337924, 337926
> Fixes: d1cd4eb2d48e ("raw/ifpga: support ipn3ke")
> Cc: rosen.xu@intel.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Andy Pei <andy.pei@intel.com>
> ---
>  drivers/raw/ifpga_rawdev/ifpga_rawdev.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/raw/ifpga_rawdev/ifpga_rawdev.c
> b/drivers/raw/ifpga_rawdev/ifpga_rawdev.c
> index 41be1a2..9c68666 100644
> --- a/drivers/raw/ifpga_rawdev/ifpga_rawdev.c
> +++ b/drivers/raw/ifpga_rawdev/ifpga_rawdev.c
> @@ -494,8 +494,8 @@
>  	if (!strcmp(attr_name, "LineSideLinkPortNum")) {
>  		if (opae_manager_get_retimer_info(mgr, &opae_rtm_info))
>  			return -1;
> -		uint64_t tmp = opae_rtm_info.ports_per_retimer *
> -			opae_rtm_info.nums_retimer;
> +		uint64_t tmp = (uint64_t)opae_rtm_info.ports_per_retimer *
> +
> 	(uint64_t)opae_rtm_info.nums_retimer;
>  		*attr_value = tmp;
>  		return 0;
>  	}
> @@ -547,8 +547,8 @@
>  	if (!strcmp(attr_name, "NICSideLinkPortNum")) {
>  		if (opae_manager_get_retimer_info(mgr, &opae_rtm_info))
>  			return -1;
> -		uint64_t tmp = opae_rtm_info.nums_fvl *
> -					opae_rtm_info.ports_per_fvl;
> +		uint64_t tmp = (uint64_t)opae_rtm_info.nums_fvl *
> +
> 	(uint64_t)opae_rtm_info.ports_per_fvl;
>  		*attr_value = tmp;
>  		return 0;
>  	}
> --
> 1.8.3.1

Acked-by: Rosen Xu <rosen.xu@intel.com>

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

* Re: [dpdk-dev] [PATCH] raw/ifpga: fix unintentional integer overflow
  2019-05-22  6:42 [dpdk-dev] [PATCH] raw/ifpga: fix unintentional integer overflow Andy Pei
  2019-05-23  2:11 ` Xu, Rosen
  2019-05-23  3:00 ` Xu, Rosen
@ 2019-07-04  7:16 ` Pei, Andy
  2 siblings, 0 replies; 5+ messages in thread
From: Pei, Andy @ 2019-07-04  7:16 UTC (permalink / raw)
  To: dev; +Cc: Xu, Rosen, stable, Zhang, Qi Z

+Qi

-----Original Message-----
From: Pei, Andy 
Sent: Wednesday, May 22, 2019 2:43 PM
To: dev@dpdk.org
Cc: Pei, Andy <andy.pei@intel.com>; Xu, Rosen <rosen.xu@intel.com>; stable@dpdk.org
Subject: [PATCH] raw/ifpga: fix unintentional integer overflow

cast unsigned int ports_per_retimer, unsigned int nums_retimer, unsigned int nums_fvl and unsigned int ports_per_fvl to uint64_t before multiply operation, to avoid Unintentional integer overflow.

Coverity issue: 337924, 337926
Fixes: d1cd4eb2d48e ("raw/ifpga: support ipn3ke")
Cc: rosen.xu@intel.com
Cc: stable@dpdk.org

Signed-off-by: Andy Pei <andy.pei@intel.com>
---
 drivers/raw/ifpga_rawdev/ifpga_rawdev.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/raw/ifpga_rawdev/ifpga_rawdev.c b/drivers/raw/ifpga_rawdev/ifpga_rawdev.c
index 41be1a2..9c68666 100644
--- a/drivers/raw/ifpga_rawdev/ifpga_rawdev.c
+++ b/drivers/raw/ifpga_rawdev/ifpga_rawdev.c
@@ -494,8 +494,8 @@
 	if (!strcmp(attr_name, "LineSideLinkPortNum")) {
 		if (opae_manager_get_retimer_info(mgr, &opae_rtm_info))
 			return -1;
-		uint64_t tmp = opae_rtm_info.ports_per_retimer *
-			opae_rtm_info.nums_retimer;
+		uint64_t tmp = (uint64_t)opae_rtm_info.ports_per_retimer *
+					(uint64_t)opae_rtm_info.nums_retimer;
 		*attr_value = tmp;
 		return 0;
 	}
@@ -547,8 +547,8 @@
 	if (!strcmp(attr_name, "NICSideLinkPortNum")) {
 		if (opae_manager_get_retimer_info(mgr, &opae_rtm_info))
 			return -1;
-		uint64_t tmp = opae_rtm_info.nums_fvl *
-					opae_rtm_info.ports_per_fvl;
+		uint64_t tmp = (uint64_t)opae_rtm_info.nums_fvl *
+					(uint64_t)opae_rtm_info.ports_per_fvl;
 		*attr_value = tmp;
 		return 0;
 	}
--
1.8.3.1


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

end of thread, other threads:[~2019-07-04  7:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-22  6:42 [dpdk-dev] [PATCH] raw/ifpga: fix unintentional integer overflow Andy Pei
2019-05-23  2:11 ` Xu, Rosen
2019-05-23  2:52   ` Pei, Andy
2019-05-23  3:00 ` Xu, Rosen
2019-07-04  7:16 ` Pei, Andy

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).