From: "Alex Bennée" <alex.bennee@linaro.org>
To: Yajun Wu <yajunw@nvidia.com>
Cc: qemu-devel@nongnu.org, mst@redhat.com, Parav Pandit <parav@nvidia.com>
Subject: Re: [PATCH] virtio/vhost-user: Fix wrong vhost notifier GPtrArray size
Date: Thu, 26 May 2022 08:08:31 +0100 [thread overview]
Message-ID: <874k1c22i3.fsf@linaro.org> (raw)
In-Reply-To: <20220526034851.683258-1-yajunw@nvidia.com>
Yajun Wu <yajunw@nvidia.com> writes:
> In fetch_or_create_notifier, idx begins with 0. So the GPtrArray size
> should be idx + 1 and g_ptr_array_set_size should be called with idx + 1.
>
> This wrong GPtrArray size causes fetch_or_create_notifier return an invalid
> address. Passing this invalid pointer to vhost_user_host_notifier_remove
> causes assert fail:
>
> qemu/include/qemu/int128.h:27: int128_get64: Assertion `r == a' failed.
> shutting down, reason=crashed
>
> Backends like dpdk-vdpa which sends out vhost notifier requests almost always
> hit qemu crash.
My bad. I was looking for ways to exercise this code but the internal
tests didn't do it. I guess I should look at getting a test setup for
dpdk. Anyway:
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
>
> Fixes: 503e355465 ("virtio/vhost-user: dynamically assign VhostUserHostNotifiers")
> Signed-off-by: Yajun Wu <yajunw@nvidia.com>
> Acked-by: Parav Pandit <parav@nvidia.com>
> Change-Id: I87e0f7591ca9a59d210879b260704a2d9e9d6bcd
> ---
> hw/virtio/vhost-user.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
> index b040c1ad2b..dbc690d16c 100644
> --- a/hw/virtio/vhost-user.c
> +++ b/hw/virtio/vhost-user.c
> @@ -1525,7 +1525,7 @@ static VhostUserHostNotifier *fetch_or_create_notifier(VhostUserState *u,
> {
> VhostUserHostNotifier *n = NULL;
> if (idx >= u->notifiers->len) {
> - g_ptr_array_set_size(u->notifiers, idx);
> + g_ptr_array_set_size(u->notifiers, idx + 1);
> }
>
> n = g_ptr_array_index(u->notifiers, idx);
--
Alex Bennée
next prev parent reply other threads:[~2022-05-26 7:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-26 3:48 [PATCH] virtio/vhost-user: Fix wrong vhost notifier GPtrArray size Yajun Wu
2022-05-26 7:08 ` Alex Bennée [this message]
2022-06-14 1:33 ` Yajun Wu
2022-06-15 16:56 ` Dong, Eddie
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=874k1c22i3.fsf@linaro.org \
--to=alex.bennee@linaro.org \
--cc=mst@redhat.com \
--cc=parav@nvidia.com \
--cc=qemu-devel@nongnu.org \
--cc=yajunw@nvidia.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;
as well as URLs for NNTP newsgroup(s).