diff options
author | Greg Kurz <groug@kaod.org> | 2020-10-03 13:02:03 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-10-14 12:55:46 +0300 |
commit | 3d36be053e584ce364a4dc374700ffe61944d1d1 (patch) | |
tree | 6adc1a7c7e6728d31f769b4170eb57dbe30ad64e /drivers/vhost | |
parent | 3480587d9b9d7643b618c97a2d9ba81e57ff8c53 (diff) | |
download | linux-3d36be053e584ce364a4dc374700ffe61944d1d1.tar.xz |
vhost: Use vhost_get_used_size() in vhost_vring_set_addr()
commit 71878fa46c7e3b40fa7b3f1b6e4ba3f92f1ac359 upstream.
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: 8ea8cf89e19a ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/vhost')
-rw-r--r-- | drivers/vhost/vhost.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index 2e688d57e752..5f0030e08688 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -1512,8 +1512,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; } |