DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v1] raw/ifpga/base: check address before assigning
@ 2021-05-31  5:22 Wei Huang
  2021-06-01 10:56 ` Zhang, Qi Z
  0 siblings, 1 reply; 2+ messages in thread
From: Wei Huang @ 2021-05-31  5:22 UTC (permalink / raw)
  To: dev, rosen.xu, qi.z.zhang; +Cc: stable, tianfei.zhang, ferruh.yigit, Wei Huang

In max10_staging_area_init(), variable "start" from fdt_get_reg() may
be invalid, it should be checked before assigning to member variable
"staging_area_base" of structure "intel_max10_device".

Coverity issue: 367480, 367482
Fixes: a05bd1b40bde ("raw/ifpga: add FPGA RSU APIs")
Cc: stable@dpdk.org

Signed-off-by: Wei Huang <wei.huang@intel.com>
Acked-by: Tianfei Zhang <tianfei.zhang@intel.com>
---
 drivers/raw/ifpga/base/opae_intel_max10.c | 14 ++++++++++----
 drivers/raw/ifpga/base/opae_intel_max10.h |  1 +
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/raw/ifpga/base/opae_intel_max10.c b/drivers/raw/ifpga/base/opae_intel_max10.c
index c223faf..9d82fb0 100644
--- a/drivers/raw/ifpga/base/opae_intel_max10.c
+++ b/drivers/raw/ifpga/base/opae_intel_max10.c
@@ -593,10 +593,16 @@ static int max10_staging_area_init(struct intel_max10_device *dev)
 			continue;
 
 		ret = fdt_get_reg(fdt_root, offset, 0, &start, &size);
-		if (!ret && (size <= MAX_STAGING_AREA_SIZE)) {
-			dev->staging_area_base = start;
-			dev->staging_area_size = size;
-		}
+		if (ret)
+			return ret;
+
+		if ((start & 0x3) || (start > MAX_STAGING_AREA_BASE) ||
+			(size > MAX_STAGING_AREA_SIZE))
+			return -EINVAL;
+
+		dev->staging_area_base = start;
+		dev->staging_area_size = size;
+
 		return ret;
 	}
 
diff --git a/drivers/raw/ifpga/base/opae_intel_max10.h b/drivers/raw/ifpga/base/opae_intel_max10.h
index e7142d6..e761d7e 100644
--- a/drivers/raw/ifpga/base/opae_intel_max10.h
+++ b/drivers/raw/ifpga/base/opae_intel_max10.h
@@ -182,6 +182,7 @@ struct opae_retimer_status {
 #define   SBUS_VERSION			GENMASK(31, 16)
 
 #define DFT_MAX_SIZE		0x7e0000
+#define MAX_STAGING_AREA_BASE	0xffffffff
 #define MAX_STAGING_AREA_SIZE	0x3800000
 
 int max10_reg_read(struct intel_max10_device *dev,
-- 
1.8.3.1


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

* Re: [dpdk-dev] [PATCH v1] raw/ifpga/base: check address before assigning
  2021-05-31  5:22 [dpdk-dev] [PATCH v1] raw/ifpga/base: check address before assigning Wei Huang
@ 2021-06-01 10:56 ` Zhang, Qi Z
  0 siblings, 0 replies; 2+ messages in thread
From: Zhang, Qi Z @ 2021-06-01 10:56 UTC (permalink / raw)
  To: Huang, Wei, dev, Xu, Rosen; +Cc: stable, Zhang, Tianfei, Yigit, Ferruh



> -----Original Message-----
> From: Huang, Wei <wei.huang@intel.com>
> Sent: Monday, May 31, 2021 1:23 PM
> To: dev@dpdk.org; Xu, Rosen <rosen.xu@intel.com>; Zhang, Qi Z
> <qi.z.zhang@intel.com>
> Cc: stable@dpdk.org; Zhang, Tianfei <tianfei.zhang@intel.com>; Yigit, Ferruh
> <ferruh.yigit@intel.com>; Huang, Wei <wei.huang@intel.com>
> Subject: [PATCH v1] raw/ifpga/base: check address before assigning
> 
> In max10_staging_area_init(), variable "start" from fdt_get_reg() may be
> invalid, it should be checked before assigning to member variable
> "staging_area_base" of structure "intel_max10_device".
> 
> Coverity issue: 367480, 367482
> Fixes: a05bd1b40bde ("raw/ifpga: add FPGA RSU APIs")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Wei Huang <wei.huang@intel.com>
> Acked-by: Tianfei Zhang <tianfei.zhang@intel.com>

Applied to dpdk-next-net-intel.

Thanks
Qi

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

end of thread, other threads:[~2021-06-01 10:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-31  5:22 [dpdk-dev] [PATCH v1] raw/ifpga/base: check address before assigning Wei Huang
2021-06-01 10:56 ` Zhang, Qi Z

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