From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 17E1EA04DC; Mon, 19 Oct 2020 12:56:06 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F0485C97A; Mon, 19 Oct 2020 12:56:03 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id A91EAC970 for ; Mon, 19 Oct 2020 12:56:02 +0200 (CEST) IronPort-SDR: ZkhEGK3BIkBvGzkxK4i1ObfaHNusNlUycYfBt4RzFo3qkZKtK7iLZ2+3Y6y1Hyhl8/ksW0PBTM EJCo596qXReA== X-IronPort-AV: E=McAfee;i="6000,8403,9778"; a="146865009" X-IronPort-AV: E=Sophos;i="5.77,394,1596524400"; d="scan'208";a="146865009" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2020 03:56:00 -0700 IronPort-SDR: ZbKeWaINI7e44x9v3PwLGyhp0u+HNMoXjuP8sqrZLSegqrkVhCMXYcLrGWlm5Q1bEJGfDF2eyL J3gwCQu4dlBg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,394,1596524400"; d="scan'208";a="301336339" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by fmsmga008.fm.intel.com with ESMTP; 19 Oct 2020 03:56:00 -0700 Received: from fmsmsx603.amr.corp.intel.com (10.18.126.83) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Mon, 19 Oct 2020 03:55:59 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Mon, 19 Oct 2020 03:55:59 -0700 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.41) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Mon, 19 Oct 2020 03:55:58 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KIZpDCyl1zmvdqAxhsoS8813Ckyqrh7QnpvobzTXUNr+jYPmbw48p5Dt7A0qhzXGmnSnC0u0Imz7574fU5h5p2bxE2MaQAoC3PtUXUKNaauVqVEdiz7SgKpdEY1VLl4jqFnYn2wOVWr0mTAWE1/hUOrNss7TS8DcQBwa4z4q4pmz3P9eoM4nYGAvKAwtU6R3PGEO7WEUnO8x0HxomthsdrClaqCjmkHhJGOQxRsclW61iZ0UBaAMPYfu5vZKR9Q4WJwzGoGeRcLpefQdG4//l4MN5ljOXnoE0e4oJaWcEo8Hi7hdSUULy76/NQG+mprFYUCZ8cB6qLwiqNqlIwgAsA== 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=MhwI9OwySzuUZvfyGcD9cmPdH6EvhcI9d9B8rSjmbp8=; b=Pyi5yf4znpz37kpImLf4DHFhAHKdf7XtG1iKkIa5Cq+hX2O1xRFOPm0pZBxhizUhP+mxT/Zh2G3ziiqbZ8KTor+a5WOw9KPHsXdjIaX8OSkHT8ymW60vcDUYvj+tFl6rnHSjOlSTLbyh5Vlm+bY7GeqoEjS2b7mHDJLRKtbjWH69y9RUkQW8TNLMdnheg/4NTYI194m1xMCDXfFhFedBvYbo0StneTDXH5WD1Erv3HlXTUClOjy1VQsoqPronfyXsoev2uQYw8/ICqCVqr1km8h+cLdMTbHjNXTRGNgUbpc6eRe7tatGK7wNoCB1+yipYXtsjWqZpPgtLAbJK/RKZg== 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=MhwI9OwySzuUZvfyGcD9cmPdH6EvhcI9d9B8rSjmbp8=; b=P1PpIsWuyXtw4NA9ULGjZkGzl9PUqcUtrgxNimaQbZhVNcSeTQStnm9mJgdDQ1zHLXxL6XcNJrVJnmCRgcMjkrBiDyym7FGBJcnrnusrRuVKMcO8kLHoJsv7SY2ZxtYHHodMH0G5xfWii9uShsJlDyvz37EUEI5FxvYWG+Uk+Bk= Received: from CY4PR11MB1702.namprd11.prod.outlook.com (2603:10b6:903:2e::8) by CY4PR1101MB2311.namprd11.prod.outlook.com (2603:10b6:910:23::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.25; Mon, 19 Oct 2020 10:55:58 +0000 Received: from CY4PR11MB1702.namprd11.prod.outlook.com ([fe80::891f:76e1:e31e:8337]) by CY4PR11MB1702.namprd11.prod.outlook.com ([fe80::891f:76e1:e31e:8337%7]) with mapi id 15.20.3477.028; Mon, 19 Oct 2020 10:55:58 +0000 From: "Dumitrescu, Cristian" To: "Dharmappa, Savinay" , "Singh, Jasvinder" , "dev@dpdk.org" Thread-Topic: [PATCH v1] net/softnic: fix out of bound access Thread-Index: AQHWpgWkWXRPyPIqx0CQ2rckGBTiy6mewD7g Date: Mon, 19 Oct 2020 10:55:58 +0000 Message-ID: References: <20201019105004.76433-1-savinay.dharmappa@intel.com> In-Reply-To: <20201019105004.76433-1-savinay.dharmappa@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.5.1.3 dlp-reaction: no-action dlp-product: dlpe-windows 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: [109.79.102.18] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: da063fd8-e60c-495f-8bf1-08d8741d8f6b x-ms-traffictypediagnostic: CY4PR1101MB2311: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:291; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 6LQjhi+UT3m3jWcA76KlRnjO4zhaFyZK9tWzRV57tX41/AqFT/e5ferMM65PXDStV6QdByuPqogHMCJohDOmJIBeRL6sV2fFftUrR8x5yLeBwdejBcMhQvJKyqPXEmQ0xnXgV7vpZDaKkHhR7vvVaflFwNILPhWnnxfhlnsBZcLbHO3kN1Ntn/F56Z04h40xv7owIDkorMk2S2IuTyDyeOvgLh1Eu+B1NHwINcnQ0RFNyF0AclFgpqwYNQCszlZx7AZVyUq6g9nMb2OlhLVZZXXW1XRm5Hc/NJco3EqOc6fdQfRyf7dOFe3+Ud2nYvVve+och1q2OXW3nxfQXdvJDg== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CY4PR11MB1702.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(366004)(396003)(39860400002)(346002)(376002)(55016002)(83380400001)(76116006)(66556008)(64756008)(66446008)(66946007)(6506007)(9686003)(86362001)(8936002)(52536014)(26005)(66476007)(53546011)(7696005)(5660300002)(186003)(8676002)(71200400001)(478600001)(316002)(2906002)(110136005)(33656002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: lWurRayz8T0xW2351Maqdwotp6uYk1qsjHeFhx6hNHKQOZ+kwd412g15gWNFVXX5+iScU4hMnzpxWgjdJ9fjpvHRZdeHmDnJxbq7PEXt5uP7WMZF/hdqy6XllMfbXS740iitb3/v4px88863hX99AwrDfqUKYwmZaYgCxemk1ssAYzXkRS+NHV+RkMfBc+XRKlHkC2Uze2/KPH3gKZjGzBKlas7oIMul5+y3y85pqOZJzfrYdwBKXhbgBuxCNMYzTFXYzNXXMKSoWli+qiH4eXJS9OE2wWM99iiijmi/3RGjdZX6nbWdQ0hI5VVGjZPSNvfYLd5triRvoRThYWsFg1FRlo7/5t2iY9Al70oCAQ90Ozu07nutZNQ8hmL5nWdXPnvIcoJ+q1MQDU5MuETVXOEnICehiLtXMKHlWEGHkyEZDUtpBKq6D6Q2XaqBSnOBYTbz1GityDV4e9ZUjdd/hVGLe9Eq4U1vYFD8HTbhq+EPll/oCgdhiGKLgqDNTtJxK4a4OKPwoOZ4aIJQqs3LGLBlsroY1VuoHj09MiFP7JD3itHSJ+sistnKj6nrv/Jrl7w0enBWVJ8uj14w46h/Qa9IwUwMzLlBHpeHlHpyP6cGtU7dpFEcoxfIAS+61dbNn11GqR1H1ba4QmGCskZ87g== 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: CY4PR11MB1702.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: da063fd8-e60c-495f-8bf1-08d8741d8f6b X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Oct 2020 10:55:58.0909 (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: z7blRMVLVZuTY75m5Ueqa9rkoSEaU7lQmJvvS6kJsolCLun232D7brO9U0ytnbqaUNI+VeHuZOdSwfT421n7dNWUHw6WpFcCH+JMb7OrqGw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1101MB2311 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v1] net/softnic: fix out of bound access X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" > -----Original Message----- > From: Dharmappa, Savinay > Sent: Monday, October 19, 2020 11:50 AM > To: Dumitrescu, Cristian ; Singh, Jasvinde= r > ; dev@dpdk.org > Cc: Dharmappa, Savinay > Subject: [PATCH v1] net/softnic: fix out of bound access >=20 > This patch fixes out of bound access of an array. >=20 > Coverity issue: 363466, 363459 > Fixes: b5dfa6703d49 ("net/softnic: update subport rate dynamically") >=20 > Signed-off-by: Savinay Dharmappa > --- > drivers/net/softnic/rte_eth_softnic_tm.c | 15 +++++++++++++-- > 1 file changed, 13 insertions(+), 2 deletions(-) >=20 > diff --git a/drivers/net/softnic/rte_eth_softnic_tm.c > b/drivers/net/softnic/rte_eth_softnic_tm.c > index 725b0231ae..df09d62d70 100644 > --- a/drivers/net/softnic/rte_eth_softnic_tm.c > +++ b/drivers/net/softnic/rte_eth_softnic_tm.c > @@ -1147,10 +1147,15 @@ update_subport_tc_rate(struct rte_eth_dev > *dev, > struct tm_node *ns =3D np->parent_node; > uint32_t subport_id =3D tm_node_subport_id(dev, ns); > struct tm_params *t =3D &p->soft.tm.params; > - uint32_t subport_profile_id =3D t->subport_to_profile[subport_id]; > + uint32_t subport_profile_id; > struct tm_shaper_profile *sp_old =3D tm_shaper_profile_search(dev, > ss->shaper_profile_id); >=20 > + if (subport_id < TM_MAX_SUBPORT_PROFILE) > + subport_profile_id =3D t->subport_to_profile[subport_id]; > + else > + return -1; > + For readability purpose, please use our typical way to handle checks, which= is: if (subport_id >=3D TM_MAX_SUBPORT_PROFILE) return -1; subport_profile_id =3D t->subport_to_profile[subport_id]; > /* Derive new subport configuration. */ > memcpy(&subport_profile, > &p->soft.tm.params.subport_profile[subport_profile_id], > @@ -2370,7 +2375,10 @@ subport_profile_get(struct rte_eth_dev *dev, > struct tm_node *np) > struct tm_params *t =3D &p->soft.tm.params; > uint32_t subport_id =3D tm_node_subport_id(dev, np->parent_node); >=20 > - return &t->subport_profile[subport_id]; > + if (subport_id < TM_MAX_SUBPORT_PROFILE) > + return &t->subport_profile[subport_id]; > + else > + return NULL; > } Same comment here. >=20 > static void > @@ -3024,6 +3032,9 @@ update_subport_rate(struct rte_eth_dev *dev, > struct rte_sched_subport_profile_params profile1; > uint32_t subport_profile_id; >=20 > + if (profile0 =3D=3D NULL) > + return -1; > + > /* Derive new pipe profile. */ > memcpy(&profile1, profile0, sizeof(profile1)); > profile1.tb_rate =3D sp->params.peak.rate; > -- > 2.17.1