Skip to content
Commit 74ad7419 authored by Pavel Tikhomirov's avatar Pavel Tikhomirov Committed by Michael S. Tsirkin
Browse files

vhost: return EINVAL if iovecs size does not match the message size



We've failed to copy and process vhost_iotlb_msg so let userspace at
least know about it. For instance before these patch the code below runs
without any error:

int main()
{
  struct vhost_msg msg;
  struct iovec iov;
  int fd;

  fd = open("/dev/vhost-net", O_RDWR);
  if (fd == -1) {
    perror("open");
    return 1;
  }

  iov.iov_base = &msg;
  iov.iov_len = sizeof(msg)-4;

  if (writev(fd, &iov,1) == -1) {
    perror("writev");
    return 1;
  }

  return 0;
}

Signed-off-by: default avatarPavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent bf4dc0b2
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment