From: sashiko-bot@kernel.org
To: "Karl Mehltretter" <kmehltretter@gmail.com>
Cc: "Vasily Gorbik" <gor@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
dmitry.torokhov@gmail.com, linux-input@vger.kernel.org,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
linux-s390@vger.kernel.org, "Heiko Carstens" <hca@linux.ibm.com>,
kvm@vger.kernel.org
Subject: Re: [PATCH v3 6/6] virtio_vdpa: implement synchronize_cbs()
Date: Tue, 08 Sep 2026 05:51:59 +0000 [thread overview]
Message-ID: <20260908055159.E49DF1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260908053817.26065-7-kmehltretter@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Possible Use-After-Free of virtqueue memory in callback during find_vqs error handling
--
commit 05a7e5947030bc4c942e05c96bf1d657ed426d56
Author: Karl Mehltretter <kmehltretter@gmail.com>
virtio_vdpa: implement synchronize_cbs()
virtio_vdpa relies on the core's synchronize_rcu() fallback for callback
synchronization. This commit adds an SRCU domain per device and implements
synchronize_cbs() with synchronize_srcu() to cover the callbacks regardless
of the calling context.
> diff --git a/drivers/virtio/virtio_vdpa.c b/drivers/virtio/virtio_vdpa.c
> index 6bcf4567a9292..f9559b6b2e0b6 100644
> --- a/drivers/virtio/virtio_vdpa.c
> +++ b/drivers/virtio/virtio_vdpa.c
[ ... ]
> @@ -123,8 +128,22 @@ static irqreturn_t virtio_vdpa_config_cb(void *private)
> static irqreturn_t virtio_vdpa_virtqueue_cb(void *private)
> {
> struct virtqueue *vq = private;
> + struct virtio_vdpa_device *vd_dev = to_virtio_vdpa_device(vq->vdev);
[Severity: High]
This is a pre-existing issue, but could this callback be invoked
concurrently on a freed vq, leading to a use-after-free when
dereferencing vq->vdev?
During driver probe, if virtio_vdpa_find_vqs() successfully creates some
virtqueues but fails on a subsequent one, it jumps to err_setup_vq and
calls virtio_vdpa_del_vqs():
drivers/virtio/virtio_vdpa.c:virtio_vdpa_find_vqs() {
...
err_setup_vq:
virtio_vdpa_del_vqs(vdev);
...
}
This tears down the previously created virtqueues. However, the callback is
not cleared with set_vq_cb(..., NULL), nor does it synchronize with pending
or concurrently running interrupt handlers (such as vp_vdpa_vq_handler).
Could a spurious or device-initiated interrupt occurring right before or
during vring_del_virtqueue(vq) race and cause virtio_vdpa_virtqueue_cb()
to dereference the freed vq structure when accessing vq->vdev?
> + irqreturn_t ret;
> + int idx;
> +
> + idx = srcu_read_lock(&vd_dev->cb_srcu);
> + ret = vring_interrupt(0, vq);
> + srcu_read_unlock(&vd_dev->cb_srcu, idx);
> +
> + return ret;
> +}
> +
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260908053817.26065-1-kmehltretter@gmail.com?part=6
next prev parent reply other threads:[~2026-09-08 5:52 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
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 [this message]
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=20260908055159.E49DF1F00A3A@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