yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-vmstate_xhci_event-fix-unterminated-field-list.patch

9ae3a8
From 00beaa541050bcbf399e116772db3746cb0c0278 Mon Sep 17 00:00:00 2001
9ae3a8
From: Laszlo Ersek <lersek@redhat.com>
9ae3a8
Date: Mon, 1 Sep 2014 13:36:52 +0200
9ae3a8
Subject: [PATCH 05/12] vmstate_xhci_event: fix unterminated field list
9ae3a8
9ae3a8
Message-id: <1409578613-11909-2-git-send-email-lersek@redhat.com>
9ae3a8
Patchwork-id: 60781
9ae3a8
O-Subject: [PATCH RHEL-7.0.z/RHEL-7.1.0 qemu-kvm 1/2] vmstate_xhci_event: fix unterminated field list
9ae3a8
Bugzilla: 1122147
9ae3a8
RH-Acked-by: Amit Shah <amit.shah@redhat.com>
9ae3a8
RH-Acked-by: Juan Quintela <quintela@redhat.com>
9ae3a8
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
9ae3a8
9ae3a8
"vmstate_xhci_event" was introduced in commit 37352df3 ("xhci: add live
9ae3a8
migration support"), and first released in v1.6.0. The field list in this
9ae3a8
VMSD is not terminated with the VMSTATE_END_OF_LIST() macro.
9ae3a8
9ae3a8
During normal use (ie. migration), the issue is practically invisible,
9ae3a8
because the "vmstate_xhci_event" object (with the unterminated field list)
9ae3a8
is only ever referenced -- via "vmstate_xhci_intr" -- if xhci_er_full()
9ae3a8
returns true, for the "ev_buffer" test. Since that field_exists() check
9ae3a8
(apparently) almost always returns false, we almost never traverse
9ae3a8
"vmstate_xhci_event" during migration, which hides the bug.
9ae3a8
9ae3a8
However, Amit's vmstate checker forces recursion into this VMSD as well,
9ae3a8
and the lack of VMSTATE_END_OF_LIST() breaks the field list terminator
9ae3a8
check (field->name != NULL) in dump_vmstate_vmsd(). The result is
9ae3a8
undefined behavior, which in my case translates to infinite recursion
9ae3a8
(because the loop happens to overflow into "vmstate_xhci_intr", which then
9ae3a8
links back to "vmstate_xhci_event").
9ae3a8
9ae3a8
Add the missing terminator.
9ae3a8
9ae3a8
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
9ae3a8
Reviewed-by: Amit Shah <amit.shah@redhat.com>
9ae3a8
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
Cc: qemu-stable@nongnu.org
9ae3a8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9ae3a8
(cherry picked from commit 3afca1d6d413592c2b78cf28f52fa24a586d8f56)
9ae3a8
9ae3a8
RHEL-7 note: this is for CVE-2014-5263.
9ae3a8
9ae3a8
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 hw/usb/hcd-xhci.c |    1 +
9ae3a8
 1 files changed, 1 insertions(+), 0 deletions(-)
9ae3a8
9ae3a8
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
9ae3a8
index fd1bd89..0ef2bc4 100644
9ae3a8
--- a/hw/usb/hcd-xhci.c
9ae3a8
+++ b/hw/usb/hcd-xhci.c
9ae3a8
@@ -3526,6 +3526,7 @@ static const VMStateDescription vmstate_xhci_event = {
9ae3a8
         VMSTATE_UINT32(flags,  XHCIEvent),
9ae3a8
         VMSTATE_UINT8(slotid,  XHCIEvent),
9ae3a8
         VMSTATE_UINT8(epid,    XHCIEvent),
9ae3a8
+        VMSTATE_END_OF_LIST()
9ae3a8
     }
9ae3a8
 };
9ae3a8
 
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8