Three small fixes over qom-list-properties crash
cover Three small fixes over qom-list-properties crash
Markus's report is here:
https://lore.kernel.org/r/[email protected]
These three that are relevant to either migration or memory, so I had a look.
Peter Xu (3):
colo-compare: Fix QMP qom-list-properties crashing system/ioport: Fix qom-list-properties crash on portio list obj
qio: Fix qom-list-properties crash on net listener object
io/net-listener.c | 14 +++++++++----- net/colo-compare.c | 9 +++++++++ system/ioport.c | 11 +++++++++-- 3 files changed, 27 insertions(+), 7 deletions(-)
Signature · 1 line
2.53.0
PATCH 1/3 colo-compare: Fix QMP qom-list-properties crashing
Many of the colo_compare_finalize() code relies on complete() done in the first place, hence the crash. Fix it by detecting if complete() is executed, skip the rest when not.
--- net/colo-compare.c | 9 +++++++++ 1 file changed, 9 insertions(+)
net/colo-compare.c +9 -0
@@ -1416,6 +1416,15 @@ static void colo_compare_finalize(Object *obj)break ; } } +/* +* If this object is never visible (colo_compare_complete() not invoked +* or failed), skip the rest. One path to trigger this is QMP command +* qom-list-properties. +*/ +if (tmp != s) { +qemu_mutex_unlock (&colo_compare_mutex); +return ; + }if (QTAILQ_EMPTY (&net_compares)) { colo_compare_active = false;qemu_mutex_destroy (&event_mtx);
Signature · 1 line
2.53.0
PATCH 2/3 system/ioport: Fix qom-list-properties crash on portio list obj
In reply to Peter XuCurrently qom-list-properties QMP command will crash when querying the portio list MR object. It's because its finalize() assumes full initialization done in portio_list_add_1().
Provide a simple fix for now to avoid the crash. There is chance for a longer term fix, ideally MR should be initialized in instance_init().
However that'll need more work, and that should also be done with cleaning the hard-coded MR operations in portio_list_add_1(). To be explored.
--- system/ioport.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
system/ioport.c +9 -2
@@ -346,8 +346,15 @@ static void memory_region_portio_list_finalize(Object *obj) {MemoryRegionPortioList *mrpio =MEMORY_REGION_PORTIO_LIST (obj); -object_unref (&mrpio->mr); -g_free (mrpio->ports); +/* +* This check makes sure any random object_new() (without doing the +* rest inits in portio_list_add_1()) will not crash when finalizing. +* One example is QMP command qom-list-properties. +*/ +if (mrpio->ports) { +object_unref (&mrpio->mr); +g_free (mrpio->ports); + } }static const TypeInfo memory_region_portio_list_info = {
Signature · 1 line
2.53.0
PATCH 3/3 qio: Fix qom-list-properties crash on net listener object
In reply to Peter XuThe QIO net listener object will crash with raw object_new() then dereference the object, like what QMP command qom-list-properties would do. Fix it by moving mutex init into instance_init().
--- io/net-listener.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
io/net-listener.c +9 -5
@@ -35,11 +35,7 @@ struct QIONetListenerSource {QIONetListener *qio_net_listener_new (void ) { -QIONetListener *listener; - - listener =QIO_NET_LISTENER (object_new (TYPE_QIO_NET_LISTENER )); -qemu_mutex_init (&listener->lock); -return listener; +return QIO_NET_LISTENER (object_new (TYPE_QIO_NET_LISTENER )); } void qio_net_listener_set_name(QIONetListener *listener,
@@ -440,6 +436,13 @@ qio_net_listener_get_local_address(QIONetListener *listener, size_t n,return qio_channel_socket_get_local_address (sioc, errp); } +static void qio_net_listener_init (Object *obj) +{ +QIONetListener *listener =QIO_NET_LISTENER (obj); + +qemu_mutex_init (&listener->lock); +} +static void qio_net_listener_finalize (Object *obj) {QIONetListener *listener =QIO_NET_LISTENER (obj);
@@ -462,6 +465,7 @@ static void qio_net_listener_finalize(Object *obj)static const TypeInfo qio_net_listener_info = { .parent =TYPE_OBJECT , .name =TYPE_QIO_NET_LISTENER , + .instance_init = qio_net_listener_init, .instance_size =sizeof (QIONetListener), .instance_finalize = qio_net_listener_finalize, };
Signature · 1 line
2.53.0
Re: [PATCH 3/3] qio: Fix qom-list-properties crash on net listener object
Quoted 11 lines · Peter Xu
The QIO net listener object will crash with raw
object_new()then dereference the object, like what QMP command qom-list-properties would do. Fix it by moving mutex init intoinstance_init().Cc Daniel P. Berrangé <[email protected]>Reported-by Markus Armbruster <[email protected]>Signed-off-by Peter Xu <[email protected]>--- io/net-listener.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
Quoted 6 lines · Peter Xu
Markus's report is here:
https://lore.kernel.org/r/[email protected]
These three that are relevant to either migration or memory, so I had a look.
Thank you!
Series
Suggest to include the reproducer in the commit messages.
Quoted 9 lines · Markus Armbruster
Quoted 6 lines · Peter Xu
Markus's report is here:
https://lore.kernel.org/r/[email protected]
These three that are relevant to either migration or memory, so I had a look.
Quoted 7 lines
Thank you!
Series
Tested-by Markus Armbruster <[email protected]>Suggest to include the reproducer in the commit messages.
I saw Marc-André sent a more comprehensive series; I'll drop this one then. Thanks for taking a look.
Signature · 1 line
Peter Xu