]> git.proxmox.com Git - mirror_qemu.git/commitdiff
virtio-balloon: Prevent guest from starting a report when we didn't request one
authorAlexander Duyck <alexander.h.duyck@linux.intel.com>
Mon, 20 Jul 2020 17:51:15 +0000 (10:51 -0700)
committerMichael S. Tsirkin <mst@redhat.com>
Wed, 22 Jul 2020 11:57:07 +0000 (07:57 -0400)
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

index e670f1e595342854ea95e0ff9e21f9232d80419a..ce70adcc69253652904f97e225e77031637bc9b2 100644 (file)
@@ -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 {
             /*