dev.dpdk.org archive mirror
 help / color / mirror / Atom feed
From: David Marchand <david.marchand@redhat.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: "Yigit, Ferruh" <ferruh.yigit@intel.com>,
	Bruce Richardson <bruce.richardson@intel.com>,
	 Gaetan Rivet <gaetan.rivet@6wind.com>, dev <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH v2] bus/pci: fix TOCTOU issue
Date: Fri, 14 Jun 2019 09:16:30 +0200	[thread overview]
Message-ID: <CAJFAV8xdkKksVRmbOFxfy8hotyNgR7SG2gxMAxDYR+4Ryuam3g@mail.gmail.com> (raw)
In-Reply-To: <20190402185105.2852-1-stephen@networkplumber.org>

On Tue, Apr 2, 2019 at 8:51 PM Stephen Hemminger <stephen@networkplumber.org>
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 <stephen@networkplumber.org>
> ---
> 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@redhat.com>

-- 
David Marchand

  reply	other threads:[~2019-06-14  7:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-02 18:51 [PATCH v2] bus/pci: fix TOCTOU issue Stephen Hemminger
2019-06-14  7:16 ` David Marchand [this message]
2019-06-14  7:35   ` [dpdk-dev] " Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAJFAV8xdkKksVRmbOFxfy8hotyNgR7SG2gxMAxDYR+4Ryuam3g@mail.gmail.com \
    --to=david.marchand@redhat.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=gaetan.rivet@6wind.com \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).