Revert "9p: init_in_iov_from_pdu can truncate the size"

This reverts commit 16724a1730.
It causes https://bugs.launchpad.net/bugs/1877688.

Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
Reviewed-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Message-Id: <20200521192627.15259-1-sstabellini@kernel.org>
Signed-off-by: Greg Kurz <groug@kaod.org>
This commit is contained in:
Stefano Stabellini 2020-05-21 12:26:25 -07:00 committed by Greg Kurz
parent ed463454ef
commit cf45183b71
4 changed files with 22 additions and 39 deletions

View file

@ -188,7 +188,7 @@ static void xen_9pfs_init_out_iov_from_pdu(V9fsPDU *pdu,
static void xen_9pfs_init_in_iov_from_pdu(V9fsPDU *pdu,
struct iovec **piov,
unsigned int *pniov,
size_t *size)
size_t size)
{
Xen9pfsDev *xen_9pfs = container_of(pdu->s, Xen9pfsDev, state);
Xen9pfsRing *ring = &xen_9pfs->rings[pdu->tag % xen_9pfs->num_rings];
@ -198,19 +198,16 @@ static void xen_9pfs_init_in_iov_from_pdu(V9fsPDU *pdu,
g_free(ring->sg);
ring->sg = g_new0(struct iovec, 2);
xen_9pfs_in_sg(ring, ring->sg, &num, pdu->idx, *size);
xen_9pfs_in_sg(ring, ring->sg, &num, pdu->idx, size);
buf_size = iov_size(ring->sg, num);
if (buf_size < P9_IOHDRSZ) {
xen_pv_printf(&xen_9pfs->xendev, 0, "Xen 9pfs reply type %d needs "
"%zu bytes, buffer has %zu, less than minimum\n",
pdu->id + 1, *size, buf_size);
if (buf_size < size) {
xen_pv_printf(&xen_9pfs->xendev, 0, "Xen 9pfs request type %d"
"needs %zu bytes, buffer has %zu\n", pdu->id, size,
buf_size);
xen_be_set_state(&xen_9pfs->xendev, XenbusStateClosing);
xen_9pfs_disconnect(&xen_9pfs->xendev);
}
if (buf_size < *size) {
*size = buf_size;
}
*piov = ring->sg;
*pniov = num;