diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 1057ba7e3fc7..5092eed75b8f 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -1094,7 +1094,11 @@ static void vhost_propagate_workers(struct vhost_dev
*dev, int nworkers)
int i, j = 0;
for (i = nworkers; i < dev->nvqs; i++) {
- dev->vqs[i]->worker = dev->vqs[j]->worker;
+ struct vhost_worker *worker;
+
+ worker = rcu_dereference_check(dev->vqs[j]->worker,
+ lockdep_is_held(&dev->mutex));
+ __vhost_vq_attach_worker(dev->vqs[i], worker);
[Severity: Medium]
Can worker be NULL here? __vhost_vq_attach_worker() starts with
mutex_lock(&worker->mutex), so a NULL argument is a NULL pointer dereference.
vhost-vdpa calls vhost_dev_init() with use_worker=false, so no default worker is
ever attached and every vq->worker stays NULL. VHOST_SET_NWORKERS has no
use_worker check, and vhost_set_workers() only attaches new workers to
vqs[1..n-1]. vhost_propagate_workers() then reads NULL from vqs[0] and passes it
on. Before this patch the NULL was only copied, which was harmless.
A narrower case exists on use_worker devices. A killed worker leaves vq->worker
NULL, so a source vq can be NULL at propagate time.
Would returning -EINVAL from vhost_set_workers() when !dev->use_worker, and
skipping a NULL source worker here, cover both cases?
Fixed.
[ ... ]
- dev->vqs[i]->worker = worker;
+ __vhost_vq_attach_worker(dev->vqs[i], worker);
[Severity: Low]
This is a bug fix, but the commit message has no Fixes: tag. Should it include:
Fixes: 705a4b3eefde ("drivers/vhost: add ioctl to increase the number of
workers")
Don't have such hash in the kernel tree.
Added - Fixes: 1491588e71da ("drivers/vhost: add ioctl to increase the
number of workers")
_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel