Skip to content

Commit

Permalink
vhost: fix unsafe vring addresses modifications
Browse files Browse the repository at this point in the history
This patch adds missing protection around vring_invalidate
and translate_ring_addresses calls in vhost_user_iotlb_msg.

Fixes: eefac95 ("vhost: postpone device creation until rings are mapped")
Cc: stable@dpdk.org

Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
Reviewed-by: David Marchand <david.marchand@redhat.com>
  • Loading branch information
mcoquelin committed Feb 17, 2022
1 parent b8162db commit 04c27cb
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/vhost/vhost_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -2564,8 +2564,11 @@ vhost_user_iotlb_msg(struct virtio_net **pdev,
vhost_user_iotlb_cache_insert(dev, vq, imsg->iova, vva,
len, imsg->perm);

if (is_vring_iotlb(dev, vq, imsg))
if (is_vring_iotlb(dev, vq, imsg)) {
rte_spinlock_lock(&vq->access_lock);
*pdev = dev = translate_ring_addresses(dev, i);
rte_spinlock_unlock(&vq->access_lock);
}
}
break;
case VHOST_IOTLB_INVALIDATE:
Expand All @@ -2578,8 +2581,11 @@ vhost_user_iotlb_msg(struct virtio_net **pdev,
vhost_user_iotlb_cache_remove(vq, imsg->iova,
imsg->size);

if (is_vring_iotlb(dev, vq, imsg))
if (is_vring_iotlb(dev, vq, imsg)) {
rte_spinlock_lock(&vq->access_lock);
vring_invalidate(dev, vq);
rte_spinlock_unlock(&vq->access_lock);
}
}
break;
default:
Expand Down

0 comments on commit 04c27cb

Please sign in to comment.