From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f176.google.com (mail-pf0-f176.google.com [209.85.192.176]) by dpdk.org (Postfix) with ESMTP id 8102D2BBE for ; Fri, 22 Apr 2016 18:24:23 +0200 (CEST) Received: by mail-pf0-f176.google.com with SMTP id 184so42985424pff.0 for ; Fri, 22 Apr 2016 09:24:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PlHoJYLqoNK0FpoN9BWiAicYjK67iPYXn21EU1wyGZg=; b=INPCQnCGK4dQwpVl54774S4Y6akPyKHyMWfh2KZ3jjxl8v33bJsI5dt6KPMrICxqO2 t4UoPFwNigwfex102JSGoM+P3K1QQpVIm3CslI9nyCbfxMdiEc9tQtEg4bfda3nv8PIb Pm3RMzRpDeMruJJDCzgdGdGOJJt63VbDANJ8tx2fDuH+NVmm4kL0VX08sscI5ct01sGE NP/QL469rjzxaDeYzeMoZOOmSrdjixMyBiAVH4AbUV1mDlXnxry+1f/l/GJX5PdwDjbf 7+czvA6je6RjDJiKP+aW10rEFZXYUZcOHdSDwm+75gD475jXYISUi82By1Kc3+egs8AO kjsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PlHoJYLqoNK0FpoN9BWiAicYjK67iPYXn21EU1wyGZg=; b=hxP4lJ/2EGnvg3Mb90GLYWGNe7QsOQFZRpWwrDX5A1K53hH1eIAWtEYskQAR4pdt0K 6A4vh3RXrNYlRKMO8/pmkn1lxrcV/1mHdKuBYc/jS+dob8/dCzNRICOwcfBewctf2md4 8J0Y98ewidEJ9ZYvO5tuswvm7WxasmWuvU1rL5b62YyzdgxsaEw+QDDLbNRUshY07ltw 0raYYPifcx7yKNaSyLLQpwmalEd6w6ICc4whaj3Wrn2ISv2HqDrX5uGKdpkTpduRuSA6 tk9IKLfbP9yxWtZKKEfqpViuPTT1saiPgF+hVkmWl6QTdaVFmjib0c9zpG/A/enEV6ku xV+g== X-Gm-Message-State: AOPr4FUhkvBK4no3mkNBoaeW2FzcUPTAP2Jo1QUqtWK/zULwS6Fa6lJ8NLWHZGoIpiVvXw== X-Received: by 10.98.11.78 with SMTP id t75mr29341128pfi.72.1461342262935; Fri, 22 Apr 2016 09:24:22 -0700 (PDT) Received: from xeon-e3 (static-50-53-72-186.bvtn.or.frontiernet.net. [50.53.72.186]) by smtp.gmail.com with ESMTPSA id ee5sm10628091pac.35.2016.04.22.09.24.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Apr 2016 09:24:22 -0700 (PDT) Date: Fri, 22 Apr 2016 09:24:34 -0700 From: Stephen Hemminger To: Michal Kobylinski Cc: thomas.monjalon@6wind.com, dev@dpdk.org Message-ID: <20160422092434.00bc0c46@xeon-e3> In-Reply-To: <1461321858-30339-1-git-send-email-michalx.kobylinski@intel.com> References: <1461321858-30339-1-git-send-email-michalx.kobylinski@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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: Fri, 22 Apr 2016 16:24:23 -0000 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 too > 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 = ((page & 0x7fffffffffffffULL) * page_size) > + physaddr = (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