[Devel] [PATCH RH7] vhost: do not try to access device IOTLB when not initialized
Pavel Tikhomirov
ptikhomirov at virtuozzo.com
Fri Dec 14 14:52:37 MSK 2018
We have GPF when Kasan checks umem->umem_tree before dereferencing it
later in vhost_umem_interval_tree_iter_first, and it is zero.
https://jira.sw.ru/browse/PSBM-90313
MS commit 6f3180afbb22 ("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: 6b1e6cc7855b0 ("vhost: new device IOTLB API")
Signed-off-by: Jason Wang <jasowang at redhat.com>
Acked-by: Michael S. Tsirkin <mst at redhat.com>
Signed-off-by: David S. Miller <davem at davemloft.net>
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
drivers/vhost/vhost.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 412585876c38..9828070ef279 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -997,6 +997,10 @@ static int vhost_process_iotlb_msg(struct vhost_dev *dev,
vhost_iotlb_notify_vq(dev, msg);
break;
case VHOST_IOTLB_INVALIDATE:
+ if (!dev->iotlb) {
+ ret = -EFAULT;
+ break;
+ }
vhost_vq_meta_reset(dev);
vhost_del_umem_range(dev->iotlb, msg->iova,
msg->iova + msg->size - 1);
--
2.17.1
More information about the Devel
mailing list