9pfs: fix offset error in v9fs_xattr_read()
PATCH v2 1/1 9pfs: fix offset error in v9fs_xattr_read()
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".
---
v2: - pass size + skip to the init_in_iov_from_pdu callback
--- hw/9pfs/9p.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
hw/9pfs/9p.c +3 -3
@@ -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);
Quoted 9 lines · Greg Kurz
The current code tries to copy
read_count' bytes starting at offsetoffset' from aread_count-sized iovec. This causesv9fs_pack()to fail with ENOBUFS.Since the PDU iovec is already partially filled with
offset' bytes, let's skip them when creatingqiov_full' and havev9fs_pack()to copy the whole of it. Moreover, this is consistent with the other places wherev9fs_init_qiov_from_pdu()is called.
Quoted 4 lines
This fixes commit "
bcb8998fac169pfs: callv9fs_init_qiov_from_pdubeforev9fs_pack".Signed-off-by Greg Kurz <[email protected]>
Quoted 30 lines
v2: - pass size + skip to the
init_in_iov_from_pducallback--- hw/9pfs/9p.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)hw/9pfs/9p.c +3
-3@@ -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);