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 EECCBA0093 for ; Mon, 18 May 2020 07:24:58 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D7F3D1D545; Mon, 18 May 2020 07:24:58 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id A08581D182; Mon, 18 May 2020 07:24:55 +0200 (CEST) IronPort-SDR: 3Uj8ISMFEG29nA1AX+yu5pS+Mm6qsj/K05pPd521yD5Kn10JNdmJGq8mu23HFhvcDaHWaqlOIN GS7kOqgoF19A== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2020 22:24:54 -0700 IronPort-SDR: grwi8k9GRpTG5CW0fC+6CaHc6RE2lutM6ZIo015EM2UKHXvpWS0fh7Bdui7kD7nn9bEaLvV0IO f5CCLqD+H4vw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,406,1583222400"; d="scan'208";a="465640634" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga006.fm.intel.com with ESMTP; 17 May 2020 22:24:54 -0700 Received: from FMSMSX110.amr.corp.intel.com (10.18.116.10) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 17 May 2020 22:24:54 -0700 Received: from FMSEDG002.ED.cps.intel.com (10.1.192.134) by fmsmsx110.amr.corp.intel.com (10.18.116.10) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 17 May 2020 22:24:54 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.173) by edgegateway.intel.com (192.55.55.69) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 17 May 2020 22:24:54 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CetNRxM16jHIjNFSvwZHTXDh+G39hsx1CM+Sx7HyZEYXF+RrGXpaxyMq8LyYtnF6iFSuW1ALNCfgo0I74fWtR0E/8zS8a0Q39zfd/sZ0GU73RqSaa8fmhIfg7oIx/T2585Il1uzUng5sEq9kWTyFLa2cwCBWlwAULDJ3o2WBHS1miRLxM2m4hWitunMWzAqgqhFPYSr5gV9HqpEi66Kp9QkD4HWg23fqWPyaLc0+Nee2dN6J2mqfUrFjSUcJoWRxFNE3sWYdqYTORmHoKrcq/KwZPJNbykq9QIxFz6Xzm1OtzidzfuLgnXnlTCHbaz+rvBFybN+qC3qzHjPoY3GoQQ== 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=GHxkOgKydam3yHWOPOx+i9HALWb/9fDT0JEf0Iiw1Jc=; b=TuBncOO/2bMuQKmWaDReoE784V3NXYnWgE1i7fJAkTTYxXwyZuVgs4+cABASaC49l0OX3p+uk2t70mCwflDe8okE2PAQjyaJLIcYceGyTyXh72FrB2NGKZAWUMGmbnBiC2mSJOcgS1+bprFJziptwvCzURQ0ZFzhd8A904oV+PGN1/pGzytYnHbLbiE4fQZOj5Qh2NIYyjpJj3LI177aQhYNgM6x8lzQ3clLz6QZE9Nk9qip40JQpwCj8Gbd4BLCp9D+A/drdiiqdKDKg9SYUxkrosEQEdzHgwLXBqGzq5/8pYhGpi/mEAXqUn2CkwNlW68OwHAXRTIA2vKxM5PiVw== 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=GHxkOgKydam3yHWOPOx+i9HALWb/9fDT0JEf0Iiw1Jc=; b=ZtdK8RBxgREqgoyVk62eScfRWELsA7kRwnvguPu9+V9p5+7aDIMlmUCBn+l4TF4PpcAAcORwhxkEnMr2JueZjHqdrdrisVp0tmiXzmSikagMEXnXt241GRL2Fd7eN4eFtk2eiKzwrQH+pj0THUhwbksF000LBYWJfBKDeV0PiAg= Received: from MWHPR11MB1391.namprd11.prod.outlook.com (2603:10b6:300:23::15) by MWHPR11MB1966.namprd11.prod.outlook.com (2603:10b6:300:10f::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.20; Mon, 18 May 2020 05:24:51 +0000 Received: from MWHPR11MB1391.namprd11.prod.outlook.com ([fe80::c809:34b4:173b:d211]) by MWHPR11MB1391.namprd11.prod.outlook.com ([fe80::c809:34b4:173b:d211%7]) with mapi id 15.20.3000.034; Mon, 18 May 2020 05:24:51 +0000 From: "Zhao1, Wei" To: "Ye, Xiaolong" , "Guo, Jia" CC: "dev@dpdk.org" , "stable@dpdk.org" , "Xing, Beilei" Thread-Topic: [dpdk-dev] [PATCH] net/i40e: fix the security risk of wild pointer operation Thread-Index: AQHWKCap0yZxSAPjxk+kacm4+eqhC6iotMsAgAAPpwCABJOegA== Date: Mon, 18 May 2020 05:24:51 +0000 Message-ID: References: <20200512151915.105152-1-wei.zhao1@intel.com> <20200515072806.GC1064@intel.com> In-Reply-To: <20200515072806.GC1064@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNTAzODEwZjEtNTM1Mi00MTIzLTg0MWQtOGRhNGM0NmM0YWY0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiNUR4ZExUdFVTU0ZLSzlEdmlqUXpNcGVOREpXV2xPMFFLaVJESkRuVzc0U3RrbVI3YjNkbHozQ1BVWlhWZkFZeiJ9 dlp-version: 11.0.600.7 dlp-product: dlpe-windows x-ctpclassification: CTP_NT dlp-reaction: no-action 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.55.52.193] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 18807e89-1e5e-416e-93d8-08d7faebca52 x-ms-traffictypediagnostic: MWHPR11MB1966: 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:10000; x-forefront-prvs: 04073E895A x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: y1ABkMheHMzw48JCzDjBH5gO+hXgH8l9udC1yzj/8o0U44cPa2t895isrjZhGA24dSimvuEZyj/chYH9ZoPzT+EKcydWzA1EoA50/YuBlMvbpqVEALFZSeF/bZse/dPOGFxkp87cuMfQEOO49Bg7dLLjQKy9mNrMd8LER5Ys7i0BtSynMJ+eCHkuNWuokfK7DtIdxKhQP0MvWs5OOErpesId+Phg4aRC9P+yhRi5XTIRSrf3wwL5DOOvPL7DRxPsBFv5H3VJZSNMcJM7HZHD+BbBmzgHjCbCnSOgCarNeeFGHjc2biUhK/+xrmFJKKhrB9BgHoCvE8TLfCcmJeH4WLOsp3aSQCVCyvbNDdIDcjThp9K6SJYPNQvULAyhdhF6UQCz9tBhVnogUUAqa5Gy/9sr34SQx8vu0fplP0R/IbaAKfexTvs7iDOWyy9Wj8// x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR11MB1391.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(366004)(396003)(346002)(136003)(39860400002)(376002)(52536014)(55016002)(76116006)(66946007)(26005)(66476007)(66556008)(64756008)(66446008)(7696005)(8676002)(9686003)(8936002)(33656002)(6506007)(53546011)(5660300002)(15650500001)(478600001)(2906002)(86362001)(110136005)(107886003)(450100002)(316002)(54906003)(186003)(4326008)(6636002)(71200400001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: XGXu9PMPGnYImdJkxXGZNNxqfYbh+Ut7Q+77Iuo1K8vfQDuAZKCAFxOYl9c9LaKcEmZQTmKHS7xpmnxwtIx6cUknMKigL0usuAfEAAvn4XZ//ogzWyhMl4PukDL64JTHTDb5lPHZe3UoJoGPyoeFjynrjajPKRfSb9dWfedCDJ/Ler6zBSz7nJRtb2voBAxjDOaxcVtRUiOfUIToXTWAUWH5qX9kX8GDEylRaHCVZ0VcnAlz5JBIUlupraWYUIXz+3YR/YStkxuwmSVk5zLI8uEmF9f+h7GWYD7KLDqAGQph7pN51WLHLtrrYCCh5WwJXMPF2xYaOBHwj2Of/xfAK3VjmoGp7P7fLens6BPKTpgl5IyOWmxOab2Y2aO0xJ9DcWwMxw0Fjo8A45DfcfNxSvv/K7ccpKNsUoUUeH1MV9msg+LGzeqliOsLlKpEGywiTEl6Ovv84afmJ9z32nRdO1zG5rTvc7vOBJ4zKlqw1s8= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 18807e89-1e5e-416e-93d8-08d7faebca52 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 May 2020 05:24:51.3842 (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: 44dDzGvERzGjh4CVmrCuTB0gvWnXYP3Tsrl0Z1XMBNRjgz7MswX8LG/jzniDnI7Wn35ucxNXyfp2bjVCZnFYIA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1966 X-OriginatorOrg: intel.com Subject: Re: [dpdk-stable] [dpdk-dev] [PATCH] net/i40e: fix the security risk of wild pointer operation X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 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, Xiaolong & guojia > -----Original Message----- > From: Ye, Xiaolong > Sent: Friday, May 15, 2020 3:28 PM > To: Guo, Jia > Cc: Zhao1, Wei ; dev@dpdk.org; stable@dpdk.org; > Xing, Beilei > Subject: Re: [dpdk-dev] [PATCH] net/i40e: fix the security risk of wild p= ointer > operation >=20 > On 05/15, Jeff Guo wrote: > >hi, zhaowei > > > >On 5/12/2020 11:19 PM, Wei Zhao wrote: > >> In i40e PMD code of function i40e_res_pool_free(), if valid_entry is > >> freed by "rte_free(valid_entry);" in the following code: > >> > >> if (prev !=3D NULL) { > >> ........................ > >> > >> if (insert =3D=3D 1) { > >> LIST_REMOVE(valid_entry, next); > >> rte_free(valid_entry); > >> } else { > >> rte_free(valid_entry); > >> insert =3D 1; > >> } > >> } > >> > >> then the following code for pool update may still use the wild > >> pointer > >> "valid_entry": > >> > >> " pool->num_free +=3D valid_entry->len; > >> pool->num_alloc -=3D valid_entry>len; " > >> it seems to be a security bug, we should avoid this risk. > >> > >> Cc: stable@dpdk.org > >> Fixes: 4861cde46116 ("i40e: new poll mode driver") > >> > >> Signed-off-by: Wei Zhao > >> --- > >> drivers/net/i40e/i40e_ethdev.c | 6 +++--- > >> 1 file changed, 3 insertions(+), 3 deletions(-) > >> > >> diff --git a/drivers/net/i40e/i40e_ethdev.c > >> b/drivers/net/i40e/i40e_ethdev.c index 749d85f54..7f8ea5309 100644 > >> --- a/drivers/net/i40e/i40e_ethdev.c > >> +++ b/drivers/net/i40e/i40e_ethdev.c > >> @@ -4973,6 +4973,9 @@ i40e_res_pool_free(struct i40e_res_pool_info > *pool, > >> } > >> insert =3D 0; > >> + pool->num_free +=3D valid_entry->len; > >> + pool->num_alloc -=3D valid_entry->len; > >> + > > > > > >Shouldn't the pool count update after the pool->free_list updated by > >"LIST_INSERT_HEAD(&pool->free_list, valid_entry, next)"? > > > >If so, you could use a variable to restore=A0 valid_entry->len at the > >begin and use it update pool count and other place. >=20 > Either way works from function point of view, but I do agree with Jeff th= at uses > local variable to store the valid_entry->len at the beginning, and then u= pdates > the pool->num_free/num_alloc at the end. >=20 > Also I think it needs to set valid_entry to NULL after free it, it can av= oid wild > pointer case like this, if there is dereference of this pointer after set= ting it to > NULL, program would crash directly and we can solve it early. >=20 > Thanks, > Xiaolong We must update it after find the proper one in the pool->free_list at once,= if we use a local pointer to store it, The proper entry may has been freed in the following code, and merge with o= ther free resource prev or next. >=20 > > > > > >> /* Try to merge with next one*/ > >> if (next !=3D NULL) { > >> /* Merge with next one */ > >> @@ -5010,9 +5013,6 @@ i40e_res_pool_free(struct i40e_res_pool_info > *pool, > >> LIST_INSERT_HEAD(&pool->free_list, valid_entry, next); > >> } > >> - pool->num_free +=3D valid_entry->len; > >> - pool->num_alloc -=3D valid_entry->len; > >> - > >> return 0; > >> }