Skip to content

Commit ca2c5b3

Browse files
committed
vhost: fix end of range for access_ok
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>
1 parent 816e85e commit ca2c5b3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/vhost/vhost.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,15 +1175,15 @@ static int iotlb_access_ok(struct vhost_virtqueue *vq,
11751175
{
11761176
const struct vhost_umem_node *node;
11771177
struct vhost_umem *umem = vq->iotlb;
1178-
u64 s = 0, size, orig_addr = addr;
1178+
u64 s = 0, size, orig_addr = addr, last = addr + len - 1;
11791179

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

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

0 commit comments

Comments
 (0)