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 D796EA034F for ; Thu, 1 Apr 2021 10:47:56 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B48D61410AA; Thu, 1 Apr 2021 10:47:56 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id 4DA4F40142; Thu, 1 Apr 2021 10:47:52 +0200 (CEST) IronPort-SDR: xt6RLDq7vSMMz+tGsBnUJwqE0xbTHNAUPs1OPLny3w10Sb84bJYhbzHqHcmc3x9gecQ6AjSn1M Am41vF5rnzFQ== X-IronPort-AV: E=McAfee;i="6000,8403,9940"; a="191670234" X-IronPort-AV: E=Sophos;i="5.81,296,1610438400"; d="scan'208";a="191670234" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2021 01:47:49 -0700 IronPort-SDR: nCYuTANxYWZU679/X5TladQ1w0S46hUR62a1Yyo7PVpga1/iLwC3UPVlmIV+tbVoXAs4Yx3W4Q b1yIzb5S+aiA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,296,1610438400"; d="scan'208";a="419098721" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga008.jf.intel.com with ESMTP; 01 Apr 2021 01:47:49 -0700 Received: from fmsmsx605.amr.corp.intel.com (10.18.126.85) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Thu, 1 Apr 2021 01:47:49 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2 via Frontend Transport; Thu, 1 Apr 2021 01:47:49 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.109) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2106.2; Thu, 1 Apr 2021 01:47:49 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nXCGCt4GvAcWvDmSjBNFk27wOHRKOW3We3AL0AOPsVLl2w7xIqkynOVTccViG8Vxv1u1iTD+XGqGtDWOBQ4kQBDMXcG1JL60i9pSgwhK+addsfwRh4uIR/XK/IoWIP5BwVUnHfej3K5hQittx6wFSumeWPc255lor7yPuedYC+SJAr8iKqzPUtt00hCQNO1qMaik2M3Tz2i1b3kVNVG2Zn7J/EpHkWrwG/Pc93DoceMwxVfD6f5gFLrvI1Leju6XN3Djuzzubf5S/jX9hHI+UE0KK710i6RznzzcxOgBN+lBgKhvrq0e5ebVTkJJBz41/kl92paKsRxNuaI2ksc1iQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JrUdwy22eDGwDLrgtCS27bRoZMuvhHszMLzIzjDw4ac=; b=CQ45/rDEcMzNsIuB/MxVUxaFhZ8RI5uID26G5BX92Rmz8OqgjlmuEipvGlot1vPA/98vfiJQvlbtbWWgTZwMcvqqu/192g1jv2ODyPoQDi9nuDQyYOfeQoHfWrQxv9faK9M7eIUyF8SHi6vaYrVgupSgaFiuI6j+MaT7hix+lUdFAtp1t/RuAiG8u/DeLOS9mE9DRim8PxNebF7nA+PfvKR/YbPvLOF0BnLg6rnCvc5S3838pYSNDwk2W6k9FON/lg1kG1rhSXjQbZO3GcRAyjO5YLDnFT8hOOMOPyq8pa2iVX6aRS19suitINirgKeVOVd8W492izOxesWiM2LllQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JrUdwy22eDGwDLrgtCS27bRoZMuvhHszMLzIzjDw4ac=; b=zBNi2m3sNDVS/vJD3Q8ySNGmNXEiW2Z4XJJ9eLeHfup5kKy3APLgbVpzfOEwGw6BhioCnc5i2dds31kKjozO1jkyzmJrghLv20HHLuxTq+HPb6wAT1xCaT/YQ1EOZSbO5N0q047lwN9JLIPMVoDTjHtjvpiZzRHBTxs72OCioqI= Received: from BYAPR11MB2901.namprd11.prod.outlook.com (2603:10b6:a03:91::23) by BY5PR11MB4305.namprd11.prod.outlook.com (2603:10b6:a03:1bf::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.28; Thu, 1 Apr 2021 08:47:45 +0000 Received: from BYAPR11MB2901.namprd11.prod.outlook.com ([fe80::4447:5f1e:984e:57f3]) by BYAPR11MB2901.namprd11.prod.outlook.com ([fe80::4447:5f1e:984e:57f3%3]) with mapi id 15.20.3999.028; Thu, 1 Apr 2021 08:47:45 +0000 From: "Xu, Rosen" To: "Huang, Wei" , "dev@dpdk.org" , "Zhang, Qi Z" CC: "stable@dpdk.org" , "Zhang, Tianfei" Thread-Topic: [PATCH v1 3/4] raw/ifpga/base: assign unsigned value to length Thread-Index: AQHXGwaNqB9Gb1R4OUezL6GtPBGZ+qqfcUXg Date: Thu, 1 Apr 2021 08:47:45 +0000 Message-ID: References: <1615969296-17021-1-git-send-email-wei.huang@intel.com> <1615969296-17021-4-git-send-email-wei.huang@intel.com> In-Reply-To: <1615969296-17021-4-git-send-email-wei.huang@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.102.204.51] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e8dee208-c8bb-484d-197b-08d8f4ead20f x-ms-traffictypediagnostic: BY5PR11MB4305: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:43; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 0FGGybYGyp/5yJeKyUde6C3gM9Tgw0csjTV5k/z0YhWTRtBbNhvx6qybIymjbyznWpNe8gTYyMIrpMLuuXR3cBV6znklfm9/QRYyiRPyDtvAyYOe3o0kAKKOJeTCBDVYOiLJioczYNZG6EwSX6xhHZIEbSft9y9crFG8aZKUTF1VECUVbBeQmsc84Zv0ssGsxSECKGIrCUZ6jS0tLjCyAMq7Xa4MvDDlE/diPoqtG4gNTFmkU97c7/YNbuxdpbZGOjac+wF9J1zn2hsjohO5BuK+X/YWwuEnPHohvK1zltnvZJE/ogTrXko+pYmYVeY2lRZi78cbYohLlnTyWyu7zgCmwlXh77MtFIHhiYory5Rqo1ItlssROko5kjiHGghQGyTnudVRW3hPHT8YYQ8NpUmXkzbZ2yjdBjIv8kMnz0wbYSDjyKQijgEVB7bePcf62uyPbMQDdwFONyjAW8PFQZ3bhtJb6ZDEJ8LeMo89qLmoydir7rKWTwNz1FXDmjnfWmrriKUWg+iyjN4LsP/RyFzhJFwE1FckQOt0oIOnbLCb2TeawAFAo/O1nqH4TuRs7VYHNAjVy/c3JUOnbDZvuqPw4Kwo55OW5qXj60PzmB1oO2wgX99Ubm3YEL6SPlaY/GFPRKVhShsugpPh++OOR1/9kIziO0dKl8yoprw7HQ4= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR11MB2901.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(376002)(136003)(346002)(39860400002)(366004)(396003)(38100700001)(8676002)(55016002)(9686003)(71200400001)(54906003)(110136005)(8936002)(478600001)(4326008)(53546011)(107886003)(450100002)(6506007)(7696005)(5660300002)(186003)(2906002)(26005)(76116006)(316002)(64756008)(66476007)(52536014)(66556008)(66946007)(66446008)(33656002)(83380400001)(6636002)(86362001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?1fj9/ThkeAHuPHxWGfbymcOZ3thwr3S6xgVHU1JJm9/LLSBSoFTPuH9v/N3w?= =?us-ascii?Q?YwdS+M4v/iRmAxmGXNYt27EK9wINeGFL4QRkP8KkzI7vylBZ72NvNUTlpsO4?= =?us-ascii?Q?L+0B+rYDs02b32/9GBwjWcWytsrtycH5YKwm435QEYu1GlPyLFd6Oa6KAPN2?= =?us-ascii?Q?Dk5Vm2/rZUYWAwp8AYU6BmbXEupoqvzPLsTRcIW6O9ymkC9Ccly2z+QgNu0p?= =?us-ascii?Q?xruRvcxRisxVmzkRuTWh2crb/BX38ip9/Ccv8m80Q3Izc/Z8w8uORuZHev6q?= =?us-ascii?Q?V+kr7KZeLSyfaNlTlSWK0CCkQUCmJ+yflDhOQjrBtBO3yGsq8sEQcIFt09Zg?= =?us-ascii?Q?+xay2o1lX9gYD0mHWHccBOdIglPCwJTmXrwv7y+1xvUAZ7KYRQJKoH3AuxKH?= =?us-ascii?Q?EBd0JE2ELFCg1IMIb+4gvPU1lU4/JE3YlaxLhXV2na6KU6yitB3flcnjg+aC?= =?us-ascii?Q?m2vc9EKkvmF/76JhQr4pMh8TEPxr/ksCRjJWXPG9ds+64wP60/6JMZEpRzth?= =?us-ascii?Q?CRKNRh5q3lEvopo8JSHgm5lH4MNGENMeyDls8BWbeZB4waqVfuBroeXkQ0HL?= =?us-ascii?Q?vXQsoBL7i38JbabT+lO5Jwk1XXE+cVq/gv1S1EalWn+WvY18xhlU3LfGugLU?= =?us-ascii?Q?lq88LKPe8Z13egFlrvFzVKy5JMDLt0ApPQmQ9bXljVz+1JaF5QV0E6Q98hDI?= =?us-ascii?Q?1kKO/m46SKNWK2zTzeljvppYRh4tavxX35W6CQEiVuEcVe8qDHYUpVNtWjkm?= =?us-ascii?Q?1NC2c3bTwwfj4vE0EziJ4/vJ4vnWvFifTfSj6S8pn4sA5pJBjudSTXlvIC20?= =?us-ascii?Q?7PTxvVP7b4LA7Q8LJyVNDMlJ66Enojv2D2utXLYlZnEdrK2enKSXYqfmd1Bf?= =?us-ascii?Q?yse9CJZ/GWzHkhYPPrwkmp1MD7tfGI5rnCNTVC7oly/ht0Xd531XnNJQfr3/?= =?us-ascii?Q?1qCilETwM5s3P8tutA4uRAJcR6spYQW+0HcM3yqoW/PpSS1t3OQ/rD4QGOAg?= =?us-ascii?Q?TPMzUAkF7RS73aN3IQZM9JtB4t1O02qq2cfexRyFw6mpkFX9oAxZjMA4Lnji?= =?us-ascii?Q?9nz2VFYuy/EJv2TNmglvwinixrzziOkqV7vjF8nbXVP3TCE8F4Gnei39esP0?= =?us-ascii?Q?ac+3UQdnkgXxGwpqmrsAiBMfgcnn2NTDJBk8VEfAJtatEQ1Qho7YF3VvVXKm?= =?us-ascii?Q?4hChx8/tdsD08IRySknwA538XgIhIVaBRAEYS3Y1rdivMOxLSYU5kbfQh21c?= =?us-ascii?Q?InnyfXPRY+sHXeb/exY+RaAQc5QR6Sj+c8PdryjBgFvZ9dknSJbLz6dqFuFe?= =?us-ascii?Q?SK3+xVuJIVbw4kZO3tlVbA5V?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BYAPR11MB2901.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e8dee208-c8bb-484d-197b-08d8f4ead20f X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Apr 2021 08:47:45.5635 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: mPagN8OusWiD1E6tG9pgM60LqgS5aRtGVoH8/t4x1aK0zpc1tG7Gb6t79e/XJx6YPr43fcNuPMzyB5yoL9ZQ/A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR11MB4305 X-OriginatorOrg: intel.com Subject: Re: [dpdk-stable] [PATCH v1 3/4] raw/ifpga/base: assign unsigned value to length X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, -----Original Message----- From: Huang, Wei =20 Sent: Wednesday, March 17, 2021 4:22 PM To: dev@dpdk.org; Xu, Rosen ; Zhang, Qi Z Cc: stable@dpdk.org; Zhang, Tianfei ; Huang, Wei <= wei.huang@intel.com> Subject: [PATCH v1 3/4] raw/ifpga/base: assign unsigned value to length In fpga_update_flash(), "smgr->rsu_length" is passed to a parameter that ca= nnot be negative. So return value of function "lseek" should be checked bef= ore being assigned to "smgr->rsu_length". Coverity issue: 367481 Fixes: 7a4f3993f269 ("raw/ifpga: add FPGA RSU APIs") Signed-off-by: Wei Huang --- drivers/raw/ifpga/base/ifpga_fme_rsu.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/raw/ifpga/base/ifpga_fme_rsu.c b/drivers/raw/ifpga/bas= e/ifpga_fme_rsu.c index a4cb2f54ba..79ee37c282 100644 --- a/drivers/raw/ifpga/base/ifpga_fme_rsu.c +++ b/drivers/raw/ifpga/base/ifpga_fme_rsu.c @@ -277,6 +277,7 @@ int fpga_update_flash(struct ifpga_fme_hw *fme, const c= har *image, struct ifpga_sec_mgr *smgr =3D NULL; uint32_t rsu_stat =3D 0; int fd =3D -1; + off_t len =3D 0; struct sigaction old_sigint_action; struct sigaction sa; time_t start; @@ -320,9 +321,21 @@ int fpga_update_flash(struct ifpga_fme_hw *fme, const = char *image, image, strerror(errno)); return -EIO; } - smgr->rsu_length =3D lseek(fd, 0, SEEK_END); + len =3D lseek(fd, 0, SEEK_END); close(fd); =20 + if (len < 0) { + dev_err(smgr, + "Failed to get file length of \'%s\' [e:%s]\n", + image, strerror(errno)); + return -EIO; + } + if (len =3D=3D 0) { + dev_err(smgr, "Length of file \'%s\' is invalid\n", image); + return -EINVAL; + } + smgr->rsu_length =3D len; + if (smgr->max10_dev->staging_area_size < smgr->rsu_length) { dev_err(dev, "Size of staging area is small than image length " "[%u<%u]\n", smgr->max10_dev->staging_area_size, -- 2.29.2 Acked-by: Rosen Xu