]> git.proxmox.com Git - mirror_qemu.git/commit
virtio-balloon: Fix possible guest memory corruption with inflates & deflates
authorDavid Gibson <david@gibson.dropbear.id.au>
Wed, 6 Mar 2019 03:06:00 +0000 (14:06 +1100)
committerMichael S. Tsirkin <mst@redhat.com>
Wed, 13 Mar 2019 01:22:31 +0000 (21:22 -0400)
commitb27b3239140470b7d593e3b0b09687bcc6fbf274
treedabf6adae3666ca5a72bd49e4baf9c01a7dcd459
parent301cf2a8dd5024aa5bbdc6bd3e121174bbfc2957
virtio-balloon: Fix possible guest memory corruption with inflates & deflates

This fixes a balloon bug with a nasty consequence - potentially
corrupting guest memory - but which is extremely unlikely to be
triggered in practice.

The balloon always works in 4kiB units, but the host could have a
larger page size on certain platforms.  Since ed48c59 "virtio-balloon:
Safely handle BALLOON_PAGE_SIZE < host page size" we've handled this
by accumulating requests to balloon 4kiB subpages until they formed a
full host page.  Since f6deb6d "virtio-balloon: Remove unnecessary
MADV_WILLNEED on deflate" we essentially ignore deflate requests.

Suppose we have a host with 8kiB pages, and one host page has subpages
A & B.  If we get this sequence of events -
inflate A
deflate A
inflate B
- the current logic will discard the whole host page.  That's
incorrect because the guest has deflated subpage A, and could have
written important data to it.

This patch fixes the problem by adjusting our state information about
partially ballooned host pages when deflate requests are received.

Fixes: ed48c59 "virtio-balloon: Safely handle BALLOON_PAGE_SIZE < host page size"
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Message-Id: <20190306030601.21986-3-david@gibson.dropbear.id.au>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: David Hildenbrand <david@redhat.com>
hw/virtio/virtio-balloon.c