Skip to contentSkip to conversation

libxl: prepare environment for domcreate_stream_done

PATCH In review Olaf Hering 4 participants 7 messages Mar 8, 2019 – Mar 11, 2019

lore
Share & tools
lore
#0 lore raw

PATCH v2 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.

---
v2:
unconditional assignment

 tools/libxl/libxl_create.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/libxl/libxl_create.c +3 -1
index a4e74a5cd2..c8b5ea984b 100644
@@ -1093,6 +1093,9 @@ static void domcreate_bootloader_done(libxl__egc *egc,
         return;
     }
 
+    /* Prepare environment for domcreate_stream_done */
+    dcs->srs.dcs = dcs;
+
     /* Restore */
     callbacks->restore_results = libxl__srm_callout_callback_restore_results;
 
@@ -1116,7 +1119,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

Acked-by on v2 1/1
#1 lore raw
Quoted 8 lines · Olaf Hering

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.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
In reply to Olaf Hering

Olaf Hering writes ("[PATCH v2] libxl: prepare environment for domcreate_stream_done"):

Quoted 3 lines

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.

Thanks. I think this is OK as far as it goes. But:

tools/libxl/libxl_create.c static void domcreate_bootloader_done(libxl__egc *egc, · line 1097

Quoted 2 lines
tools/libxl/libxl_create.c +2 -0
+    /* Prepare environment for domcreate_stream_done */
+    dcs->srs.dcs = dcs;

The need for this comment is telling us something about the weird code structure here. We initialise all of dcs->srs much later, so even with this change we call domcreate_stream_done with a mostly-uninitialised srs.

In fact this is OK because domcreate_stream_done only reads srs->dcs and then does everything with the obtained dcs. But there is nothing there to indicate that srs might be mostly uninitialised. Maybe we could add a comment there, something like:

/* NB perhaps only srs->dcs is valid; eg in the case of an
* early branch to domcreate_bootloader_done's `out' block */

?

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw

Am Fri, 8 Mar 2019 14:08:10 +0000
schrieb Ian Jackson <[email protected]>:

Quoted 7 lines

In fact this is OK because domcreate_stream_done only reads srs->dcs and then does everything with the obtained dcs. But there is nothing there to indicate that srs might be mostly uninitialised. Maybe we could add a comment there, something like:

/* NB perhaps only srs->dcs is valid; eg in the case of an
* early branch to domcreate_bootloader_done's `out' block */

I'm find with that. Can this comment be adjusted at commit time?

Olaf

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#4 lore raw
Quoted 8 lines · Olaf Hering

Am Fri, 8 Mar 2019 14:08:10 +0000
schrieb Ian Jackson <[email protected]>:

Quoted 5 lines

In fact this is OK because domcreate_stream_done only reads srs->dcs and then does everything with the obtained dcs. But there is nothing there to indicate that srs might be mostly uninitialised. Maybe we could add a comment there, something like:

Quoted 4 lines
Quoted 2 lines

/* NB perhaps only srs->dcs is valid; eg in the case of an
* early branch to domcreate_bootloader_done's `out' block */

I'm find with that. Can this comment be adjusted at commit time?

Sure.

Wei.

Quoted 2 lines

Olaf

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#5 lore raw
In reply to Olaf Hering

Olaf Hering writes ("Re: [PATCH v2] libxl: prepare environment for domcreate_stream_done"):

Quoted 8 lines

Am Fri, 8 Mar 2019 14:08:10 +0000
schrieb Ian Jackson <[email protected]>:

Quoted 5 lines

In fact this is OK because domcreate_stream_done only reads srs->dcs and then does everything with the obtained dcs. But there is nothing there to indicate that srs might be mostly uninitialised. Maybe we could add a comment there, something like:

Quoted 4 lines
Quoted 2 lines

/* NB perhaps only srs->dcs is valid; eg in the case of an
* early branch to domcreate_bootloader_done's `out' block */

I'm find with that. Can this comment be adjusted at commit time?

Sure, although if it's me that commits it I'd do it as a followup patch.

We need a release ack I think for 4.12. Subject adjusted, CCing Juergen. Juergen, will bounce the original patch to you too.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#6 lore raw
In reply to Olaf Hering
Quoted 8 lines · Olaf Hering

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.

As we are very close to a 4.12 release and this is no recent regression I'd like to defer this patch to 4.13.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel