From: Keir Fraser <keirf@google.com>
To: kvm@vger.kernel.org
Cc: will@kernel.org, Keir Fraser <keirf@google.com>
Subject: [PATCH kvmtool 1/2] virtio/balloon: Fix a crash when collecting stats
Date: Fri, 20 May 2022 14:37:05 +0000 [thread overview]
Message-ID: <20220520143706.550169-2-keirf@google.com> (raw)
In-Reply-To: <20220520143706.550169-1-keirf@google.com>
The collect_stats hook dereferences the stats virtio queue without
checking that it has been initialised.
Signed-off-by: Keir Fraser <keirf@google.com>
Cc: Will Deacon <will@kernel.org>
---
virtio/balloon.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/virtio/balloon.c b/virtio/balloon.c
index 8e8803f..7c7b115 100644
--- a/virtio/balloon.c
+++ b/virtio/balloon.c
@@ -126,9 +126,14 @@ static void virtio_bln_do_io(struct kvm *kvm, void *param)
static int virtio_bln__collect_stats(struct kvm *kvm)
{
+ struct virt_queue *vq = &bdev.vqs[VIRTIO_BLN_STATS];
u64 tmp;
- virt_queue__set_used_elem(&bdev.vqs[VIRTIO_BLN_STATS], bdev.cur_stat_head,
+ /* Exit if the queue is not set up. */
+ if (!vq->pfn)
+ return -ENODEV;
+
+ virt_queue__set_used_elem(vq, bdev.cur_stat_head,
sizeof(struct virtio_balloon_stat));
bdev.vdev.ops->signal_vq(kvm, &bdev.vdev, VIRTIO_BLN_STATS);
--
2.36.1.124.g0e6072fb45-goog
next prev parent reply other threads:[~2022-05-20 14:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-20 14:37 [PATCH kvmtool 0/2] Fixes for virtio_balloon stats printing Keir Fraser
2022-05-20 14:37 ` Keir Fraser [this message]
2022-05-20 14:37 ` [PATCH kvmtool 2/2] stat: Add descriptions for new virtio_balloon stat types Keir Fraser
2022-05-20 20:51 ` [PATCH kvmtool 0/2] Fixes for virtio_balloon stats printing Will Deacon
2022-05-23 14:42 ` Andre Przywara
2022-05-23 15:06 ` Keir Fraser
2022-05-23 15:13 ` Andre Przywara
2022-05-23 15:49 ` Alexandru Elisei
2022-05-23 16:35 ` Keir Fraser
2022-05-23 17:07 ` Alexandru Elisei
2022-05-23 17:39 ` Andre Przywara
2022-05-24 8:40 ` Alexandru Elisei
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=20220520143706.550169-2-keirf@google.com \
--to=keirf@google.com \
--cc=kvm@vger.kernel.org \
--cc=will@kernel.org \
/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