qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Alexander Duyck <alexander.h.duyck@linux.intel.com>,
	qemu-stable@nongnu.org, David Hildenbrand <david@redhat.com>
Subject: [PULL 3/9] virtio-balloon: Prevent guest from starting a report when we didn't request one
Date: Wed, 22 Jul 2020 08:09:19 -0400	[thread overview]
Message-ID: <20200722120853.9144-4-mst@redhat.com> (raw)
In-Reply-To: <20200722120853.9144-1-mst@redhat.com>

From: Alexander Duyck <alexander.h.duyck@linux.intel.com>

Based on code review it appears possible for the driver to force the device
out of a stopped state when hinting by repeating the last ID it was
provided.

Prevent this by only allowing a transition to the start state when we are
in the requested state. This way the driver is only allowed to send one
descriptor that will transition the device into the start state. All others
will leave it in the stop state once it has finished.

Fixes: c13c4153f76d ("virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT")
Acked-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Alexander Duyck <alexander.h.duyck@linux.intel.com>
Message-Id: <20200720175115.21935.99563.stgit@localhost.localdomain>
Cc: qemu-stable@nongnu.org
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/virtio/virtio-balloon.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
index e670f1e595..ce70adcc69 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
@@ -526,7 +526,8 @@ static bool get_free_page_hints(VirtIOBalloon *dev)
             ret = false;
             goto out;
         }
-        if (id == dev->free_page_report_cmd_id) {
+        if (dev->free_page_report_status == FREE_PAGE_REPORT_S_REQUESTED &&
+            id == dev->free_page_report_cmd_id) {
             dev->free_page_report_status = FREE_PAGE_REPORT_S_START;
         } else {
             /*
-- 
MST



  parent reply	other threads:[~2020-07-22 12:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-22 12:09 [PULL 0/9] acpi,virtio,pc: bugfixes Michael S. Tsirkin
2020-07-22 12:09 ` [PULL 1/9] acpi: accept byte and word access to core ACPI registers Michael S. Tsirkin
2020-07-22 12:09 ` [PULL 2/9] virtio: Drop broken and superfluous object_property_set_link() Michael S. Tsirkin
2020-07-22 12:09 ` Michael S. Tsirkin [this message]
2020-07-22 12:09 ` [PULL 4/9] virtio-balloon: Add locking to prevent possible race when starting hinting Michael S. Tsirkin
2020-07-22 12:09 ` [PULL 5/9] virtio-balloon: Replace free page hinting references to 'report' with 'hint' Michael S. Tsirkin
2020-07-22 12:09 ` [PULL 6/9] virtio: list legacy-capable devices Michael S. Tsirkin
2020-07-22 12:09 ` [PULL 7/9] virtio: verify that legacy support is not accidentally on Michael S. Tsirkin
2020-07-22 12:09 ` [PULL 8/9] intel_iommu: Use correct shift for 256 bits qi descriptor Michael S. Tsirkin
2020-07-22 12:09 ` [PULL 9/9] virtio-pci: Changed vdev to proxy for VirtIO PCI BAR callbacks Michael S. Tsirkin
2020-07-23 18:00 ` [PULL 0/9] acpi,virtio,pc: bugfixes Peter Maydell

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=20200722120853.9144-4-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=alexander.h.duyck@linux.intel.com \
    --cc=david@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.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;
as well as URLs for NNTP newsgroup(s).