aboutsummaryrefslogtreecommitdiff
path: root/hw/9pfs/9p.h
diff options
context:
space:
mode:
authorGreg Kurz <groug@kaod.org>2020-01-20 15:11:39 +0100
committerGreg Kurz <groug@kaod.org>2020-01-20 15:11:39 +0100
commit16724a173049ac29c7b5ade741da93a0f46edff7 (patch)
tree1585a3ff4437d15c176b36a1be9f2b5ed45e583f /hw/9pfs/9p.h
parent846cf408a4c8055063f4a5a71ccf7ed030cdad30 (diff)
downloadqemu-16724a173049ac29c7b5ade741da93a0f46edff7.zip
qemu-16724a173049ac29c7b5ade741da93a0f46edff7.tar.gz
qemu-16724a173049ac29c7b5ade741da93a0f46edff7.tar.bz2
9p: init_in_iov_from_pdu can truncate the size
init_in_iov_from_pdu might not be able to allocate the full buffer size requested, which comes from the client and could be larger than the transport has available at the time of the request. Specifically, this can happen with read operations, with the client requesting a read up to the max allowed, which might be more than the transport has available at the time. Today the implementation of init_in_iov_from_pdu throws an error, both Xen and Virtio. Instead, change the V9fsTransport interface so that the size becomes a pointer and can be limited by the implementation of init_in_iov_from_pdu. Change both the Xen and Virtio implementations to set the size to the size of the buffer they managed to allocate, instead of throwing an error. However, if the allocated buffer size is less than P9_IOHDRSZ (the size of the header) still throw an error as the case is unhandable. Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com> CC: groug@kaod.org CC: anthony.perard@citrix.com CC: roman@zededa.com CC: qemu_oss@crudebyte.com [groug: fix 32-bit build] Signed-off-by: Greg Kurz <groug@kaod.org>
Diffstat (limited to 'hw/9pfs/9p.h')
-rw-r--r--hw/9pfs/9p.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/hw/9pfs/9p.h b/hw/9pfs/9p.h
index 3904f82..8d07a0b 100644
--- a/hw/9pfs/9p.h
+++ b/hw/9pfs/9p.h
@@ -425,7 +425,7 @@ struct V9fsTransport {
ssize_t (*pdu_vunmarshal)(V9fsPDU *pdu, size_t offset, const char *fmt,
va_list ap);
void (*init_in_iov_from_pdu)(V9fsPDU *pdu, struct iovec **piov,
- unsigned int *pniov, size_t size);
+ unsigned int *pniov, size_t *size);
void (*init_out_iov_from_pdu)(V9fsPDU *pdu, struct iovec **piov,
unsigned int *pniov, size_t size);
void (*push_and_notify)(V9fsPDU *pdu);