Skip to contentSkip to conversation

vhost: reset metadata cache when initializing new IOTLB

PATCH In review Jason Wang 2 participants 3 messages Aug 8, 2018

Subsystems (5)
lore
Share & tools
lore

Jason Wang

author
#0 lore raw

PATCH 1/1 vhost: reset metadata cache when initializing new IOTLB

We need to reset metadata cache during new IOTLB initialization, otherwise the stale pointers to previous IOTLB may be still accessed which will lead a use after free.

Reported-by [email protected]
Fixes f88949138058 ("vhost: introduce O(1) vq metadata cache")
---
 drivers/vhost/vhost.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/vhost/vhost.c +6 -3
index a502f1a..ed31145 100644
@@ -1560,9 +1560,12 @@ int vhost_init_device_iotlb(struct vhost_dev *d, bool enabled)
 	d->iotlb = niotlb;
 
 	for (i = 0; i < d->nvqs; ++i) {
-		mutex_lock(&d->vqs[i]->mutex);
-		d->vqs[i]->iotlb = niotlb;
-		mutex_unlock(&d->vqs[i]->mutex);
+		struct vhost_virtqueue *vq = d->vqs[i];
+
+		mutex_lock(&vq->mutex);
+		vq->iotlb = niotlb;
+		__vhost_vq_meta_reset(vq);
+		mutex_unlock(&vq->mutex);
 	}
 
 	vhost_umem_clean(oiotlb);
Signature · 1 line
2.7.4
maintainer
#1 lore raw

From: Jason Wang <[email protected]>
Date: Wed, 8 Aug 2018 11:43:04 +0800

Quoted 7 lines

We need to reset metadata cache during new IOTLB initialization, otherwise the stale pointers to previous IOTLB may be still accessed which will lead a use after free.

Reported-by [email protected]
Fixes f88949138058 ("vhost: introduce O(1) vq metadata cache")

Applied and queued up for -stable, thanks Jason.

maintainer
#2 lore raw
In reply to Jason Wang

From: Jason Wang <[email protected]>
Date: Wed, 8 Aug 2018 11:43:04 +0800

Quoted 7 lines

We need to reset metadata cache during new IOTLB initialization, otherwise the stale pointers to previous IOTLB may be still accessed which will lead a use after free.

Reported-by [email protected]
Fixes f88949138058 ("vhost: introduce O(1) vq metadata cache")

Applied and queued up for -stable, thanks Jason.