qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Greg Kurz <groug@kaod.org>, qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Felix Wilhelm <fwilhelm@ernw.de>,
	"Michael S. Tsirkin" <mst@redhat.com>, P J P <ppandit@redhat.com>,
	"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [PATCH v4 3/3] 9pfs: handle walk of ".." in the root directory
Date: Fri, 16 Sep 2016 00:22:11 +0200	[thread overview]
Message-ID: <ff03dfb0-a7af-75eb-076c-b13f86af9a88@redhat.com> (raw)
In-Reply-To: <147257719770.28515.3353821932092912758.stgit@bahia.lab.toulouse-stg.fr.ibm.com>



On 30/08/2016 20:40, Greg Kurz wrote:
> +
> +    err = fid_to_qid(pdu, fidp, &qid);
> +    if (err < 0) {
> +        goto out;
> +    }
> +
>      v9fs_path_init(&dpath);
>      v9fs_path_init(&path);

The "out" label can now be reached without having initialized dpath and
path.  This upsets Coverity (and might also cause a segfault, indeed).

The simplest fix is to move the v9fs_path_init before the fid_to_qid call.

Paolo

>      /*
> @@ -1318,16 +1334,22 @@ static void v9fs_walk(void *opaque)
>      v9fs_path_copy(&dpath, &fidp->path);
>      v9fs_path_copy(&path, &fidp->path);
>      for (name_idx = 0; name_idx < nwnames; name_idx++) {
> -        err = v9fs_co_name_to_path(pdu, &dpath, wnames[name_idx].data, &path);
> -        if (err < 0) {
> -            goto out;
> -        }
> -        err = v9fs_co_lstat(pdu, &path, &stbuf);
> -        if (err < 0) {
> -            goto out;
> +        if (not_same_qid(&pdu->s->root_qid, &qid) ||
> +            strcmp("..", wnames[name_idx].data)) {
> +            err = v9fs_co_name_to_path(pdu, &dpath, wnames[name_idx].data,
> +                                       &path);
> +            if (err < 0) {
> +                goto out;
> +            }
> +
> +            err = v9fs_co_lstat(pdu, &path, &stbuf);
> +            if (err < 0) {
> +                goto out;
> +            }
> +            stat_to_qid(&stbuf, &qid);
> +            v9fs_path_copy(&dpath, &path);
>          }
> -        stat_to_qid(&stbuf, &qids[name_idx]);
> -        v9fs_path_copy(&dpath, &path);
> +        memcpy(&qids[name_idx], &qid, sizeof(qid));
>      }
>      if (fid == newfid) {
>          BUG_ON(fidp->fid_type != P9_FID_NONE);
> diff --git a/hw/9pfs/9p.h b/hw/9pfs/9p.h
> index b4f757ab5449..a38603398ef5 100644
> --- a/hw/9pfs/9p.h
> +++ b/hw/9pfs/9p.h
> @@ -236,6 +236,7 @@ typedef struct V9fsState
>      int32_t root_fid;
>      Error *migration_blocker;
>      V9fsConf fsconf;
> +    V9fsQID root_qid;
>  } V9fsState;
>  
>  /* 9p2000.L open flags */
> 
> 
> 

      reply	other threads:[~2016-09-15 22:23 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-30 17:10 [Qemu-devel] [PATCH v4 0/3] 9pfs security fixes Greg Kurz
2016-08-30 17:11 ` [Qemu-devel] [PATCH v4 1/3] 9pfs: forbid illegal path names Greg Kurz
2016-08-30 18:03   ` Eric Blake
2016-08-30 19:27     ` Greg Kurz
2016-08-31  2:42     ` Aneesh Kumar K.V
2016-08-30 17:13 ` [Qemu-devel] [PATCH v4 2/3] 9pfs: forbid . and .. in file names Greg Kurz
2016-08-30 18:06   ` Eric Blake
2016-08-30 19:03     ` Greg Kurz
2016-08-30 18:19 ` [Qemu-devel] [PATCH v4 0/3] 9pfs security fixes Michael S. Tsirkin
2016-08-30 18:29 ` Peter Maydell
2016-08-30 19:39   ` Peter Maydell
2016-08-31  9:33     ` Greg Kurz
2016-08-30 18:40 ` [Qemu-devel] [PATCH v4 3/3] 9pfs: handle walk of ".." in the root directory Greg Kurz
2016-09-15 22:22   ` Paolo Bonzini [this message]

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=ff03dfb0-a7af-75eb-076c-b13f86af9a88@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=fwilhelm@ernw.de \
    --cc=groug@kaod.org \
    --cc=mst@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=ppandit@redhat.com \
    --cc=qemu-devel@nongnu.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).