Skip to content

Commit

Permalink
vhost: fix end of range for access_ok
Browse files Browse the repository at this point in the history
During access_ok checks, addr increases as we iterate over the data
structure, thus addr + len - 1 will point beyond the end of region we
are translating.  Harmless since we then verify that the region covers
addr, but let's not waste cpu cycles.

Reported-by: Koichiro Den <den@klaipeden.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Koichiro Den <den@klaipeden.com>
  • Loading branch information
Michael S. Tsirkin committed Nov 14, 2017
1 parent 816e85e commit ca2c5b3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/vhost/vhost.c
Original file line number Diff line number Diff line change
@@ -1175,15 +1175,15 @@ static int iotlb_access_ok(struct vhost_virtqueue *vq,
{
const struct vhost_umem_node *node;
struct vhost_umem *umem = vq->iotlb;
u64 s = 0, size, orig_addr = addr;
u64 s = 0, size, orig_addr = addr, last = addr + len - 1;

if (vhost_vq_meta_fetch(vq, addr, len, type))
return true;

while (len > s) {
node = vhost_umem_interval_tree_iter_first(&umem->umem_tree,
addr,
addr + len - 1);
last);
if (node == NULL || node->start > addr) {
vhost_iotlb_miss(vq, addr, access);
return false;

0 comments on commit ca2c5b3

Please sign in to comment.