Skip to content

Commit 6f3180a

Browse files
jasowangdavem330
authored andcommitted
vhost: do not try to access device IOTLB when not initialized
The code will try to access dev->iotlb when processing VHOST_IOTLB_INVALIDATE even if it was not initialized which may lead to NULL pointer dereference. Fixes this by check dev->iotlb before. Fixes: 6b1e6cc ("vhost: new device IOTLB API") Signed-off-by: Jason Wang <jasowang@redhat.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent e9cb423 commit 6f3180a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/vhost/vhost.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,6 +1015,10 @@ static int vhost_process_iotlb_msg(struct vhost_dev *dev,
10151015
vhost_iotlb_notify_vq(dev, msg);
10161016
break;
10171017
case VHOST_IOTLB_INVALIDATE:
1018+
if (!dev->iotlb) {
1019+
ret = -EFAULT;
1020+
break;
1021+
}
10181022
vhost_vq_meta_reset(dev);
10191023
vhost_del_umem_range(dev->iotlb, msg->iova,
10201024
msg->iova + msg->size - 1);

0 commit comments

Comments
 (0)