libxl: prepare environment for domcreate_stream_done
PATCH 1/1 libxl: prepare environment for domcreate_stream_done
The function domcreate_bootloader_done may branch early to domcreate_stream_done, in case some error occoured. Here srs->dcs will be NULL, which leads to a crash.
It is unclear what the purpose of that backpointer is. Perhaps it can be removed, and domcreate_stream_done could use CONTAINER_OF.
--- tools/libxl/libxl_create.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tools/libxl/libxl_create.c +4 -1
@@ -1093,6 +1093,10 @@ static void domcreate_bootloader_done(libxl__egc *egc,return ; } +/* Prepare environment for domcreate_stream_done */ +if (!dcs->srs.dcs) + dcs->srs.dcs = dcs; +/* Restore */ callbacks->restore_results = libxl__srm_callout_callback_restore_results;
@@ -1116,7 +1120,6 @@ static void domcreate_bootloader_done(libxl__egc *egc, goto out; dcs->srs.ao = ao; - dcs->srs.dcs = dcs; dcs->srs.fd = restore_fd; dcs->srs.legacy = (dcs->restore_params.stream_version ==1 ); dcs->srs.back_channel = false;
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Thanks for the patch!
Quoted 17 lines · Olaf Hering
The function
domcreate_bootloader_donemay branch early todomcreate_stream_done, in case some error occoured. Heresrs->dcswill be NULL, which leads to a crash.It is unclear what the purpose of that backpointer is. Perhaps it can be removed, and
domcreate_stream_donecould useCONTAINER_OF.Signed-off-by Olaf Hering <[email protected]>--- tools/libxl/libxl_create.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)tools/libxl/libxl_create.c +0
-0
tools/libxl/libxl_create.c static void domcreate_bootloader_done(libxl__egc *egc, · line 1099
Quoted 7 lines
tools/libxl/libxl_create.c +4
-0@@ -1093,6 +1093,10 @@ static void domcreate_bootloader_done(libxl__egc *egc,return ; } +/* Prepare environment for domcreate_stream_done */ +if (!dcs->srs.dcs) + dcs->srs.dcs = dcs; +
Have you seen the field been set before entering this function? Or is the if () just a precaution?
If it is the latter, can we have an ASSERT instead? Seeing the original code already unconditionally assigns dcs, I don't think you can make it any worse than before.
Wei.
tools/libxl/libxl_create.c static void domcreate_bootloader_done(libxl__egc *egc, · line 1125
Quoted 11 lines
tools/libxl/libxl_create.c +0
-1/* Restore */ callbacks->restore_results = libxl__srm_callout_callback_restore_results;@@ -1116,7 +1120,6 @@ static void domcreate_bootloader_done(libxl__egc *egc, goto out; dcs->srs.ao = ao; - dcs->srs.dcs = dcs; dcs->srs.fd = restore_fd; dcs->srs.legacy = (dcs->restore_params.stream_version ==1 ); dcs->srs.back_channel = false;
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Am Thu, 7 Mar 2019 11:02:47 +0000
schrieb Wei Liu <[email protected]>:
Quoted 2 lines
Have you seen the field been set before entering this function? Or is the if () just a precaution?
Sorry, this is not the variant I intended to send. The assignment was supposed to be unconditionally.
Today I browsed the code and it was not clear if that backpointer is really required. Does anyone know if srs->dcs can ever be something else than the dcs which contains that srs?
Olaf
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 6 lines · Olaf Hering
Am Thu, 7 Mar 2019 11:02:47 +0000
schrieb Wei Liu <[email protected]>:Quoted 2 lines
Have you seen the field been set before entering this function? Or is the if () just a precaution?
Quoted 6 lines
Sorry, this is not the variant I intended to send. The assignment was supposed to be unconditionally.
Today I browsed the code and it was not clear if that backpointer is really required. Does anyone know if
srs->dcscan ever be something else than the dcs which contains that srs?
That code has been changed quite a bit with migration v2 and COLO. I wouldn't be surprised if some code becomes stale.
Sadly I won't have time today to dig into the history.
Wei.
Quoted 2 lines
Olaf
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Am Thu, 7 Mar 2019 12:18:20 +0000
schrieb Wei Liu <[email protected]>:
Quoted 2 lines
That code has been changed quite a bit with migration v2 and COLO. I wouldn't be surprised if some code becomes stale.
Are you ok with just moving that assignment up to avoid the crash? This should be backported to at least 4.10, older branches need that too. A thoroughly review can still be done later.
Olaf
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 10 lines · Olaf Hering
Am Thu, 7 Mar 2019 12:18:20 +0000
schrieb Wei Liu <[email protected]>:Quoted 2 lines
That code has been changed quite a bit with migration v2 and COLO. I wouldn't be surprised if some code becomes stale.
Are you ok with just moving that assignment up to avoid the crash? This should be backported to at least 4.10, older branches need that too. A thoroughly review can still be done later.
Sure. That would be fine by me. Thanks for fixing this issue.
Wei.
Quoted 1 line
Olaf
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel