[RH7] vhost: do not try to access device IOTLB when not initialized

Submitted by Pavel Tikhomirov on Dec. 14, 2018, 11:52 a.m.


Message ID 20181214115237.17292-1-ptikhomirov@virtuozzo.com
State New
Series "vhost: do not try to access device IOTLB when not initialized"
Headers show

Commit Message

Pavel Tikhomirov Dec. 14, 2018, 11:52 a.m.
We have GPF when Kasan checks umem->umem_tree before dereferencing it
later in vhost_umem_interval_tree_iter_first, and it is zero.


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@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
 drivers/vhost/vhost.c | 4 ++++
 1 file changed, 4 insertions(+)

Patch hide | download patch | download mbox

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);
+		if (!dev->iotlb) {
+			ret = -EFAULT;
+			break;
+		}
 		vhost_del_umem_range(dev->iotlb, msg->iova,
 				     msg->iova + msg->size - 1);