From: sashiko-bot@kernel.org
To: "Karl Mehltretter" <kmehltretter@gmail.com>
Cc: kvm@vger.kernel.org, linux-s390@vger.kernel.org,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
dmitry.torokhov@gmail.com, linux-input@vger.kernel.org,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
"Vasily Gorbik" <gor@linux.ibm.com>,
"Heiko Carstens" <hca@linux.ibm.com>
Subject: Re: [PATCH v3 4/6] um: virtio_uml: implement synchronize_cbs()
Date: Tue, 08 Sep 2026 05:50:16 +0000 [thread overview]
Message-ID: <20260908055017.70F841F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260908053817.26065-5-kmehltretter@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Premature clearing of dynamically allocated IRQ bit in um_free_irq() causes unintended IRQ sharing and race conditions.
- [High] Resource leak and potential Use-After-Free on vhost_user_init() error path.
--
commit 88d671cc22ee3a67541ca7191122aa3e1f6d8c9f
Author: Karl Mehltretter <kmehltretter@gmail.com>
um: virtio_uml: implement synchronize_cbs()
This commit implements synchronize_cbs() for virtio_uml by using
synchronize_irq() instead of waiting for an RCU grace period. This
synchronizes with the IRQ handlers used by virtqueue callbacks.
> diff --git a/arch/um/drivers/virtio_uml.c b/arch/um/drivers/virtio_uml.c
> index 7425a8548141a..1f2e62e29a277 100644
> --- a/arch/um/drivers/virtio_uml.c
> +++ b/arch/um/drivers/virtio_uml.c
[ ... ]
> @@ -869,6 +870,14 @@ static void vu_reset(struct virtio_device *vdev)
> vu_dev->status = 0;
> }
>
> +static void vu_synchronize_cbs(struct virtio_device *vdev)
> +{
> + struct virtio_uml_device *vu_dev = to_virtio_uml_device(vdev);
> +
> + if (vu_dev->irq != UM_IRQ_ALLOC)
> + synchronize_irq(vu_dev->irq);
> +}
> +
> static void vu_del_vq(struct virtqueue *vq)
> {
> struct virtio_uml_vq_info *info = vq->priv;
[Severity: High]
This isn't a bug introduced by this patch, but it is a pre-existing issue in
the codebase.
When a virtqueue is deleted during teardown, vu_del_vq() calls
um_free_irq(vu_dev->irq, vq) to remove the callback for that specific queue.
However, looking at um_free_irq() in arch/um/kernel/irq.c, it lacks reference
counting and unconditionally clears the dynamically allocated IRQ bit:
arch/um/kernel/irq.c:um_free_irq() {
free_irq(irq, dev);
clear_bit(irq, irqs_allocated);
}
Since virtio_uml shares a single dynamically allocated IRQ (vu_dev->irq)
across multiple virtqueues and the slave request channel using IRQF_SHARED,
could this premature clearing of the IRQ bit mark it as free for global
reallocation while still in use?
It seems concurrent requests for a new dynamic IRQ from other devices could be
assigned this prematurely freed IRQ, resulting in unintended forced sharing or
-EBUSY probe failures.
[ ... ]
[Severity: High]
This is also a pre-existing issue, but there appears to be a resource leak
and potential use-after-free in the probe error path of virtio_uml.
In virtio_uml_probe(), vhost_user_init() is called. If the slave request
channel is negotiated, vhost_user_init_slave_req() creates a pipe, assigns
req_fds[0] to vu_dev->req_fd, and requests an IRQ handler via
um_request_irq_tt():
arch/um/drivers/virtio_uml.c:vhost_user_init() {
if (vu_dev->protocol_features &
BIT_ULL(VHOST_USER_PROTOCOL_F_SLAVE_REQ)) {
rc = vhost_user_init_slave_req(vu_dev);
if (rc)
return rc;
}
if (vu_dev->protocol_features &
BIT_ULL(VHOST_USER_PROTOCOL_F_MQ)) {
rc = vhost_user_get_queue_num(vu_dev, &vu_dev->max_vqs);
if (rc)
return rc;
}
If a subsequent step like vhost_user_get_queue_num() fails, it returns the
error code directly. Back in virtio_uml_probe(), the error path is taken:
arch/um/drivers/virtio_uml.c:virtio_uml_probe() {
error_init:
os_close_file(vu_dev->sock);
error_free:
kfree(vu_dev);
return rc;
}
Does this error path free vu_dev without unregistering the active IRQ
handler or closing the vu_dev->req_fd file descriptor?
If an untrusted userspace backend forces the probe to fail, could the leaked
IRQ handler subsequently fire and access the freed vu_dev memory, causing a
use-after-free?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260908053817.26065-1-kmehltretter@gmail.com?part=4
next prev parent reply other threads:[~2026-09-08 5:50 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-08 5:38 [PATCH v3 0/6] virtio: fix and add callback synchronization hooks Karl Mehltretter
2026-09-08 5:38 ` [PATCH v3 1/6] virtio_ccw: fix synchronize_cbs() after interrupt fallback Karl Mehltretter
2026-09-08 5:50 ` sashiko-bot
2026-09-08 5:38 ` [PATCH v3 2/6] virtio_ccw: always take irq_lock in the classic interrupt handler Karl Mehltretter
2026-09-08 5:51 ` sashiko-bot
2026-09-08 8:14 ` Michael S. Tsirkin
2026-09-08 5:38 ` [PATCH v3 3/6] remoteproc: implement synchronize_cbs() for virtio devices Karl Mehltretter
2026-09-08 5:54 ` sashiko-bot
2026-09-08 5:38 ` [PATCH v3 4/6] um: virtio_uml: implement synchronize_cbs() Karl Mehltretter
2026-09-08 5:50 ` sashiko-bot [this message]
2026-09-08 5:38 ` [PATCH v3 5/6] platform/mellanox: mlxbf-tmfifo: " Karl Mehltretter
2026-09-08 5:52 ` sashiko-bot
2026-09-08 5:38 ` [PATCH v3 6/6] virtio_vdpa: " Karl Mehltretter
2026-09-08 5:51 ` sashiko-bot
2026-09-08 8:31 ` Michael S. Tsirkin
2026-09-08 8:06 ` [PATCH v3 0/6] virtio: fix and add callback synchronization hooks Michael S. Tsirkin
2026-09-08 8:25 ` Michael S. Tsirkin
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=20260908055017.70F841F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=dmitry.torokhov@gmail.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=kmehltretter@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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