From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 4A938A00E6 for ; Fri, 14 Jun 2019 09:16:45 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 115B71D4C0; Fri, 14 Jun 2019 09:16:44 +0200 (CEST) Received: from mail-ua1-f66.google.com (mail-ua1-f66.google.com [209.85.222.66]) by dpdk.org (Postfix) with ESMTP id D12721D4BF for ; Fri, 14 Jun 2019 09:16:42 +0200 (CEST) Received: by mail-ua1-f66.google.com with SMTP id j8so586018uan.6 for ; Fri, 14 Jun 2019 00:16:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=20sf0t/tSCxSYgXeVYCATIaNiW5yYPF1He8zFDqylvE=; b=gf7d2IvF8QGYraZRVW3Vwf+u/FIdV5TQWmuQBH7x+nW5Oa5yqck4mpPyZwvGqysVjX vLLB21TVgf4RX58emlnhuCQqIeXFex1q22KTclPHDQpqcTfsRhVGRot3B1ht7NvgiHCW vrMntj0aX3aihT22D3mwLlLuaLZzg/Iw3zC2DweHualWrBVjC4drGfp3bNZrJ3T6q6fe kTsJ8eMxlZ+f3nDOijIg/Y8As8gArF7TKPAncXbzdGeSbTwTMJg5qeufFkGO0VXrFDQh kWGRKo/hxmdrdqTeYpGGDcW2vrWWe2Sj941jV/u6k8i0/dOcPlHIvOqus21n77CtmKAk f9Mg== X-Gm-Message-State: APjAAAUGRY3BtdRsqz/UJu7s84cl2+wIFXw6Ldu4PWsP923vh4UVV7l0 4wBXyBb1HHMaHRuVFbgOyhqi+W2NjAScYgcDE59siA== X-Google-Smtp-Source: APXvYqyUO8DnWUvtokcomFhATb5e4d4ZwBfwnkKjfHyUiLp0hNt9eAPMc+gZZefywUEvX05JGCkPg3cpgk5STWdxei0= X-Received: by 2002:ab0:1388:: with SMTP id m8mr33554657uae.53.1560496601952; Fri, 14 Jun 2019 00:16:41 -0700 (PDT) MIME-Version: 1.0 References: <20190402185105.2852-1-stephen@networkplumber.org> In-Reply-To: <20190402185105.2852-1-stephen@networkplumber.org> From: David Marchand Date: Fri, 14 Jun 2019 09:16:30 +0200 Message-ID: To: Stephen Hemminger Cc: "Yigit, Ferruh" , Bruce Richardson , Gaetan Rivet , dev Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [PATCH v2] bus/pci: fix TOCTOU issue 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" On Tue, Apr 2, 2019 at 8:51 PM Stephen Hemminger wrote: > Using access followed by open causes a static analysis warning > about Time of check versus Time of use. Also, access() and > open() have different UID permission checks. > > This is not a serious problem; but easy to fix by using errno instead. > > Coverity issue: 300870 > Fixes: 4a928ef9f611 ("bus/pci: enable write combining during mapping") > Signed-off-by: Stephen Hemminger > --- > v2 - add more CC to original mail, and rebase > > drivers/bus/pci/linux/pci_uio.c | 11 +++++------ > 1 file changed, 5 insertions(+), 6 deletions(-) > > diff --git a/drivers/bus/pci/linux/pci_uio.c > b/drivers/bus/pci/linux/pci_uio.c > index 09ecbb7aad25..0d1b9aa347ba 100644 > --- a/drivers/bus/pci/linux/pci_uio.c > +++ b/drivers/bus/pci/linux/pci_uio.c > @@ -314,12 +314,11 @@ pci_uio_map_resource_by_index(struct rte_pci_device > *dev, int res_idx, > loc->domain, loc->bus, loc->devid, > loc->function, res_idx); > > - if (access(devname, R_OK|W_OK) != -1) { > - fd = open(devname, O_RDWR); > - if (fd < 0) > - RTE_LOG(INFO, EAL, "%s cannot be mapped. " > - "Fall-back to non prefetchable > mode.\n", > - devname); > + fd = open(devname, O_RDWR); > + if (fd < 0 && errno != ENOENT) { > + RTE_LOG(INFO, EAL, "%s cannot be mapped. " > + "Fall-back to non prefetchable mode.\n", > + devname); > } > } > > Reviewed-by: David Marchand -- David Marchand