Skip to content

Commit

Permalink
virtio-9p: record element after sanity checks
Browse files Browse the repository at this point in the history
If the guest sends a malformed request, we end up with a dangling pointer
in V9fsVirtioState. This doesn't seem to cause any bug, but let's remove
this side effect anyway.

Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
  • Loading branch information
gkurz committed Jun 29, 2017
1 parent 453a1b2 commit 3a21fb2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion hw/9pfs/virtio-9p-device.c
Expand Up @@ -61,7 +61,6 @@ static void handle_9p_output(VirtIODevice *vdev, VirtQueue *vq)
}
QEMU_BUILD_BUG_ON(sizeof(out) != 7);

v->elems[pdu->idx] = elem;
len = iov_to_buf(elem->out_sg, elem->out_num, 0,
&out, sizeof(out));
if (len != sizeof(out)) {
Expand All @@ -70,6 +69,8 @@ static void handle_9p_output(VirtIODevice *vdev, VirtQueue *vq)
goto out_free_req;
}

v->elems[pdu->idx] = elem;

pdu_submit(pdu, &out);
}

Expand Down

0 comments on commit 3a21fb2

Please sign in to comment.