From: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
To: no-reply@sashiko.virtuozzo.com, andrey.zhadchenko@virtuozzo.com
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH hci-8.1 v2 1/2] drivers/vhost: fix a use-after-free of VHOST_SET_NWORKERS workers
Date: Sun, 15 Nov 2026 12:39:01 +0100 [thread overview]
Message-ID: <da6950c7-9420-424c-aaa5-712dcce0d644@virtuozzo.com> (raw)
In-Reply-To: <010701a1dec69ac9-bf9daa4a-6cb1-4816-b5e7-cea3599a4584-000000@eu-central-1.amazonses.com>
>> 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
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-11-15 11:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 10:28 [Devel] [PATCH hci-8.1 v2 0/2] drivers/vhost/blk: add support for worker ioctls Alexander Ivanov
2026-11-15 10:28 ` [Devel] [PATCH hci-8.1 v2 1/2] drivers/vhost: fix a use-after-free of VHOST_SET_NWORKERS workers Alexander Ivanov
2026-11-15 10:35 ` no-reply
2026-11-15 11:39 ` Alexander Ivanov [this message]
2026-11-15 10:28 ` [Devel] [PATCH hci-8.1 v2 2/2] drivers/vhost/blk: add support for worker ioctls Alexander Ivanov
2026-11-15 10:35 ` no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=da6950c7-9420-424c-aaa5-712dcce0d644@virtuozzo.com \
--to=alexander.ivanov@virtuozzo.com \
--cc=andrey.zhadchenko@virtuozzo.com \
--cc=devel@openvz.org \
--cc=no-reply@sashiko.virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox