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 93434A00C3; Thu, 23 Jun 2022 08:36:04 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3F48A4069D; Thu, 23 Jun 2022 08:36:04 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 55DE64069C; Thu, 23 Jun 2022 08:36:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1655966162; x=1687502162; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=aAEbYpIm5bsC+yONUI3qJ896K8x1Lh6Dcz6HGAhXijo=; b=Qj8wGWEMUAR+VsGHkbCU7Kp0IoLNZlTdNjkhwTUlO/8OFzgTlqK/F4F4 Ow7ExPo9Lmi1Z4tEsxHWYQN8TDn0BbYMNmlLbnrAxYyhY4C+Yvr+/jUuW VjQ6tdaMwNVg7ThDzReCgd6gHtvQD7EJRwMo4eIlhVcv31NgQIpiOnsAg zpW/zGxvawdYjATmNGjWIY0aF5gPTNvlO6qwWt4LxtOl79gtHZ59Afjay xta+6mBFbYOofmD0HQDVObiHNFRXfLqBn2puRoF2N2z1cN4v0c0AcwX5S B3ApQMkSv4CkpG6PGubBx677MnZrZ9Ycr4oiH2xCaL/o3lt+5p2Cj1Hk3 g==; X-IronPort-AV: E=McAfee;i="6400,9594,10386"; a="281717625" X-IronPort-AV: E=Sophos;i="5.92,215,1650956400"; d="scan'208";a="281717625" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2022 23:36:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,215,1650956400"; d="scan'208";a="615464900" Received: from orsmsx604.amr.corp.intel.com ([10.22.229.17]) by orsmga008.jf.intel.com with ESMTP; 22 Jun 2022 23:36:01 -0700 Received: from orsmsx604.amr.corp.intel.com (10.22.229.17) by ORSMSX604.amr.corp.intel.com (10.22.229.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Wed, 22 Jun 2022 23:36:00 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx604.amr.corp.intel.com (10.22.229.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Wed, 22 Jun 2022 23:36:00 -0700 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (104.47.51.42) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Wed, 22 Jun 2022 23:36:00 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jkd7UEgCTmamsvI7vKM/O1k21VEnyLW2jLwotgMmtoFTfrFODgx6Iz+/xkkEQOHnvxEMH9ACv4cwX6HyyP3gixf1bEkS3Dq2S35HfL5+2TvUaMUIu/vZF2jl4F41cV8Uxt9huHL6g8dLbqL9uQxQTLfRNl15baymJ42lJvHeAfMt7Z/n6tEm9lbBt/V4PDzN2hID/CuT398DE8FLaTth3SwN3wWwoHYt6RoSniQ27kwIzl25ePyNnUR0IDHUOH4hFBmlUkVQlYVJefj6rJ/yHKVq0jXNJRY6KdO4GotjERHHyo2r5uXFMtsIljMbvsgtkYqFRlNHvDO42cToY7wLdg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7cxDcWO+yB8vExuKCNSKX/EbJvhNUl8d5hMrr2xOhRg=; b=fZ3HyqleQmdvRFwkDcB7i+uTM+ACgzvxqZyu8SyHz0Yzam9SceXLUds5ghd+WcaMCSQKQLsEq7h4tTcMpLkZ1COSjkfAJ38UNyQHCE+UNgCzI2Y/qcQ2wPSJKI/yyqR6SowKHl3d2VmNz5JIrrzR3t2yUstZbYYpR/tHanLOgcxGUdt3wmJCTTMwh/ja191pyb3fR5TGcmYyBwtqDX8gbLR+cZ43uY3OpNhnlO1Qh9EW2jObjQYn3AIEhwuRb8n/kWPNesBGO/Bo8n9AfF52Yf/fOuCOr97l9F5n0gdqLlrEzIFaYV3YT1wSXxgZtWePSG32WALDpwdG2pbgCuQ9LQ== 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 Received: from DM6PR11MB4252.namprd11.prod.outlook.com (2603:10b6:5:201::26) by MN2PR11MB3949.namprd11.prod.outlook.com (2603:10b6:208:138::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.15; Thu, 23 Jun 2022 06:35:59 +0000 Received: from DM6PR11MB4252.namprd11.prod.outlook.com ([fe80::b9d5:600c:9f13:bc96]) by DM6PR11MB4252.namprd11.prod.outlook.com ([fe80::b9d5:600c:9f13:bc96%7]) with mapi id 15.20.5353.022; Thu, 23 Jun 2022 06:35:58 +0000 From: "Xu, Rosen" To: "Huang, Wei" , "dev@dpdk.org" , "thomas@monjalon.net" , "nipun.gupta@nxp.com" , "hemant.agrawal@nxp.com" CC: "stable@dpdk.org" , "Zhang, Tianfei" , "Zhang, Qi Z" Subject: RE: [PATCH] raw/ifpga: avoid potential integer overflow Thread-Topic: [PATCH] raw/ifpga: avoid potential integer overflow Thread-Index: AQHYhq3ZYVgZFQV5uE+v8DElDNYhZK1chq7A Date: Thu, 23 Jun 2022 06:35:58 +0000 Message-ID: References: <1655953900-26199-1-git-send-email-wei.huang@intel.com> In-Reply-To: <1655953900-26199-1-git-send-email-wei.huang@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.6.500.17 dlp-reaction: no-action x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiOGExZDRkY2ItZWNkMC00Mzg5LTlhNzQtNzY4NzMzZWQyNmNlIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoieENjelVXSjcxSUY2ZjJqTGJrYmhKQU91N3JIZ0RDT1BIVkFUNGlNUjVZOUtHOUZLVXZTNklra3laMnFPNkZFcSJ9 x-ctpclassification: CTP_NT authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 84f3f0e0-d078-4469-fe0b-08da54e2a250 x-ms-traffictypediagnostic: MN2PR11MB3949:EE_ x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: q7b4lxiGm0JdA/dCByZVZz2QDsxtkUHLMx7bWXhkRzeIHXKBDjjW9oFjmtJGuAfqFvb/G8iQ9pnBRh30oqNErUHAi18i3YtAAIFEubRQcfuqx91lRuFXhK0/0Q9470f/LZ/7/6zQcSFU+oGVszxq/8sph42LQSW+f8LCX1wXHr3y/4JEse3ZMlpTbQUm07yfWPaCaWlE8Z6a6ggrPuMjNz/l4jy466JKS/p5gVvbUG7bgaae2zcCOLNY75gyJTrAjvB9RYvDXbhLVxTuqbeF/cFmbt4zG+6KGTnwZiU1hz+/CTFVhhbExRrLntF7sYi86TBm7FQESUy/MiSuM6/3d5UfYCZwXY94FG/dSBKPiOaA4kHXfSRNnHWmkKLVgQo/kjmilp5LVHbSOqYrbDkuWC/UqMkiE2/au5f+dccMigSKg7jts5oidGa6y+Bu0iVQQDEfyEI7MMpgjSIuD8NGvT0bZgA9EK9ORPI57vV4F9ksgEQ4JYK/txrNTU1t1r+AvJhRw+rhb2Gh47epFi45EcKtauNLm2ftTlGBTO0zKFUtsOa4Ttc5Cn4tdSKLxyjnDGG/n4OiFdF1xxnRVVJ4afcneP2scQJmgPmur/re27Kd8/XJ30E3RKAury4LpHHMnQomlob1JKVVXUAcf0GitTJL/Bspu3vVhLi+o3WSV2q3R9mjji7C3pxY0mdaSw1uUszKzKpjWoyCIMhHJpdj5XHyt27GRuXmpNmIt0c5dL0nVyehd58T4Fgsm6AGem8WVO4oSEj7ZBE3eWmPT6uwmQ== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR11MB4252.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(396003)(136003)(366004)(39860400002)(346002)(376002)(7696005)(71200400001)(83380400001)(82960400001)(55016003)(38070700005)(186003)(122000001)(26005)(38100700002)(52536014)(64756008)(66446008)(316002)(6506007)(4326008)(5660300002)(478600001)(8936002)(2906002)(54906003)(41300700001)(66476007)(33656002)(110136005)(76116006)(8676002)(107886003)(66556008)(66946007)(9686003)(53546011)(86362001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: kdbAB77PnZ2Lm64iCmp8Ne2H+g0JY600Fqvo8awb0U6I70ASfzMfICIeRSo9gVpzackSgnXAYFWZ6AsazgLZUSziHV48n3hbYMSTFyBAM1FyaH3uFGO1a/DV+9kxb0Z1E/LGAh/O4icA1aCql59VraFZ+xp+3Xa9aKylFWMd8OzUoHBV5Nip53TIhjIFn0bX/Xc/VKVRPafZ2pUJ4fu7P9tNaOU5s5DQ1Je/qM/vxa00GekHDMnF1+m358GDvwa/v4qRbT4ExFiH6Xh/4jXymm8xh4rKQmYTBQhXAgdcq87ekql45RSRRwS8OPoSsa3tKKOzAeP7KOobfh5CYZh4GoQPfmdqZK3o/kFdGxz3orHndzsEsBsCFZrnNIPwY6i3OVytKMSZVhx4TWMeiu7M8ebcvT1aYvC+VxXDBeBVIf/axJVbObMkDei1FUBZM9fthv7VFnowVW7E4nYlXEBgGu01xlAvnUG4gwcjDjFmEV8WrpIvsJjAadxpVGfHDErm92JMymfAB0SyvPmBzJWizkBDuBBttIv7SbcX0ITZZfwfLHbD8bg9Q89tXg46gf0csoXAuMXCVT+r9X/dfckTx7PovLmYbea2dz5n20LE8eJ/eV1lVtNX31vqvkBTUzQoGfEvw5o9GUOOYYQY7o+DBjNvcat54LfK9iug9vRT/t83foha6CzZK3+gsRSg45LcZXrJcQqR4CYODYHAjBprJdoyiSTKDkSBjsRMG6O/1NrkpV4xmdsDgoE3t9JKNXHpmhHB3ijmEJEFTji0yCWIwg== 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: DM6PR11MB4252.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 84f3f0e0-d078-4469-fe0b-08da54e2a250 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Jun 2022 06:35:58.8280 (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: KeLhkhQ7DBAUNKV9yw3GMpt+yNlECjotJT+Gkf78ho13d72BTycRNVlC8yuGBfblMFQF7cC81fXaEJCNM2EG0A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3949 X-OriginatorOrg: intel.com 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 Hi, > -----Original Message----- > From: Huang, Wei > Sent: Thursday, June 23, 2022 11:12 > To: dev@dpdk.org; thomas@monjalon.net; nipun.gupta@nxp.com; > hemant.agrawal@nxp.com > Cc: stable@dpdk.org; Xu, Rosen ; Zhang, Tianfei > ; Zhang, Qi Z ; Huang, Wei > > Subject: [PATCH] raw/ifpga: avoid potential integer overflow >=20 > Expression "tx_chunks * ctx->dma_buf_size" in dma_fpga_to_fpga() is > evaluated using 32-bit arithmetic, which would overflow potentially. Cha= nge > tx_chunks to type "uint64_t" to avoid such issue. >=20 > Coverity issue: 379203 > Fixes: 7d63899a5c19 ("raw/ifpga: add N3000 AFU driver") >=20 > Signed-off-by: Wei Huang > --- > drivers/raw/ifpga/afu_pmd_n3000.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) >=20 > diff --git a/drivers/raw/ifpga/afu_pmd_n3000.c > b/drivers/raw/ifpga/afu_pmd_n3000.c > index 8708164..5120df5 100644 > --- a/drivers/raw/ifpga/afu_pmd_n3000.c > +++ b/drivers/raw/ifpga/afu_pmd_n3000.c > @@ -1158,7 +1158,7 @@ static int dma_fpga_to_fpga(struct dma_afu_ctx > *ctx, uint64_t dst, uint64_t src, > uint64_t count_left =3D count; > uint64_t dma_chunks =3D 0; > uint64_t offset =3D 0; > - uint32_t tx_chunks =3D 0; > + uint64_t tx_chunks =3D 0; > uint64_t *tmp_buf =3D NULL; > int ret =3D 0; >=20 > @@ -1213,7 +1213,7 @@ static int dma_fpga_to_fpga(struct dma_afu_ctx > *ctx, uint64_t dst, uint64_t src, > offset =3D tx_chunks * ctx->dma_buf_size; > count_left -=3D offset; > IFPGA_RAWDEV_PMD_DEBUG("0x%"PRIx64" --> > 0x%"PRIx64 > - " (%u...0x%"PRIx64")", > + " (%"PRIu64"...0x%"PRIx64")", > src, dst, tx_chunks, count_left); > tmp_buf =3D (uint64_t *)rte_malloc(NULL, ctx->dma_buf_size, > DMA_ALIGN_BYTES); > -- > 1.8.3.1 Acked-by: Rosen Xu