From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 3A4B8532D for ; Tue, 28 Jun 2016 10:06:27 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP; 28 Jun 2016 01:06:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,540,1459839600"; d="scan'208";a="1011052863" Received: from irsmsx105.ger.corp.intel.com ([163.33.3.28]) by fmsmga002.fm.intel.com with ESMTP; 28 Jun 2016 01:06:25 -0700 Received: from irsmsx109.ger.corp.intel.com ([169.254.13.193]) by irsmsx105.ger.corp.intel.com ([169.254.7.51]) with mapi id 14.03.0248.002; Tue, 28 Jun 2016 09:06:24 +0100 From: "Jastrzebski, MichalX K" To: "david.marchand@6wind.com" CC: "thomas.monjalon@6wind.com" , "dev@dpdk.org" , Stephen Hemminger , "Kobylinski, MichalX" , "Mrzyglod, DanielX T" Thread-Topic: [dpdk-dev] [PATCH] mem: fix overflowed return value Thread-Index: AQHRnIhOj+gnmTyis0mDRji+EdYpB5+WHRUAgEmOOICAH0GfEA== Date: Tue, 28 Jun 2016 08:06:23 +0000 Message-ID: <60ABE07DBB3A454EB7FAD707B4BB158213AAF1EF@IRSMSX109.ger.corp.intel.com> References: <1461321858-30339-1-git-send-email-michalx.kobylinski@intel.com> <20160422092434.00bc0c46@xeon-e3> <7ADD74816B4C8A45B56203CBA65FE5A637791649@IRSMSX107.ger.corp.intel.com> In-Reply-To: <7ADD74816B4C8A45B56203CBA65FE5A637791649@IRSMSX107.ger.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.181] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] mem: fix overflowed return value X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Jun 2016 08:06:27 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Mrzyglod, DanielX > T > Sent: Wednesday, June 08, 2016 1:41 PM > To: Stephen Hemminger ; Kobylinski, > MichalX > Cc: thomas.monjalon@6wind.com; dev@dpdk.org; > david.marchand@6wind.com > Subject: Re: [dpdk-dev] [PATCH] mem: fix overflowed return value >=20 >=20 >=20 > >-----Original Message----- > >From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Stephen > Hemminger > >Sent: Friday, April 22, 2016 6:25 PM > >To: Kobylinski, MichalX > >Cc: thomas.monjalon@6wind.com; dev@dpdk.org > >Subject: Re: [dpdk-dev] [PATCH] mem: fix overflowed return value > > > >On Fri, 22 Apr 2016 12:44:18 +0200 > >Michal Kobylinski wrote: > > > >> Fix issue reported by Coverity. > >> > >> Coverity ID 13255: Overflowed return value: The return value will be t= oo > >> small or even negative, likely resulting in unexpected behavior in a > >> caller that uses the return value. In rte_mem_virt2phy: An integer > >> overflow occurs, with the overflowed value used as the return value of > >> the function > >> > >> Fixes: 3097de6e6bfb ("mem: get physical address of any pointer") > >> > >> Signed-off-by: Michal Kobylinski > >> --- > >> lib/librte_eal/linuxapp/eal/eal_memory.c | 2 +- > >> 1 file changed, 1 insertion(+), 1 deletion(-) > >> > >> diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c > >b/lib/librte_eal/linuxapp/eal/eal_memory.c > >> index 5b9132c..6ceca5b 100644 > >> --- a/lib/librte_eal/linuxapp/eal/eal_memory.c > >> +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c > >> @@ -195,7 +195,7 @@ rte_mem_virt2phy(const void *virtaddr) > >> * the pfn (page frame number) are bits 0-54 (see > >> * pagemap.txt in linux Documentation) > >> */ > >> - physaddr =3D ((page & 0x7fffffffffffffULL) * page_size) > >> + physaddr =3D (uint64_t)((page & 0x7fffffffffffffULL) * page_size) > >> + ((unsigned long)virtaddr % page_size); > >> close(fd); > >> return physaddr; > > > >I am not trusting any of these Coverity patches you are sending. > >It seems you think wraparound can be just fixed by casting, it can't >=20 > From my point of view it's False Possitive there is no chance that page_s= ize > will be bigger than long. > Coverity Assume that page_size may be 18446744071562067968 but it can't. >=20 > Only for glibc<2.1 we probably should change page_size =3D getpagesize();= to > page_size =3D sysconf(_SC_PAGESIZE); > May I change this Coverity to False Positive or I missed something ? What= 's > your opinion ? Hi David, What is Your opinion about classifying this defect as false/positive?=20 We would like to move forward with this work. Michal