From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 303B3A0524; Wed, 14 Apr 2021 09:42:17 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ADDEA1616CA; Wed, 14 Apr 2021 09:42:16 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id 4516E1616B0; Wed, 14 Apr 2021 09:42:15 +0200 (CEST) IronPort-SDR: +XbJlGCFxO9yXozC3Eya6eZ/54UppkmiQXzOrTQU/Wg9z62kK+JShOtHeBYkhX0L5iI2pNElea N+kJgg7bAiXw== X-IronPort-AV: E=McAfee;i="6200,9189,9953"; a="194699625" X-IronPort-AV: E=Sophos;i="5.82,221,1613462400"; d="scan'208";a="194699625" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Apr 2021 00:42:14 -0700 IronPort-SDR: bdq8YDlOj/4agk91hVChqByuPuGHI43dCuiKae+pscdbhVzNup+0S5elZoEuP6gZ7LTl61sJeb 5dTXKMqyIfOg== X-IronPort-AV: E=Sophos;i="5.82,221,1613462400"; d="scan'208";a="461022894" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.213.205.34]) ([10.213.205.34]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Apr 2021 00:42:11 -0700 To: "Zhang, Tianfei" , Aaron Conole Cc: David Marchand , "stable@dpdk.org" , "Huang, Wei" , "Zhang, Qi Z" , "Xu, Rosen" , "dev@dpdk.org" , "Mcnamara, John" References: <20210408085151.54996-1-wei.huang@intel.com> <20210408085151.54996-2-wei.huang@intel.com> From: Ferruh Yigit X-User: ferruhy Message-ID: Date: Wed, 14 Apr 2021 08:42:07 +0100 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH v2 1/1] raw/ifpga/base: check size before assigning X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 4/14/2021 3:46 AM, Zhang, Tianfei wrote: > > >> -----Original Message----- >> From: Aaron Conole >> Sent: 2021年4月9日 22:56 >> To: Yigit, Ferruh >> Cc: David Marchand ; stable@dpdk.org; >> Zhang, Tianfei ; Huang, Wei >> ; Zhang, Qi Z ; Xu, Rosen >> ; dev@dpdk.org; Mcnamara, John >> >> Subject: Re: [PATCH v2 1/1] raw/ifpga/base: check size before assigning >> >> Ferruh Yigit writes: >> >>> On 4/8/2021 9:51 AM, Wei Huang wrote: >>>> In max10_staging_area_init(), variable "size" from fdt_get_reg() may >>>> be invalid, it should be checked before assigning to member variable >>>> "staging_area_size" of structure "intel_max10_device". >>>> >>>> Coverity issue: 367480, 367482 >>>> Fixes: 96ebfcf8125c ("raw/ifpga/base: add SPI and MAX10 device >>>> driver") >>>> >>>> Signed-off-by: Wei Huang >>>> --- >>>> v2: check size before assigning to staging_area_size >>>> --- >>>> drivers/raw/ifpga/base/opae_intel_max10.c | 2 +- >>>> drivers/raw/ifpga/base/opae_intel_max10.h | 1 + >>>> 2 files changed, 2 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/drivers/raw/ifpga/base/opae_intel_max10.c >>>> b/drivers/raw/ifpga/base/opae_intel_max10.c >>>> index 443e248fb3..c223fafa03 100644 >>>> --- a/drivers/raw/ifpga/base/opae_intel_max10.c >>>> +++ b/drivers/raw/ifpga/base/opae_intel_max10.c >>>> @@ -593,7 +593,7 @@ static int max10_staging_area_init(struct >> intel_max10_device *dev) >>>> continue; >>>> ret = fdt_get_reg(fdt_root, offset, 0, &start, &size); >>>> -if (!ret) { >>>> +if (!ret && (size <= MAX_STAGING_AREA_SIZE)) { >>>> dev->staging_area_base = start; >>>> dev->staging_area_size = size; >>>> } >>>> diff --git a/drivers/raw/ifpga/base/opae_intel_max10.h >>>> b/drivers/raw/ifpga/base/opae_intel_max10.h >>>> index 670683f017..e7142d6f0d 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_VERSIONGENMASK(31, 16) >>>> #define DFT_MAX_SIZE0x7e0000 >>>> +#define MAX_STAGING_AREA_SIZE0x3800000 >>>> int max10_reg_read(struct intel_max10_device *dev, >>>> unsigned int reg, unsigned int *val); >>>> >>> >>> Hi Aaron, David, >>> >>> The data flow is complex for this coverity issues [1], at least I >>> can't confirm that change fixes the issue. >>> >>> Are you aware of any way to confirm this coverity issue before merging it? >> >> Not generically. :-/ >> >> We need someone that understands the data flow and the coverity splat to >> know that the fix is correct. Coverity even ratelimits how many outstanding >> submissions we can post, iirc, so we don't get to push patch sets (unless we >> pay? I don't recall if there's an option for that). > > This fix is looks good for me. The fdt_get_reg() function just read out the content of some items from DTS file, > We call the libfdt library API to do this. > The Coverity just assume some attacker broken the DTS file or invoke the function with arbitrary values, it is not safety, > So this patch add some checking after the function return. > Hi Tianfei, From the CI capacity perspective, it would be better to have a way to verify Coverity fixes before merging them. For most of the Coverity fixes we can tell that patch is fixing issue by review, but for the non trivial cases like this, a way to verify patch, even it is manual etc.., would be nice, otherwise it turns out to try and see Coverity fixes. And as far as I remember we had in the past that a Coverity fix result two more new Coverity issues :) >> >>> [1] >>> https://scan4.coverity.com/reports.htm#v26325/p10075/fileInstanceId=10 >>> 0181086&defectInstanceId=14238477&mergedDefectId=367480 >