Skip to contentSkip to conversation

vmstate_xhci_event: fix unterminated field list

PATCH In review Laszlo Ersek 4 participants 5 messages Jul 22, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vmstate_xhci_event: fix unterminated field list

"vmstate_xhci_event" was introduced in commit 37352df3 ("xhci: add live migration support"), and first released in v1.6.0. The field list in this VMSD is not terminated with the VMSTATE_END_OF_LIST() macro.

During normal use (ie. migration), the issue is practically invisible, because the "vmstate_xhci_event" object (with the unterminated field list) is only ever referenced -- via "vmstate_xhci_intr" -- if xhci_er_full() returns true, for the "ev_buffer" test. Since that field_exists() check (apparently) almost always returns false, we almost never traverse "vmstate_xhci_event" during migration, which hides the bug.

However, Amit's vmstate checker forces recursion into this VMSD as well, and the lack of VMSTATE_END_OF_LIST() breaks the field list terminator check (field->name != NULL) in dump_vmstate_vmsd(). The result is undefined behavior, which in my case translates to infinite recursion (because the loop happens to overflow into "vmstate_xhci_intr", which then links back to "vmstate_xhci_event").

Add the missing terminator.

---
 hw/usb/hcd-xhci.c | 1 +
 1 file changed, 1 insertion(+)
hw/usb/hcd-xhci.c +1 -0
index 7f2af89..58c4b11 100644
@@ -3737,6 +3737,7 @@ static const VMStateDescription vmstate_xhci_event = {
         VMSTATE_UINT32(flags,  XHCIEvent),
         VMSTATE_UINT8(slotid,  XHCIEvent),
         VMSTATE_UINT8(epid,    XHCIEvent),
+        VMSTATE_END_OF_LIST()
     }
 };
 
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 18 lines · Laszlo Ersek

"vmstate_xhci_event" was introduced in commit 37352df3 ("xhci: add live migration support"), and first released in v1.6.0. The field list in this VMSD is not terminated with the VMSTATE_END_OF_LIST() macro.

During normal use (ie. migration), the issue is practically invisible, because the "vmstate_xhci_event" object (with the unterminated field list) is only ever referenced -- via "vmstate_xhci_intr" -- if xhci_er_full() returns true, for the "ev_buffer" test. Since that field_exists() check (apparently) almost always returns false, we almost never traverse "vmstate_xhci_event" during migration, which hides the bug.

However, Amit's vmstate checker forces recursion into this VMSD as well, and the lack of VMSTATE_END_OF_LIST() breaks the field list terminator check (field->name != NULL) in dump_vmstate_vmsd(). The result is undefined behavior, which in my case translates to infinite recursion (because the loop happens to overflow into "vmstate_xhci_intr", which then links back to "vmstate_xhci_event").

Quoted 3 lines

Add the missing terminator.

Thanks for spotting this!

Amit

Reviewed-by on v1 1/1
#2 lore raw
In reply to Laszlo Ersek

Il 22/07/2014 17:26, Laszlo Ersek ha scritto:

Quoted 31 lines

"vmstate_xhci_event" was introduced in commit 37352df3 ("xhci: add live migration support"), and first released in v1.6.0. The field list in this VMSD is not terminated with the VMSTATE_END_OF_LIST() macro.

During normal use (ie. migration), the issue is practically invisible, because the "vmstate_xhci_event" object (with the unterminated field list) is only ever referenced -- via "vmstate_xhci_intr" -- if xhci_er_full() returns true, for the "ev_buffer" test. Since that field_exists() check (apparently) almost always returns false, we almost never traverse "vmstate_xhci_event" during migration, which hides the bug.

However, Amit's vmstate checker forces recursion into this VMSD as well, and the lack of VMSTATE_END_OF_LIST() breaks the field list terminator check (field->name != NULL) in dump_vmstate_vmsd(). The result is undefined behavior, which in my case translates to infinite recursion (because the loop happens to overflow into "vmstate_xhci_intr", which then links back to "vmstate_xhci_event").

Add the missing terminator.

---
 hw/usb/hcd-xhci.c | 1 +
 1 file changed, 1 insertion(+)
hw/usb/hcd-xhci.c +0 -0
index 7f2af89..58c4b11 100644

hw/usb/hcd-xhci.c static const VMStateDescription vmstate_xhci_event = { · line 3743

Quoted 7 lines
hw/usb/hcd-xhci.c +1 -0
@@ -3737,6 +3737,7 @@ static const VMStateDescription vmstate_xhci_event = {
         VMSTATE_UINT32(flags,  XHCIEvent),
         VMSTATE_UINT8(slotid,  XHCIEvent),
         VMSTATE_UINT8(epid,    XHCIEvent),
+        VMSTATE_END_OF_LIST()
     }
 };
 
#3 lore raw
Quoted 26 lines · Paolo Bonzini

Il 22/07/2014 17:26, Laszlo Ersek ha scritto:

Quoted 25 lines

"vmstate_xhci_event" was introduced in commit 37352df3 ("xhci: add live migration support"), and first released in v1.6.0. The field list in this VMSD is not terminated with the VMSTATE_END_OF_LIST() macro.

During normal use (ie. migration), the issue is practically invisible, because the "vmstate_xhci_event" object (with the unterminated field list) is only ever referenced -- via "vmstate_xhci_intr" -- if xhci_er_full() returns true, for the "ev_buffer" test. Since that field_exists() check (apparently) almost always returns false, we almost never traverse "vmstate_xhci_event" during migration, which hides the bug.

However, Amit's vmstate checker forces recursion into this VMSD as well, and the lack of VMSTATE_END_OF_LIST() breaks the field list terminator check (field->name != NULL) in dump_vmstate_vmsd(). The result is undefined behavior, which in my case translates to infinite recursion (because the loop happens to overflow into "vmstate_xhci_intr", which then links back to "vmstate_xhci_event").

Add the missing terminator.

---
 hw/usb/hcd-xhci.c | 1 +
 1 file changed, 1 insertion(+)
Quoted 15 lines

hw/usb/hcd-xhci.c static const VMStateDescription vmstate_xhci_event = { · line 3743

Quoted 13 lines
hw/usb/hcd-xhci.c +1 -0
index 7f2af89..58c4b11 100644
@@ -3737,6 +3737,7 @@ static const VMStateDescription vmstate_xhci_event = {
         VMSTATE_UINT32(flags,  XHCIEvent),
         VMSTATE_UINT8(slotid,  XHCIEvent),
         VMSTATE_UINT8(epid,    XHCIEvent),
+        VMSTATE_END_OF_LIST()
     }
 };
 

As far as I can see, this address was present in my original To: list. :) (Admittedly, not with CC.)

Quoted 1 line

Thank you!

Laszlo

#4 lore raw
Quoted 5 lines · Laszlo Ersek
Quoted 1 line · Paolo Bonzini

As far as I can see, this address was present in my original To: list. :) (Admittedly, not with CC.)

Including the line in the commit message means it can get pulled back out of the git log automatically for application to the stable branch.

I'll commit this to master shortly.

thanks
-- PMM