Message ID | 20190306155048.12868-5-nitesh@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | KVM: Guest Free Page Hinting | expand |
diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index cfe7574b5204..e82c72cd916b 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -970,6 +970,11 @@ static int virtballoon_probe(struct virtio_device *vdev) } #ifdef CONFIG_KVM_FREE_PAGE_HINTING + if (virtio_has_feature(vdev, VIRTIO_BALLOON_F_PAGE_POISON)) { + memset(&poison_val, PAGE_POISON, sizeof(poison_val)); + virtio_cwrite(vb->vdev, struct virtio_balloon_config, + poison_val, &poison_val); + } if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_HINTING)) enable_hinting(vb); #endif
This patch enables the kernel to report the page poisoning value to the host by using VIRTIO_BALLOON_F_PAGE_POISON feature. Page Poisoning is a feature in which the page is filled with a specific pattern of (0x00 or 0xaa) after freeing and the same is verified before allocation to prevent following issues: *information leak from the freed data *use after free bugs *memory corruption The issue arises when the pattern used for Page Poisoning is 0xaa while the newly allocated page received from the host by the guest is filled with the pattern 0x00. This will result in memory corruption errors. Signed-off-by: Nitesh Narayan Lal <nitesh@redhat.com> --- drivers/virtio/virtio_balloon.c | 5 +++++ 1 file changed, 5 insertions(+)