From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by dpdk.org (Postfix) with ESMTP id 428AB322C for ; Sun, 18 Nov 2018 16:04:41 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id DFFB020E69; Sun, 18 Nov 2018 10:04:40 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sun, 18 Nov 2018 10:04:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s=mesmtp; bh=vKkJLG4sAWHqt0bKD/IvOMm5kG9H3zlQfIEdk1d5J0s=; b=UAk0/nvwr2LC mEhddKoOjcilh2G/YWXjhgr/9ccbKVu9U0icgRBs34X2+m5K+ori8SkXuJKrwhAa DzXeOPS7uVZG9bmg0b75CBUMUIkwo3efgywcQf+gib1FjJi9IWiBBd0dNxRxJkUy RTa0laA016McD9Xsy+bPjsY1UPJfYVQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=vKkJLG4sAWHqt0bKD/IvOMm5kG9H3zlQfIEdk1d5J 0s=; b=N8kQhjFSuP2LQcuEDmPqeM3DtihvwMAPtaYM7phs6/0nwz/WR7HBA9EbP L1drvRx1BVEc3B3WPxqQGyxuUNEyDbLqjkoE/JAvybqWJQ2odpX2NaodtcGDVRr0 NqjDwQO1QsV/NaInwdf07+h1WyB/remf6A6XYjZn9nBduCjbbJNvtW5CDEYn+S6l JnX7xwmmMqZRaEpLAxPNXBSry7Iu3FCHNm3WFKpxYTEFKHVO8s14dl6QHDounEXn AePg0pQnYB/EjT1lO1cB1hkc8FA43dvLGdcD2gmrl2I9LlLpAomI1HKZnhDikrLf YAsr30iJ40jfmVtcwkm3fnhABa20g== X-ME-Sender: X-ME-Proxy: Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id E5A95E405B; Sun, 18 Nov 2018 10:04:39 -0500 (EST) From: Thomas Monjalon To: Stephen Hemminger Cc: dev@dpdk.org, ferruh.yigit@intel.com Date: Sun, 18 Nov 2018 16:04:38 +0100 Message-ID: <45370656.e11tQEUeGQ@xps> In-Reply-To: <20181106214901.1392-3-stephen@networkplumber.org> References: <20181106214901.1392-1-stephen@networkplumber.org> <20181106214901.1392-3-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] [RFC 2/5] 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: , X-List-Received-Date: Sun, 18 Nov 2018 15:04:41 -0000 +Cc Ferruh 06/11/2018 22:48, Stephen Hemminger: > 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 > --- > 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 112ac51dddcc..8521fe63b0ae 100644 > --- a/drivers/bus/pci/linux/pci_uio.c > +++ b/drivers/bus/pci/linux/pci_uio.c > @@ -306,12 +306,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); > } > }