Skip to content

Commit

Permalink
vhost: Use vhost_get_used_size() in vhost_vring_set_addr()
Browse files Browse the repository at this point in the history
The open-coded computation of the used size doesn't take the event
into account when the VIRTIO_RING_F_EVENT_IDX feature is present.
Fix that by using vhost_get_used_size().

Fixes: 8ea8cf8 ("vhost: support event index")
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kurz <groug@kaod.org>
Link: https://lore.kernel.org/r/160171932300.284610.11846106312938909461.stgit@bahia.lan
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
  • Loading branch information
Greg Kurz authored and Michael S. Tsirkin committed Oct 4, 2020
1 parent 0210a8d commit 71878fa
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/vhost/vhost.c
Original file line number Diff line number Diff line change
Expand Up @@ -1519,8 +1519,7 @@ static long vhost_vring_set_addr(struct vhost_dev *d,
/* Also validate log access for used ring if enabled. */
if ((a.flags & (0x1 << VHOST_VRING_F_LOG)) &&
!log_access_ok(vq->log_base, a.log_guest_addr,
sizeof *vq->used +
vq->num * sizeof *vq->used->ring))
vhost_get_used_size(vq, vq->num)))
return -EINVAL;
}

Expand Down

0 comments on commit 71878fa

Please sign in to comment.