From: Greg Kurz <groug@kaod.org>
To: Stefano Stabellini <sstabellini@kernel.org>
Cc: qemu-devel@nongnu.org,
"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [PATCH] 9pfs: fix offset error in v9fs_xattr_read()
Date: Tue, 24 Jan 2017 08:41:28 +0100 [thread overview]
Message-ID: <20170124084128.2a9a14ca@bahia.lan> (raw)
In-Reply-To: <alpine.DEB.2.10.1701231200240.10192@sstabellini-ThinkPad-X260>
On Mon, 23 Jan 2017 12:20:57 -0800 (PST)
Stefano Stabellini <sstabellini@kernel.org> wrote:
> On Sat, 21 Jan 2017, Greg Kurz wrote:
> > The current code tries to copy `read_count' bytes starting at offset
> > `offset' from a `read_count`-sized iovec. This causes v9fs_pack() to
> > fail with ENOBUFS.
> >
> > Since the PDU iovec is already partially filled with `offset' bytes,
> > let's skip them when creating `qiov_full' and have v9fs_pack() to
> > copy the whole of it. Moreover, this is consistent with the other
> > places where v9fs_init_qiov_from_pdu() is called.
> >
> > This fixes commit "bcb8998fac16 9pfs: call v9fs_init_qiov_from_pdu
> > before v9fs_pack".
>
> Sorry about that!
>
>
> > Signed-off-by: Greg Kurz <groug@kaod.org>
> > ---
> > hw/9pfs/9p.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
> > index fa58877570f6..f0eef1a3ef53 100644
> > --- a/hw/9pfs/9p.c
> > +++ b/hw/9pfs/9p.c
> > @@ -1685,8 +1685,8 @@ static int v9fs_xattr_read(V9fsState *s, V9fsPDU *pdu, V9fsFidState *fidp,
> > }
> > offset += err;
> >
> > - v9fs_init_qiov_from_pdu(&qiov_full, pdu, 0, read_count, false);
> > - err = v9fs_pack(qiov_full.iov, qiov_full.niov, offset,
> > + v9fs_init_qiov_from_pdu(&qiov_full, pdu, offset, read_count, false);
>
> v9fs_init_qiov_from_pdu calls init_in_iov_from_pdu passing read_count as
> size argument. offset is not passed to init_in_iov_from_pdu, it is only
> used to initialized qiov_full.
>
> In other words, don't we need to:
>
> v9fs_init_qiov_from_pdu(&qiov_full, pdu, offset, read_count + offset, false);
>
> To make sure that qiov_full has "read_count + offset" bytes in it, and
> qiov_full is initialized skipping the first "offset" bytes?
>
If we do that then qemu_iovec_concat() will skip offset bytes and then copy
read_count + offset bytes or am I missing something ?
>
> > + err = v9fs_pack(qiov_full.iov, qiov_full.niov, 0,
> > ((char *)fidp->fs.xattr.value) + off,
> > read_count);
> > qemu_iovec_destroy(&qiov_full);
> >
next prev parent reply other threads:[~2017-01-24 7:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-21 14:27 [Qemu-devel] [PATCH] 9pfs: fix offset error in v9fs_xattr_read() Greg Kurz
2017-01-23 20:20 ` Stefano Stabellini
2017-01-24 7:41 ` Greg Kurz [this message]
2017-01-24 22:24 ` Stefano Stabellini
2017-01-24 23:10 ` Greg Kurz
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=20170124084128.2a9a14ca@bahia.lan \
--to=groug@kaod.org \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=sstabellini@kernel.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).