From: Greg Kurz <groug@kaod.org>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>,
Greg Kurz <groug@kaod.org>
Subject: [Qemu-devel] [PULL 5/5] 9pfs: fix offset error in v9fs_xattr_read()
Date: Wed, 25 Jan 2017 14:48:02 +0100 [thread overview]
Message-ID: <1485352082-16830-6-git-send-email-groug@kaod.org> (raw)
In-Reply-To: <1485352082-16830-1-git-send-email-groug@kaod.org>
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".
Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
---
hw/9pfs/9p.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
index d2d028828294..138d8e825d28 100644
--- a/hw/9pfs/9p.c
+++ b/hw/9pfs/9p.c
@@ -1655,7 +1655,7 @@ static void v9fs_init_qiov_from_pdu(QEMUIOVector *qiov, V9fsPDU *pdu,
if (is_write) {
pdu->s->transport->init_out_iov_from_pdu(pdu, &iov, &niov);
} else {
- pdu->s->transport->init_in_iov_from_pdu(pdu, &iov, &niov, size);
+ pdu->s->transport->init_in_iov_from_pdu(pdu, &iov, &niov, size + skip);
}
qemu_iovec_init_external(&elem, iov, niov);
@@ -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);
+ err = v9fs_pack(qiov_full.iov, qiov_full.niov, 0,
((char *)fidp->fs.xattr.value) + off,
read_count);
qemu_iovec_destroy(&qiov_full);
--
2.7.4
next prev parent reply other threads:[~2017-01-25 13:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-25 13:47 [Qemu-devel] [PULL 0/5] 9p patches 20170125 Greg Kurz
2017-01-25 13:47 ` [Qemu-devel] [PULL 1/5] 9pfs: add missing coroutine_fn annotations Greg Kurz
2017-01-25 13:47 ` [Qemu-devel] [PULL 2/5] tests: virtio-9p: improve error reporting Greg Kurz
2017-01-25 13:48 ` [Qemu-devel] [PULL 3/5] 9pfs: fix off-by-one error in PDU free list Greg Kurz
2017-01-25 13:48 ` [Qemu-devel] [PULL 4/5] 9pfs: local: trivial cosmetic fix in pwritev op Greg Kurz
2017-01-25 13:48 ` Greg Kurz [this message]
2017-01-25 18:34 ` [Qemu-devel] [PULL 0/5] 9p patches 20170125 Peter Maydell
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=1485352082-16830-6-git-send-email-groug@kaod.org \
--to=groug@kaod.org \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=peter.maydell@linaro.org \
--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).