All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] libxl: prepare environment for domcreate_stream_done
@ 2019-03-07 10:56 Olaf Hering
  2019-03-07 11:02 ` Wei Liu
  0 siblings, 1 reply; 6+ messages in thread
From: Olaf Hering @ 2019-03-07 10:56 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Olaf Hering, Ian Jackson

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.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
---
 tools/libxl/libxl_create.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index a4e74a5cd2..989ce6d5bd 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -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
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v1] libxl: prepare environment for domcreate_stream_done
  2019-03-07 10:56 [PATCH v1] libxl: prepare environment for domcreate_stream_done Olaf Hering
@ 2019-03-07 11:02 ` Wei Liu
  2019-03-07 11:53   ` Olaf Hering
  0 siblings, 1 reply; 6+ messages in thread
From: Wei Liu @ 2019-03-07 11:02 UTC (permalink / raw)
  To: Olaf Hering; +Cc: xen-devel, Ian Jackson, Wei Liu

Thanks for the patch!

On Thu, Mar 07, 2019 at 11:56:49AM +0100, Olaf Hering wrote:
> 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.
> 
> Signed-off-by: Olaf Hering <olaf@aepfle.de>
> ---
>  tools/libxl/libxl_create.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
> index a4e74a5cd2..989ce6d5bd 100644
> --- a/tools/libxl/libxl_create.c
> +++ b/tools/libxl/libxl_create.c
> @@ -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.


>      /* 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
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1] libxl: prepare environment for domcreate_stream_done
  2019-03-07 11:02 ` Wei Liu
@ 2019-03-07 11:53   ` Olaf Hering
  2019-03-07 12:18     ` Wei Liu
  0 siblings, 1 reply; 6+ messages in thread
From: Olaf Hering @ 2019-03-07 11:53 UTC (permalink / raw)
  To: Wei Liu; +Cc: xen-devel, Ian Jackson


[-- Attachment #1.1: Type: text/plain, Size: 481 bytes --]

Am Thu, 7 Mar 2019 11:02:47 +0000
schrieb Wei Liu <wei.liu2@citrix.com>:

> 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

[-- Attachment #1.2: Digitale Signatur von OpenPGP --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 157 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1] libxl: prepare environment for domcreate_stream_done
  2019-03-07 11:53   ` Olaf Hering
@ 2019-03-07 12:18     ` Wei Liu
  2019-03-08  9:22       ` Olaf Hering
  0 siblings, 1 reply; 6+ messages in thread
From: Wei Liu @ 2019-03-07 12:18 UTC (permalink / raw)
  To: Olaf Hering; +Cc: xen-devel, Wei Liu, Ian Jackson

On Thu, Mar 07, 2019 at 12:53:38PM +0100, Olaf Hering wrote:
> Am Thu, 7 Mar 2019 11:02:47 +0000
> schrieb Wei Liu <wei.liu2@citrix.com>:
> 
> > 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?

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.

> 
> Olaf



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1] libxl: prepare environment for domcreate_stream_done
  2019-03-07 12:18     ` Wei Liu
@ 2019-03-08  9:22       ` Olaf Hering
  2019-03-08 10:59         ` Wei Liu
  0 siblings, 1 reply; 6+ messages in thread
From: Olaf Hering @ 2019-03-08  9:22 UTC (permalink / raw)
  To: Wei Liu; +Cc: xen-devel, Ian Jackson


[-- Attachment #1.1: Type: text/plain, Size: 401 bytes --]

Am Thu, 7 Mar 2019 12:18:20 +0000
schrieb Wei Liu <wei.liu2@citrix.com>:

> 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

[-- Attachment #1.2: Digitale Signatur von OpenPGP --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 157 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1] libxl: prepare environment for domcreate_stream_done
  2019-03-08  9:22       ` Olaf Hering
@ 2019-03-08 10:59         ` Wei Liu
  0 siblings, 0 replies; 6+ messages in thread
From: Wei Liu @ 2019-03-08 10:59 UTC (permalink / raw)
  To: Olaf Hering; +Cc: xen-devel, Wei Liu, Ian Jackson

On Fri, Mar 08, 2019 at 10:22:18AM +0100, Olaf Hering wrote:
> Am Thu, 7 Mar 2019 12:18:20 +0000
> schrieb Wei Liu <wei.liu2@citrix.com>:
> 
> > 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.

> Olaf



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-03-08 10:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-07 10:56 [PATCH v1] libxl: prepare environment for domcreate_stream_done Olaf Hering
2019-03-07 11:02 ` Wei Liu
2019-03-07 11:53   ` Olaf Hering
2019-03-07 12:18     ` Wei Liu
2019-03-08  9:22       ` Olaf Hering
2019-03-08 10:59         ` Wei Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.